I have a shell script that I would like to run at the end of my target's build phase. However, I would like this script to only run when I build with the release configuration. How can this be done? Thanks!
How can I limit a "Run Script" build phase to my release configuration?
Asked Answered
if [ "${CONFIGURATION}" = "Release" ]; then
echo Do something really release-like
fi
The script will run at the end of every configuration, but it won't do anything in this case unless the configuration is Release (assuming everything it does is contained within the test block).
I just discovered it does not work with multi-worded configuration names. It works with "Release" but does not with "Internal Beta". –
Titanothere
@Titanothere - that is just bash; if you have multi-word variable, you need to surround the variable in quotes. So ${CONFIGURATION} becomes "${CONFIGURATION}". I'll update the answer to include that. –
Hazel
So I tried this with a script that uploads to crittercism the dysm file. Something's not working and xcode gets stuck on the phase when I add the wrapper of the "if". Any ideas? if [ "${CONFIGURATION}" = "Hockey Distribution" ]; then APP_ID="xxxxxxxx" API_KEY="xxxxxxxxx" source ${SRCROOT}/GlideiPhone/Vendor/CrittercismSDK/dsym_upload.sh fi –
Shipworm
I have 'Debug', 'Release' (for Instruments), 'Ad Hoc' and 'App Store' configs (with different code signing), so I changed it for
if [ "${CONFIGURATION}" != "Debug" ]; then...
. –
Siffre For the if condition i want to use a #define TRUE/FALSE stored in the .pch file.. how would i reference it in the script code? –
Ecumenicism
@skyline75489 : Bash uses
=
and ==
interchangeably. –
Personnel Can this same thing be accomplished with pre-processor flags? –
Specimen
This snippet was not working. I needed to change the "==" if [ "${CONFIGURATION}" == "Release" ] –
Ruscio
if [ "${CONFIGURATION}" = "Debug" ]; then ... works for me in Xcode 14 –
Threesome
+1 #5913699 –
Permalloy
"Debug-installing on a real device (build & run from Xcode) does not count as "installing". The run script only runs when archiving (tested with Xcode 9)." #5913699 –
Permalloy
It won't work if you want to build your app in
Release
configuration without archiving it. The question was explicitly about Release
configuration. –
Cirro © 2022 - 2024 — McMap. All rights reserved.