ios - Override NSUserDefault preferences at build time -


i able set app preferences @ build time in ios project. know can create different targets in xcode think amount of preferences might end of making end nightmarish amount of targets in project.

an easy example setting default integer default called 'amount'. 'amount' defined in plist file in app called 'preferences.plist'. load plist file , register defaults plist on nsuserdefaults.

nsurl *preferencesfile = [[nsbundle mainbundle] urlforresource:@"preferences" withextension:@"plist"];     nsdictionary *defaultpreferences = [nsdictionary dictionarywithcontentsofurl:defaultpreferencesfile];     [[nsuserdefaults standarduserdefaults]  registerdefaults:preferences]; 

i assume write script modify preferences.plist file before build, build it. think might become nightmare when need mod bunch of different preferences.

end game have jenkins build ipas. create multiple jenkins builds point same code based build app different preferences.

android has flavors, , ability set resource values. ios have similar can use build these different 'flavors' of apps?

i use jenkins build action inject appropriate variables plist before xcode build:

plutil -replace mybuildbranch -string ${branch} myproj/myproj-info.plist 

i read value @ runtime using like:

nsbundle * bundle = [nsbundle bundleforclass:[appdelegate class]]; nsstring * mybuildbranch = bundle.infodictionary[@"mybuildbranch"] 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -