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

4

7

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?

Brucine answered 8/11, 2018 at 9:46 Comment(0)
P
14

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}
Phylloid answered 8/11, 2018 at 11:36 Comment(0)
S
5

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!

Speaker answered 21/6, 2019 at 20:51 Comment(1)
For anyone who is also needing this for sentry, I'd strongly suggest adding the following check to your sentry script so the run script will fail if the dSYM cannot be found: sentry-cli difutil check "$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Resources/DWARF/$TARGET_NAME"Speaker
P
2

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
Pennywise answered 14/2, 2019 at 10:7 Comment(1)
This worked for me also. Our project has had no changes to the dsym uploading for well over a year and it suddenly started breaking, so I am guessing we reached a certain size that means we need a sleep to allow the OS to copy stuff about in time.Woollen
L
0

Based on some answers I compiled the following:

${PODS_ROOT}/FirebaseCrashlytics/upload-symbols -gsp ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist -p ios ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}

What helped me along the way is testing each factor of this script:

upload-symbols:

test -e ${PODS_ROOT}/FirebaseCrashlytics/upload-symbols && echo "upload-symbols exists" || echo "upload-symbols not found"

GoogleService-Info.plist:

test -e ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist && echo "GoogleService exists" || echo "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist not found"

dSYM:

test -e ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME} && echo "DWARF_DSYM_FILE_NAME exists" || echo "DWARF_DSYM_FILE_NAME not found"

In my case, the plist file was incorrect.

Lisalisabet answered 2/4, 2021 at 17:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.