Script to be called as part of an Xcode Run Script build phase. This will ensure that script Input File is copied (and code signed) to script Output File.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script embeds (and codesigns) a framework within an iOS app binary, but only when the configuration is Debug. | |
# It must be called from, or copied into an Xcode Run Script build phase with following setup: | |
# Input Files: | |
# - Path to framework within project folder (source path) | |
# - For example: $(SRCROOT)/ThirdPartyFrameworks/SimulatorStatusMagiciOS.framework | |
# Output Files: | |
# - Desired path to framework within ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH} (destination path) | |
# - For example: ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/SimulatorStatusMagiciOS.framework | |
# | |
# For explanation of Input & Output Files, check out: https://indiestack.com/2014/12/speeding-up-custom-script-phases/ | |
# This script adapted from: https://stackoverflow.com/a/40484337/9051514 (thanks Ricardo Duarte!) | |
if [[ -z ${SCRIPT_INPUT_FILE_0} || -z ${SCRIPT_OUTPUT_FILE_0} ]]; then | |
echo "This Xcode Run Script build phase must be configured with Input & Output Files" | |
exit 1 | |
fi | |
echo "Embed ${SCRIPT_INPUT_FILE_0}" | |
if [[ $CONFIGURATION == 'Debug' ]]; then | |
FRAMEWORK_SOURCE=${SCRIPT_INPUT_FILE_0} | |
FRAMEWORK_DESTINATION=${SCRIPT_OUTPUT_FILE_0} | |
DESTINATION_FOLDER=`dirname ${FRAMEWORK_DESTINATION}` | |
mkdir -p ${DESTINATION_FOLDER} | |
cp -Rv ${FRAMEWORK_SOURCE} ${FRAMEWORK_DESTINATION} | |
CODE_SIGN_IDENTITY_FOR_ITEMS="${EXPANDED_CODE_SIGN_IDENTITY_NAME}" | |
if [ "${CODE_SIGN_IDENTITY_FOR_ITEMS}" = "" ] ; then | |
CODE_SIGN_IDENTITY_FOR_ITEMS="${CODE_SIGN_IDENTITY}" | |
fi | |
BINARY_NAME=`basename ${FRAMEWORK_DESTINATION} .framework` | |
codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" ${FRAMEWORK_DESTINATION}/${BINARY_NAME} | |
echo " ✅ Embedded successfully" | |
else | |
echo " ❌ Non Debug build detected - do not embed" | |
fi |
I tried this too - not working for me on ios app
https://raw.githubusercontent.com/CocoaDebug/CocoaDebug/master/CocoaDebug/copy_and_codesign.sh
maybe try targeting ${CODESIGNING_FOLDER_PATH}
app_frameworks_dir="${CODESIGNING_FOLDER_PATH}/Frameworks"
If it doesn't work for you maybe you need to check your output path.
Check if you need to use CONFIGURATION_BUILD_DIR
. For example my "Output Files" was: ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MyFancyFramework.framework
How would this work for xcframeworks since those are split under different architectures?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working on XCode 10, needs to be updated (NVM) I ran the wrong target