Xcode Run script Build Phase "run script only when installing" option - xcode

There is a "run script only when installing" option in Xcode Run script Build Phase, I am not able to find documentation on this. What does it do?

With Run script only when installing checked, the script only runs when do Product Archive.

In the Xcode Build System Guide (Xcode 3.2.x), it says:
Run script only when installing. Runs the script only during install builds, that is, when using the install option of xcodebuild or when the build settings Deployment Location (DEPLOYMENT_LOCATION) and Deployment Postprocessing (DEPLOYMENT_POSTPROCESSING) are on.

Related

Is it possible to run an Xcode Build Phase Script when running xcodebuild from the command line?

I have a build phase Run Script in my Xcode project that is required for ensuring the module bundle is up to date. The script runs when actions are executed through the Xcode GUI, and the Swift Package is able to build and run tests successfully. But when I try to run xcodebuild test from the command line for CI/CD, the tests fail because the Run Script did not get executed during the build process.
Is there a way to tell xcodebuild to use the Run Scripts from my Xcode project? Or is there a flag I can use to specify a script for it to run?
Judging by the radio silence, I'm guessing this isn't possible using an xcodebuild flag or changing any Xcode settings.
What I ended up doing as a workaround was splitting build and test commands and then running my script in between.
# build-for-test is used bcus normal build wont build the test bundle, which was important in my use case
xcodebuild build-for-test ...
bash path/to/run-script.sh
xcodebuild test ...
The xcodebuild test command will use the files compiled by the earlier build command, so it won't clean any changes made to the xcode build dir by the run script (which is what I was doing).

Teamcity cli step fails in continuous build while works manually

I have ported my project build from buildbot to teamcity and it now fails on a command line step where I call a shell script that:
1) launches the macdeployqt qt utility to codesign the built app and then
2) tries to notarize the app.
I always get a sigsegv during the launch of macdeployqt
Obviously launching the script manually on the same machine and folder works as expected.
The problem was on my side, a JetBrains support staff stated that command-line runner is just calling the script as it is and not modifying any environment. It turned out that the script was failing because there was a double / in a path.

Add Run Script Phase only for Debug Configuration XCode 3.2

I want a run a script post-build for an XCode 3.2 project, so I added a "Run Script" phase to my target. It works great, but I only want to run this script in the Debug configuration, does anyone know how to do this?
thx,
A
Take a look at this answer, it looks to do what you are looking for. Running script only for an 'Archive' build in Xcode 4

Run a bash script in Xcode only when "Build & Run"

Is there a way, in Xcode, to run a bash script in a build phase, only when I "Build & Run" and not in all other occasions?
Actually, what I would like to do, is to write a script to update the build number every time I build and run a new version on the device.
Xcode does not tell your script why it's building — that is, if it's going to run the app afterwards or not —; only that it is building. Also note that selecting 'Run' as opposed to 'Build & Run' does not run scripts in Run Script phases.
If you build in other occasions, you can pass build settings to xcodebuild (if building from the command line) or by selecting a different build configuration (if building from the Xcode application), which you can refer to in your build scripts as environment variables. For example:
if [ "$CONFIGURATION" == "Debug" ]; then
# increment build number
fi
(This script uses the CONFIGURATION built-in build setting, but you can create custom build settings if needed.)

How to run an xcode project from bash?

I have a build script calling xcodebuild. that works, but I want to also run the project from bash as well. Effectively I want to negate the need to click "Build and Run" button from the GUI. I'm looking at xcrun but it's not too obvious to me what to do
It sounds like you want to run the product of the build, not the project itself. If you want to do that, you just need to use the bash invocation for the product. If you're building a command-line program, then there will be an executable with the product's name in the project's built products directory after a succesful build. The project's built products directory depends on your preferences for Xcode and the project, but can be determined from the $BUILT_PRODUCTS_DIR environment variable within an Xcode build phase.
I do this for one of my projects in a shell script. It let's me remotely build over SSH.
xcodebuild clean
xcodebuild
cp -rp ~/Projects/VSM/Mac/iCar/build/Release/iCar.app ~/Desktop/
open ~/Desktop/iCar.app
I chose to copy the app to the Desktop on purpose but you wouldn't have to.
try open xcode

Resources