Created
January 30, 2013 09:44
-
-
Save jmoody/4672008 to your computer and use it in GitHub Desktop.
a main.m file for GHUnit that fixes problems described in gh-unit issue 96 - command line tests failing for Xcode 4.5 (and 4.6) for iOS 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <objc/runtime.h> | |
#import <objc/message.h> | |
@interface UIWindow (Private) | |
- (void) swizzled_createContext; | |
@end | |
@implementation UIWindow (Private) | |
- (void) swizzled_createContext { | |
// nop | |
} | |
@end | |
int main(int argc, char *argv[]) { | |
int retVal; | |
@autoreleasepool { | |
CFMessagePortRef portRef = NULL; | |
if (getenv("GHUNIT_CLI")) { | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wundeclared-selector" | |
Method originalWindowCreateContext = | |
class_getInstanceMethod([UIWindow class], | |
@selector(_createContext)); | |
#pragma clang diagnostic pop | |
Method swizzledWindowCreateConext = | |
class_getInstanceMethod([UIWindow class], | |
@selector(swizzled_createContext)); | |
method_exchangeImplementations(originalWindowCreateContext, | |
swizzledWindowCreateConext); | |
portRef = CFMessagePortCreateLocal(NULL, | |
(CFStringRef) @"PurpleWorkspacePort", | |
NULL, | |
NULL, | |
NULL); | |
} | |
retVal = UIApplicationMain(argc, argv, | |
NSStringFromClass([UIApplication class]), | |
@"GHUnitIOSAppDelegate"); | |
if (portRef != NULL) { CFRelease(portRef); } | |
} | |
return retVal; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gh-unit issue: gh-unit/gh-unit#96
thanks @barumrho for pointing out that this
http://stackoverflow.com/questions/12557935/xcode-4-5-command-line-unit-testing/14395861#14395861
works.