Can't access build setting
Asked Answered
V

1

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?

Vada answered 19/10, 2015 at 18:1 Comment(8)
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.Penitentiary
"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.Vada
Have you added the WebServiceUrl to all target's build settings, or just the "Resolved" target?Penitentiary
"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.Vada
Actually I've fixed the main target by pressing the delete key on the setting row. ;)Vada
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.Penitentiary
I removed it from the config file and added it to the target column but same result.Vada
Let us continue this discussion in chat.Penitentiary
V
1

The code was looking in the wrong bundle.

This answer gave me the solution...

https://mcmap.net/q/126327/-why-can-39-t-code-inside-unit-tests-find-bundle-resources

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.

Vada answered 22/10, 2015 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.