Skip to content

Instantly share code, notes, and snippets.

@SiarheiFedartsou
Created July 18, 2014 06:08
Show Gist options
  • Save SiarheiFedartsou/97457b95413ced000193 to your computer and use it in GitHub Desktop.
Save SiarheiFedartsou/97457b95413ced000193 to your computer and use it in GitHub Desktop.
#ifdef DEBUG
/// Tests if .xctest bundle is loaded, so returns YES if the app is running with XCTest framework.
inline BOOL IsUnitTesting() __attribute__((const));
inline BOOL IsUnitTesting()
{
NSDictionary *environment = [NSProcessInfo processInfo].environment;
NSString *injectBundlePath = environment[@"XCInjectBundle"];
return [injectBundlePath.pathExtension isEqualToString:@"xctest"];
}
#endif
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef DEBUG
if (IsUnitTesting()) return YES;
#endif
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment