Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Script Phase after dSYM is generated with Xcode 10 (on build)

In the New Features section, it states:

  • In the new build system, shell scripts can't rely on the state of build artifacts not listed in other build phases (for example, the Info.plist file or .dSYM files.) Add files the script build phase depends on as explicit input dependencies to the shell script build phase. (40852184)

In previous Xcode, the script was executed successfully but now it can execute when the dSYM file size is 0.

How can I have a Run Script Phase that will start only after the dSYM file is generated?
How can I create an "explicit input dependencies to the shell script build phase" as they requested?

like image 204
Maor Refaeli Avatar asked Nov 08 '18 09:11

Maor Refaeli


People also ask

How do I run a build phase script in Xcode?

Go to the Build Phases section of your project. (Click on the project, then on the main target, then on the “Build Phases” tab along the top.) Click the + at the top left to create a new build phase; choose “New Run Script Phase.” Xcode creates the script at the end of the list, naming it “Run Script.”

Where is build phase in Xcode?

To view the build phases for a target, select the target and navigate to the Build Phases tab, as shown in the following figure. To add a new build phase, click the Add button (+) and select an appropriate build phase from the pop-up menu. Xcode disables any menu options that aren't valid.

How do I check if a script is running in Xcode?

1 Select xcodeproj file of you project -> Select Target -> Select Build Phases -> Click on plus button (upper left corner) -> Select New Run Script Phase. 2If you want to run a script while it is being installed on the device then please check a little checkbox just below the script box.

What is a Run script phase?

The Run Script build phase provides a place to enter any input and output files for your script. Use input and output files to customize your script's behavior and to help the build system understand when to execute your script.


3 Answers

A similar question can be found here:

Build phase script is running before needed files are created in Xcode 10

You need to add the dSYM as an input file dependency of your run script phase: D

dSYM default location is ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}

You can test this using a short script and observing its output:

#!/bin/sh

if [ ! -d ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME} ]; then
    echo "Couldn't find dsym file"
    exit 1
fi

stat -x ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
like image 192
Roi Tal Avatar answered Nov 04 '22 05:11

Roi Tal


Roi Tai's answer is almost correct. Specifying only ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME} is just the dSYMs folder and not the dSYM file itself.

I actually fully resolved the issue without having to use sleep in my script. The Input File path needs to be the following:

${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}

I was experiencing this issue when attempting to upload dSYMs to Sentry in my Build Phases. When specifying this full file path, the script waits for the dSYM to be fully generated before executing - no sleep call needed!

like image 31
vastopa Avatar answered Nov 04 '22 05:11

vastopa


For me proposed solution didn't work. In my case I had to know when Info.plist file inside dSYM is generated. Though script started when file is there its size was zero and script failed.

What worked for me is 5s sleep as first line in my script:

sleep 5
like image 27
Anton Plebanovich Avatar answered Nov 04 '22 06:11

Anton Plebanovich