main.mm 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "RegisterMonoModules.h"
  2. #include "RegisterFeatures.h"
  3. #include <csignal>
  4. // Hack to work around iOS SDK 4.3 linker problem
  5. // we need at least one __TEXT, __const section entry in main application .o files
  6. // to get this section emitted at right time and so avoid LC_ENCRYPTION_INFO size miscalculation
  7. static const int constsection = 0;
  8. void UnityInitTrampoline();
  9. // WARNING: this MUST be c decl (NSString ctor will be called after +load, so we cant really change its value)
  10. const char* AppControllerClassName = "UnityAppController";
  11. int main(int argc, char* argv[])
  12. {
  13. UnityInitStartupTime();
  14. @autoreleasepool
  15. {
  16. UnityInitTrampoline();
  17. UnityInitRuntime(argc, argv);
  18. RegisterMonoModules();
  19. NSLog(@"-> registered mono modules %p\n", &constsection);
  20. RegisterFeatures();
  21. // iOS terminates open sockets when an application enters background mode.
  22. // The next write to any of such socket causes SIGPIPE signal being raised,
  23. // even if the request has been done from scripting side. This disables the
  24. // signal and allows Mono to throw a proper C# exception.
  25. std::signal(SIGPIPE, SIG_IGN);
  26. UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String: AppControllerClassName]);
  27. }
  28. return 0;
  29. }
  30. #if TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR
  31. #include <pthread.h>
  32. extern "C" int pthread_cond_init$UNIX2003(pthread_cond_t *cond, const pthread_condattr_t *attr)
  33. { return pthread_cond_init(cond, attr); }
  34. extern "C" int pthread_cond_destroy$UNIX2003(pthread_cond_t *cond)
  35. { return pthread_cond_destroy(cond); }
  36. extern "C" int pthread_cond_wait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex)
  37. { return pthread_cond_wait(cond, mutex); }
  38. extern "C" int pthread_cond_timedwait$UNIX2003(pthread_cond_t *cond, pthread_mutex_t *mutex,
  39. const struct timespec *abstime)
  40. { return pthread_cond_timedwait(cond, mutex, abstime); }
  41. #endif // TARGET_IPHONE_SIMULATOR && TARGET_TVOS_SIMULATOR