Question

I have this URL in my server that is used for testing and another one that is used for production.

At some point in my code I did this:

#ifdef DEBUG
  static NSString * const url = "http://sandbox.myserver.com";
#else
  static NSString * const url = "http://live.myserver.com";
#endif

this works fine when I am debugging the app on Xcode but if I send ad hoc versions of my app to beta testers it will fail. Ad hoc apps will use the production URL instead of the sandbox one.

What is the correct way of doing this test?

Was it helpful?

Solution

in short:

var data = String($.NSString.stringWithContentsOfFileEncodingError($.NSBundle.mainBundle.pathForResourceOfType('embedded', 'mobileprovision'), $.NSISOLatin1StringEncoding, null));
data = data.slice(data.indexOf('<plist'));
data = data.slice(0, data.indexOf('</plist>')+8);
data = $.NSString.stringWithString(data).dataUsingEncoding($.NSISOLatin1StringEncoding);
var mobileProvision = $.NSPropertyListSerialization.propertyListWithDataOptionsFormatError(data, $.NSPropertyListImmutable, null, null);
if (mobileProvision.valueForKey('ProvisionedDevices')) {
    res.debug = 'adhoc';
} else {
    res.debug = false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top