From fe59acd7d99f58a437f900e9cb0d4fcf6b20330b Mon Sep 17 00:00:00 2001 From: Gianfranco Berardi Date: Wed, 2 Jun 2021 22:20:56 -0500 Subject: [PATCH 1/2] WIP: Create an XCFramework for SDL libraries This does not quite work. At the very least building the static library with the argument "Static Library-iOS" does work, but it would take more changes to merge all of the appropriate simulator vs device libraries combined. But I'm hoping that this is a good start if there is an interest in getting the XCFramework for SDL to build. --- build.sh | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/build.sh b/build.sh index fb6f0d1..ba873a6 100644 --- a/build.sh +++ b/build.sh @@ -298,7 +298,7 @@ mkdir -p $ios_dir/lib mkdir -p $tvos_dir/lib build_ios_tvos_lib() { - target=$1 + scheme=$1 fname=$2 env1=$3 env2=$4 @@ -306,35 +306,30 @@ build_ios_tvos_lib() { # Ignore empty environment variable args, replace with dummy var if [[ $env1 == '' ]]; then env1="A="; fi if [[ $env2 == '' ]]; then env2="A="; fi + + SIMULATOR_PATH="build/${fname}-iphonesimulator" + DEVICE_PATH="build/${fname}-iphoneos" task "Building $fname for iPhone..." - xcodebuild -target "$target" -configuration Release -sdk iphoneos "$env1" "$env2" | $XCPRETTY + buildDir="BUILD_DIR=$DEVICE_PATH" + xcodebuild -scheme "$scheme" -configuration Release -sdk iphoneos SKIP_INSTALL=NO "$env1" "$env2" "$buildDir" | $XCPRETTY task "Building $fname for iPhone Simulator..." - xcodebuild -target "$target" -configuration Release -sdk iphonesimulator "$env1" "$env2" | $XCPRETTY + buildDir="BUILD_DIR=$SIMULATOR_PATH" - task "Building $fname for Apple TV..." - xcodebuild -target "$target" -configuration Release -sdk appletvos "$env1" "$env2" | $XCPRETTY + xcodebuild -scheme "$scheme" -configuration Release -sdk iphonesimulator SKIP_INSTALL=no "$env1" "$env2" "$buildDir" | $XCPRETTY - task "Building $fname for Apple TV Simulator..." - xcodebuild -target "$target" -configuration Release -sdk appletvsimulator "$env1" "$env2" | $XCPRETTY - - task "Building $fname universal libs..." - - mkdir -p build/Release-ios-universal - lipo build/Release-iphoneos/$fname.a build/Release-iphonesimulator/$fname.a -create -output build/Release-ios-universal/$fname.a - - mkdir -p build/Release-tvos-universal - lipo build/Release-appletvos/$fname.a build/Release-appletvsimulator/$fname.a -create -output build/Release-tvos-universal/$fname.a + task "Combining all frameworks..." + xcodebuild -create-xcframework -framework ${SIMULATOR_PATH}/Products/Library/Frameworks/${fname}.framework -framework ${DEVICE_PATH}/Products/Library/Frameworks/${fname}.framework -output ${OUTPUT_DIR}/${fname}.xcframework } # Build SDL2 task "Building SDL2 iOS and tvOS static libs..." -cd SDL/Xcode-iOS/SDL +cd SDL/Xcode/SDL -build_ios_tvos_lib libSDL-iOS libSDL2 +build_ios_tvos_lib "Static Library-iOS" libSDL2 cp build/Release-ios-universal/libSDL2.a $ios_dir/lib cp build/Release-tvos-universal/libSDL2.a $tvos_dir/lib From b8c25f8efbec59d5a445886469788c890f96ac54 Mon Sep 17 00:00:00 2001 From: Gianfranco Berardi Date: Thu, 3 Jun 2021 15:33:44 -0500 Subject: [PATCH 2/2] Accidentally submitted the wrong changes These changes create frameworks, then merge the frameworks together into an XCFramework. --- build.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index ba873a6..c2e328c 100644 --- a/build.sh +++ b/build.sh @@ -306,21 +306,21 @@ build_ios_tvos_lib() { # Ignore empty environment variable args, replace with dummy var if [[ $env1 == '' ]]; then env1="A="; fi if [[ $env2 == '' ]]; then env2="A="; fi - - SIMULATOR_PATH="build/${fname}-iphonesimulator" - DEVICE_PATH="build/${fname}-iphoneos" - task "Building $fname for iPhone..." - buildDir="BUILD_DIR=$DEVICE_PATH" - xcodebuild -scheme "$scheme" -configuration Release -sdk iphoneos SKIP_INSTALL=NO "$env1" "$env2" "$buildDir" | $XCPRETTY + SIMULATOR_ARCHIVE_PATH="build/${fname}-iphonesimulator.xcarchive" + DEVICE_ARCHIVE_PATH="build/${fname}-iphoneos.xcarchive" + task "Building $fname for iPhone Simulator..." - buildDir="BUILD_DIR=$SIMULATOR_PATH" + env1="BUILD_DIR=$SIMULATOR_ARCHIVE_PATH" + xcodebuild archive -scheme "${scheme}" -archivePath ${SIMULATOR_ARCHIVE_PATH} -configuration Release -sdk iphonesimulator SKIP_INSTALL=NO "$env1" - xcodebuild -scheme "$scheme" -configuration Release -sdk iphonesimulator SKIP_INSTALL=no "$env1" "$env2" "$buildDir" | $XCPRETTY + task "Building $fname for iPhone..." + env1="BUILD_DIR=$DEVICE_ARCHIVE_PATH" + xcodebuild archive -scheme "${scheme}" -archivePath ${DEVICE_ARCHIVE_PATH} -configuration Release -sdk iphoneos SKIP_INSTALL=NO "$env1" task "Combining all frameworks..." - xcodebuild -create-xcframework -framework ${SIMULATOR_PATH}/Products/Library/Frameworks/${fname}.framework -framework ${DEVICE_PATH}/Products/Library/Frameworks/${fname}.framework -output ${OUTPUT_DIR}/${fname}.xcframework + xcodebuild -create-xcframework -framework ${SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${fname}.framework -framework ${DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${fname}.framework -output ${OUTPUT_DIR}/${fname}.xcframework } # Build SDL2