1

Here's an entry in my config file...

enter image description here

This gets picked up correctly in build settings...

enter image description here

I've referenced the setting in both Info.plist files for the project...

enter image description here

But upon execution of the test target, the value isn't there...

enter image description here

Any ideas?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
  • The first thing I would check is that the build setting belongs to the same target as the .plist file. It looks like the target you have selected in the build settings is named, "Resolved". It looks to be a testing target, so it might not be the target you are expecting. Testing targets have their own, separate .plist file. – Albert Bori Oct 19 '15 at 22:27
  • "Resolved" means the build setting values used when taking into consideration the different places that values can be specified. e.g. Project, target, settings file. I've added the setting to both of the .plist files - so I don't think it can be that. – Ian Warburton Oct 19 '15 at 22:32
  • Have you added the `WebServiceUrl` to all target's build settings, or just the "Resolved" target? – Albert Bori Oct 19 '15 at 22:35
  • "Resolved" isn't a target. All targets (plus the project) have a "Resolved" column in the build settings when you switch on "Levels" instead of "Combined". Oddly, my project's target doesn't have a value in resolved even though the value appears in the config file column. The test project does have a value in resolved though, and that's the target I'm running. I've updated the question with screen shots. – Ian Warburton Oct 19 '15 at 22:47
  • Actually I've fixed the main target by pressing the delete key on the setting row. ;) – Ian Warburton Oct 19 '15 at 22:49
  • I see now, I was comparing it to the "Combined" build settings view. Your expanded screenshot makes more sense. Not sure if it will fix this, but my user-defined settings show up in both the "Resolved" column and the column immediately to the right of it (the target's column). I have nothing in the Config.File column. – Albert Bori Oct 19 '15 at 22:54
  • I removed it from the config file and added it to the target column but same result. – Ian Warburton Oct 19 '15 at 22:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92783/discussion-between-albert-bori-and-ian-warburton). – Albert Bori Oct 19 '15 at 22:57

1 Answers1

1

The code was looking in the wrong bundle.

This answer gave me the solution...

https://stackoverflow.com/a/30687916/221683

This was the code I used instead...

let urlString = NSBundle(forClass: self.dynamicType).objectForInfoDictionaryKey("WebServiceUrl") as? String

I only needed the entry in the Info.plist for my test target which is where the above code was defined.

Additionally, I didn't need quotes around the value in the config file.

Community
  • 1
  • 1
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189