-
-
Save iShawnWang/d904934efded271d83b36288562df410 to your computer and use it in GitHub Desktop.
Detect Ad Hoc Build Configuration in code at runtime
This file contains hidden or 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
//AdHoc detect with following 2 conditions : | |
//1.`embedded.mobileprovision` contains field `ProvisionedDevices` (Debug and Ad Hoc Build contains this field ,Release not) | |
//2.it is not DEBUG Build , we can use `#ifdef DEBUG` to decide it | |
NS_INLINE BOOL isAdHoc(){ | |
BOOL isAdHoc = NO; | |
BOOL isDebug; | |
#ifdef DEBUG | |
isDebug=YES; | |
#else | |
isDebug=NO; | |
#endif | |
NSData *data=[NSData dataWithContentsOfURL:[[NSBundle mainBundle]URLForResource:@"embedded" withExtension:@"mobileprovision"]]; | |
NSString *str=[[NSString alloc]initWithData:data encoding:NSISOLatin1StringEncoding]; | |
NSRange rangeOfDevicesUDIDs = [str rangeOfString:@"ProvisionedDevices"]; | |
isAdHoc = rangeOfDevicesUDIDs.location!=NSNotFound && !isDebug; | |
return isAdHoc; | |
} | |
//Ref | |
//http://stackoverflow.com/questions/23161261/detecting-if-app-is-ad-hoc?rq=1 | |
//http://stackoverflow.com/questions/3426467/how-to-determine-at-run-time-if-app-is-for-development-app-store-or-ad-hoc-dist | |
//https://gist.github.com/steipete/7668246 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment