Skip to content

Instantly share code, notes, and snippets.

@iShawnWang iShawnWang/LOL
Last active Oct 14, 2016

Embed
What would you like to do?
Detect Ad Hoc Build Configuration in code at runtime
//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
You can’t perform that action at this time.