I'm working with an iOS project that produces a Framework directory at the root of the project when I execute Product -> Build For -> Running in Xcode. I need to be able to automate this process on the command line presumably using xcodebuild. However, I can't seem to determine the correct set of parameters to make this happen. Any insight into how to run this same scenario without the GUI? Do I have to look at using lipo?
This is the generic script I created. It creates a framework with combined device and simulator binaries.
#!/bin/bash
while getopts s:w: flag
do
case "${flag}" in
s) scheme=${OPTARG};;
w) workspace="-workspace ${OPTARG}.xcworkspace";;
esac
done
if [ -z "$scheme" ]
then
echo "$(basename $BASH_SOURCE) -- build XCFramework"
echo ""
echo "$(basename $BASH_SOURCE) -s scheme-name [ -w workspace0-name ]"
echo ""
echo "Run this script from the top-level directory of your framework."
echo "The build result will be here: archives/<scheme-name>.xcframework"
exit
fi
rm -rf archives/$scheme.xcframework
xcodebuild archive \
$workspace \
-scheme $scheme \
-destination "generic/platform=iOS Simulator" \
-archivePath "archives/$scheme-Simulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
$workspace \
-scheme $scheme \
-destination "generic/platform=iOS" \
-archivePath "archives/$scheme" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
cp -r archives/$scheme-Simulator.xcarchive/Products/Library/Frameworks/. archives/simulator
cp -r archives/$scheme.xcarchive/Products/Library/Frameworks/. archives/ios
function GetUUID() {
local arch=$1
local binary=$2
local dwarfdump_result=$(dwarfdump -u ${binary})
local regex="UUID: (.*) \((.*)\)"
if [[ $dwarfdump_result =~ $regex ]]; then
local result_uuid="${BASH_REMATCH[1]}"
local result_arch="${BASH_REMATCH[2]}"
if [ "$result_arch" == "$arch" ]; then
echo $result_uuid
fi
fi
}
BCSYMBOLMAP_UUID=$(GetUUID "arm64" "archives/$scheme.xcarchive/Products/Library/Frameworks/$scheme.framework/$scheme")
xcodebuild -create-xcframework \
-framework archives/ios/$scheme.framework \
-debug-symbols ${PWD}/archives/$scheme.xcarchive/dSYMs/$scheme.framework.dSYM \
-debug-symbols "${PWD}/archives/$scheme.xcarchive/BCSymbolMaps/${BCSYMBOLMAP_UUID}.bcsymbolmap" \
-framework archives/simulator/$scheme.framework \
-debug-symbols ${PWD}/archives/$scheme-Simulator.xcarchive/dSYMs/$scheme.framework.dSYM \
-output archives/$scheme.xcframework
cd archives
rm -rf $scheme-Simulator.xcarchive $scheme.xcarchive ios simulator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.