Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Environment Variables Not Present During Archive

Tags:

I have an iOS application that has a TestFlight build scheme. In this scheme I have setup an environment variable called TESTFLIGHT with a value of 1 set in the "Run" tab. Also, in the "Profile" tab of the build scheme it has the "Use the RUn action's arguments and variables" option checked, and I see the appropriate EV in the list.

This works just fine when running the app from Xcode, but when I make an archive and run the app on my device the Environment Variable TESTFLIGHT is not present. My question is there an option/scheme tab that I'm missing here?

The EV is set on the "Run" tab and is selected for the debug build configuration. Do I need to change this to release?

Thank you all!

like image 299
miken.mkndev Avatar asked Jan 08 '13 12:01

miken.mkndev


People also ask

How do I see Environment Variables in Xcode?

Choose Edit SchemeUnder 'Run' Configurations in the left pane, select 'Arguments' Tab. See 'Environment Variables' section. Enable / Disable specific key value pair from the 'Environment Variables' section. Whatever variables set above is for Run Configuration.

Do I need to build before archive Xcode?

Make sure your build is successfulBefore beginning to archive your build, you need to make sure that the build is successful not only for Debug, for also for Release.

How do I enable Environment Variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

What does archive in Xcode do?

It archives your Xcode project by running the xcodebuild archive command and exports the archive into an . ipa file with the xcodebuild -exportArchive command. This . ipa file can be shared and installed on test devices, or uploaded to App Store Connect.


1 Answers

Environments variable are set only if you run the app from Xcode. If you run the same app from the device directly by tapping the icon, they won't be set. They are not part of the app. As their name imply, they are part of the environment, that Xcode sets up specifically before running them. (If you were developing on the Mac, you could set them in a shell before launching an executable, but that is not possible on the iPhone.)

like image 130
Guillaume Avatar answered Oct 14 '22 15:10

Guillaume