Skip to content

Instantly share code, notes, and snippets.

@pixelknitter
Last active March 13, 2019 08:08
Show Gist options
  • Save pixelknitter/3894039 to your computer and use it in GitHub Desktop.
Save pixelknitter/3894039 to your computer and use it in GitHub Desktop.
dSYM Archiving Script
DSYM_ZIP_FPATH="/tmp/$DWARF_DSYM_FILE_NAME.zip"
# create dSYM .zip file
echo "Compressing .dSYM to ${DSYM_ZIP_FPATH} ..."
test -e "${DSYM_SRC}" && (echo "Creating zip of dSYM file" && /usr/bin/zip -r "${DSYM_ZIP_FPATH}" "${DSYM_SRC}" -dc
RELATIVE_DEST_PATH="${PROJECT_DIR}/dSYM/" # You can make this to be whatever path.
test ! -d ${RELATIVE_DEST_PATH} && mkdir -p "${RELATIVE_DEST_PATH}"
DEST_PATH="${RELATIVE_DEST_PATH}/${EXECUTABLE_NAME}.$(date +%Y%m%d%H%M%S).app.dSYM"
cp -rf "${DSYM_SRC}" "${DEST_PATH}"
# Default for release/adhoc builds
DSYM_SRC=${ARCHIVE_DSYMS_PATH}/${DWARF_DSYM_FILE_NAME}
#! /bin/sh
# Crittercism app info found in your App Settings page
#
# Created by Crittercism
# Updated 02-04-2013
CRITTERCISM_APP_ID=${APP_ID:-0}
API_KEY=${API_KEY:-0}
SIMULATOR=${SIMULATOR:-0}
SHOW_CONSOLE="YES"
LOG="/tmp/crittercism.log"
/bin/rm -f ${LOG} # Clean out the old log, comment this if you want logs for each build.
# Utility functions
echoLog() { echo ${1} >> "${LOG}"; }
exitWithMessageAndCode() {
echoLog "${1}"
exit "${2}"
}
echoLog "Starting dSYM archiving & upload to Crittercism"
echoLog ""
# Open the console
if [ "$SHOW_CONSOLE" = "YES" ]; then
/usr/bin/open -a /Applications/Utilities/Console.app $LOG
fi
# Check to make sure the necessary parameters are defined
if [ "$CRITTERCISM_APP_ID" -eq 0 ]; then
echoLog "Crittercism App ID not defined.";
exit -1;
fi
if [ "$API_KEY" -eq 0 ]; then
echoLog "Crittercism API Key not defined.";
exit -1;
fi
# Default for release/adhoc builds
DSYM_SRC=${ARCHIVE_DSYMS_PATH}/${DWARF_DSYM_FILE_NAME}
# Give an option if they want to capture debug builds or not.
if [ "$BUILD_STYLE" == "Debug" ]; then
SKIP_DEBUG=`osascript -e "tell application \"Xcode\"" -e "set noButton to \"Let em starve.\"" -e "set yesButton to \"Feed the Critter!\"" -e "set upload_dialog to display dialog \"Skip Debug build?\" buttons {noButton, yesButton} default button yesButton with icon 1" -e "set button to button returned of upload_dialog" -e "if button is equal to yesButton then" -e "return 1" -e "else" -e "return 0" -e "end if" -e "end tell"`
if [ $SKIP_DEBUG -eq 1 ]; then
echoLog "Skipping debug"
exit 0;
fi
fi
# Grab dSYM from the simulator location
if [ "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]; then
if [ $SIMULATOR -eq 0 ]; then
echoLog "Skipping simulator builds"
exit 0;
fi
DSYM_SRC=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
fi
#BUNDLE_VERSION_KEY="CFBundleVersion" # i.e. build number - ex: 792
#BUNDLE_SHORT_VERSION_KEY="CFBundleShortVersionString" # i.e. MAJOR.MINOR.MICRO version number - ex: 1.3.1
# TODO: Get Value from the Key for version strings.
# Display this builds information
#echoLog "For ${BUNDLE_SHORT_VERSION_VALUE} build number - ${BUNDLE_VERSION_VALUE}"
#echoLog ""
echoLog "CRITTERCISM_APP_ID - ${CRITTERCISM_APP_ID}"
echoLog ""
echoLog "CRITTERCISM_API_KEY - ${API_KEY}"
echoLog ""
echoLog "Time to feed the Critter!"
# This is around the area you'd want to add the dSYM archive to your project repository
RELATIVE_DEST_PATH="${PROJECT_DIR}/dSYM/" # You can make this to be whatever path.
test ! -d ${RELATIVE_DEST_PATH} && mkdir -p "${RELATIVE_DEST_PATH}"
DEST_PATH="${RELATIVE_DEST_PATH}/${EXECUTABLE_NAME}.$(date +%Y%m%d%H%M%S).app.dSYM"
echoLog "Copying ${DSYM_SRC} ... to ... ${DEST_PATH}"
cp -rf "${DSYM_SRC}" "${DEST_PATH}"
DSYM_ZIP_FPATH="/tmp/$DWARF_DSYM_FILE_NAME.zip"
# create dSYM .zip file
echoLog "Compressing .dSYM to ${DSYM_ZIP_FPATH} ..."
test -e "${DSYM_SRC}" && (echo "Creating zip of dSYM file" && /usr/bin/zip -r "${DSYM_ZIP_FPATH}" "${DSYM_SRC}" -dc >> "${LOG}") || exitWithMessageAndCode "Could not find dSYM file to zip at: ${DSYM_SRC}" 1
echoLog ""
echoLog "Done compressing"
CRITTERCISM_DSYM_UPLOAD_URL="https://api.crittercism.com/api_beta/dsym/${CRITTERCISM_APP_ID}"
# Upload dSYM to Crittercism
echoLog "Uploading dSYM to Crittercism..."
curl "${CRITTERCISM_DSYM_UPLOAD_URL}" \
-F dsym=@"${DSYM_ZIP_FPATH}" \
-F key="${API_KEY}" \
>> "${LOG}" 2>&1
echoLog ""
# Remove temp dSYM archive
echoLog "Cleaning up temporary dSYM archive..."
/bin/rm -f "/tmp/$DWARF_DSYM_FILE_NAME.zip"
echoLog "Archiving and upload to Crittercism complete."
# If errors occur, let us know!
if [ "$?" -ne 0 ]; then
echoLog "There were errors in the script!"
osascript -e "tell application \"Xcode\"" -e "display dialog \"There were errors uploading to Crittercism... Check ${LOG}\" buttons {\"OK\"} with icon stop" -e "end tell"
/usr/bin/open -a /Applications/Utilities/Console.app $LOG
exit 1
fi
curl "https://api.crittercism.com/api_beta/dsyms/<app_id>" -F key="<YOUR API_KEY>"
{"dsyms": [<uuid>, <uuid>, ...]}
CRITTERCISM_APP_ID=${APP_ID:-0}
API_KEY=${API_KEY:-0}
SIMULATOR=${SIMULATOR:-0}
# Grab dSYM from the simulator location
if [ "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]; then
if [ $SIMULATOR -eq 0 ]; then
echo "Skipping simulator builds"
exit 0;
fi
# Default location for simulator build dSYMs
DSYM_SRC=${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
fi
# Give an option if they want to capture debug builds or not.
if [ "$BUILD_STYLE" == "Debug" ]; then
SKIP_DEBUG=`osascript -e "tell application \"Xcode\"" -e "set noButton to \"Let em starve.\"" -e "set yesButton to \"Feed the Critter!\"" -e "set upload_dialog to display dialog \"Skip Debug build?\" buttons {noButton, yesButton} default button yesButton with icon 1" -e "set button to button returned of upload_dialog" -e "if button is equal to yesButton then" -e "return 1" -e "else" -e "return 0" -e "end if" -e "end tell"`
if [ $SKIP_DEBUG -eq 1 ]; then
echoLog "Skipping debug"
exit 0;
fi
fi
curl "https://api.crittercism.com/api_beta/dsym/<app_id>" -F dsym=@"<path/to/dsym.zip>" -F key="<YOUR API_KEY>"
CRITTERCISM_DSYM_UPLOAD_URL="https://api.crittercism.com/api_beta/dsym/${CRITTERCISM_APP_ID}"
# Upload dSYM to Crittercism
echo "Uploading dSYM to Crittercism..."
curl "${CRITTERCISM_DSYM_UPLOAD_URL}" \
-F dsym=@"${DSYM_ZIP_FPATH}" \
-F key="${API_KEY}"
@tanduynguyen
Copy link

It works so good on simulator. But when I debug on real device, it says error "Could not find dSYM file to zip at: /NTU.app.dSYM" Is there anything wrong?

@danyalaytekin
Copy link

Add the following if you're getting an Expect 100 error.

-H "Expect:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment