Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // AppDelegate.m
  2.  
  3. @implementation AppDelegate
  4.  
  5. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  6. {
  7. if (isRunningTests()) return YES;
  8. // ...
  9. return YES;
  10. }
  11.  
  12. BOOL isRunningTests(void)
  13. {
  14. NSDictionary* environment = [[NSProcessInfo processInfo] environment];
  15. NSString* injectBundle = environment[@"XCInjectBundle"];
  16. return [[injectBundle pathExtension] isEqualToString:@"xctest"];
  17. }
  18.  
  19. - (instancetype)init
  20. {
  21. self = [super init];
  22. if (self) {
  23. if (isRunningTests()){
  24. // This bundle has unit tests injected. Let's not really start the app to avoid interfering with the tests.
  25. id infoDictionary = [[NSBundle mainBundle] infoDictionary];
  26. [infoDictionary setValue:@"UnitTest" forKey:@"UIMainStoryboardFile"];
  27. }
  28. }
  29. return self;
  30. }
  31. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement