Where to set environment variables for app?
Asked Answered
I

1

32

I'm working with source code that is frozen and cannot be changed; but its ENV aware and expects changes through the ENV. The source code is being used in an Xcode 4/iOS project.

Xcode 3 allowed us to set environmental variables on the app in the Executable folder (see Figure 1 at iOS Debugging Magic). Xcode 4 appears to lack the 'executable info' that was present in Xcode 3.

I've looked through a number of similar questions on Stack Overflow, but no one has answered the questions. Answers usually degenerate to preprocessor macros. Confer: How to set environment variables in iPhone executable using XCode 4?, Conditional Environment Variables in Xcode, and Where to set environmental variables in ios?.

How does on set an app's environment variables in Xcode 4?

Initiative answered 30/6, 2013 at 17:36 Comment(0)
F
66

You can set environment variables via Xcode Schemes. To edit a scheme, select it in the top bar:

Editing a scheme in Xcode

Choose the Run mode and go to the Arguments tab, and there you go...

Setting environment variables in Xcode

By default, these settings are also used for the Test and Profile modes.

Fluttery answered 30/6, 2013 at 20:14 Comment(3)
Thank you. I can't believe it was so much trouble to find anyone else say this in my Google search results.Lashawn
Will those variable be accessible when archiving the app for deployment to Test Flight ???Bedew
No – they are passed to the app when you launch the app from the selected scheme in Xcode, but do not become part of the app.Fluttery

© 2022 - 2024 — McMap. All rights reserved.