Question: I'm new to Xcode.

I spent the last two days trying to figure out how to test my app on my iPhone which accesses a web service. On the simulator I can use a hard-coded 'localhost' variable, but I don't want to hardcode all the configuration settings.

I'm using Swift + Xcode 6 but I think this is the same process as Xcode 5.

I looked through lots of articles and I think I'm supposed to use .xcconfig, but it's very unclear.

For example, I created a `Environment.xcconfig` file. I populated it with 

```
API_BASE_URL = "http://localhost:4000/api/v1"

```

I then went into Project -> Info and set the Debug configuration file to `Environment`. 

I then tried to access the variable in code via `${API_BASE_URL}` but I get `Use of unresolved identifier 'API_BASE_URL'`. 

This is extremely frustrating. Any ideas?

Answer: 
1. Setup config hierarchy in case you have pods configs:
[![enter image description here](https://i.stack.imgur.com/9qk8u.jpg)](https://i.stack.imgur.com/9qk8u.jpg)

OR if you haven't any pods at all, the Configurations hierarchy gonna look like this:
[![enter image description here](https://i.stack.imgur.com/HXSAM.jpg)](https://i.stack.imgur.com/HXSAM.jpg)

2. Create all the key-value pairs for each config file (in this case there are 3 config files for dev/adhoc/appstore builds). Each config file has same set of keys:
[![enter image description here](https://i.stack.imgur.com/qJgqb.jpg)](https://i.stack.imgur.com/qJgqb.jpg)
3. Add each key to the generator:
[![enter image description here](https://i.stack.imgur.com/inQnJ.jpg)](https://i.stack.imgur.com/inQnJ.jpg)
4. Then just use the keys in your code :
[![enter image description here](https://i.stack.imgur.com/2Ft7M.jpg)](https://i.stack.imgur.com/2Ft7M.jpg)

**PS: the keys generated this way are also recognizable in .swift files (make sure you have a bridging header in your Swift project, even though you don't use obj-c sources and it will be empty).**

**UPDATE for Swift 2.2: doesn't work anymore** [Swift 2.2: GCC\_PREPROCESSOR\_DEFINITIONS constants no longer imported](https://stackoverflow.com/questions/36266789/swift-2-2-gcc-preprocessor-definitions-constants-no-longer-imported)
You don't want `.xcconfig`; that stores settings for Xcode. Instead, you want a property list (`.plist`) file. To do so, hit `command-N` to create a new file, then select `iOS > Resources > Property List`. Use the plist editor to add keys, values, and value types. Then load your properties by adding these lines somewhere in your app:

```
if let filePath = NSBundle.mainBundle().pathForResource("Latin Conjugations", ofType:"plist") {
    let plist = NSDictionary(contentsOfFile:filePath)
}

```

You can then access your properties via the plist dictionary like you would any other dictionary value. Note that it's not a Swift `Dictionary`, since that doesn't have a constructor that takes a file path to load.

**Updated 10/21/2015:** This answer is now Swift 2.0-compliant. `pathForResource()` now returns an Optional.