문제

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?

도움이 되었습니까?

해결책

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;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top