Domanda

I never remember to change anything when I'm going to production so I just use this method (https://developer.apple.com/library/mac/qa/qa1361/_index.html) provided by apple to detect if I'm debugging or in production so all of my changes are made for me (switch to real ads, use the production url etc.)

I have the following plist for Urban Airship

AirshipConfig.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>analyticsEnabled</key>
    <false/>
    <key>inProduction</key>
    <false/>
    <key>developmentAppKey</key>
    <string>SOMESTRINGHERE</string>
    <key>developmentAppSecret</key>
    <string>SOMESTRINGHERE</string>
    <key>productionAppKey</key>
    <string>SOMESTRINGHERE</string>
    <key>productionAppSecret</key>
    <string>SOMESTRINGHERE</string>
</dict>
</plist>

Now for Urban Airship I have to change inProduction to true when I release to the app store and false when I'm debugging

So in my app delegate I'm trying to change the plist with the following if. I'm still trying to get the contents of the plist to see that it's working but I keep getting (null) as my NSLog

if([Def AmIBeingDebugged]){
    //Development set to false
    NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"AirshipConfig" ofType:@"plist"];
    NSLog(@"%@", [NSArray arrayWithContentsOfFile:plistPath]);
}else{
    //Production set to true
}

Any help on setting the correct plist value would be greatly appreciated as I've hit a wall and can't figure out why it's always (null) as I'd think I'd need the contents so I could rewrite the file.

È stato utile?

Soluzione

First create separate copies of AirshipConfig.plist for all of your Xcode build configurations, and name them in the format AirshipConfig_$(CONFIGURATION).plist (so e.g. AirshipConfig_Debug.plist and AirshipConfig_Release.plist). Then update their contents to whatever you want (e.g. set inProduction to appropriate values.)

Then create a new "Run Script" Build Phase for your application target in Xcode, and give it the name "Copy Urban Airship config file to bundle". Add this as the contents of the script:

cp "${SRCROOT}/MyProjectName/AirshipConfig_${CONFIGURATION}.plist" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AirshipConfig.plist"

This will copy the config file for the correct build configuration into your app bundle, with the filename that the external library expects (AirshipConfig.plist). Just ensure that the source path for the config files is correct in the above example.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top