Jorgen Jorgen - 1 year ago 99
Swift Question

Several targets in Xcode

I'm starting a project where I will have several targets.
My question is how do I get an value from the right info.plist?

Say I have three plists...

Target1-info.plist / Target2-info.plist / Target3-info.plist

Is there any 'wildcard' that can be used when using...

if let path = NSBundle.mainBundle().pathForResource("*-info", ofType: "plist")

Answer Source

You can access the values of the plist directly by using NSBundle.mainBundle().objectForInfoDictionaryKey("SOME_KEY")
Just replace "SOME_KEY" with the key you want.

e.g: NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleDevelopmentRegion")

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download