Skip to content

Commit

Permalink
Update build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
rudrankriyam authored Oct 10, 2024
1 parent 0308904 commit c12b529
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions .github/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd -P)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

PROJECT_BUILD_DIR="${PROJECT_BUILD_DIR:-"${PROJECT_ROOT}/build"}"
XCODEBUILD_BUILD_DIR="$PROJECT_BUILD_DIR/xcodebuild"
XCODEBUILD_DERIVED_DATA_PATH="$XCODEBUILD_BUILD_DIR/DerivedData"
XCODEBUILD_DERIVED_DATA_PATH="./DerivedData"

PACKAGE_NAME=$1
if [ -z "$PACKAGE_NAME" ]; then
Expand All @@ -26,24 +21,16 @@ build_framework() {
rm -rf "$XCODEBUILD_ARCHIVE_PATH"

xcodebuild archive \
-scheme $scheme \
-archivePath $XCODEBUILD_ARCHIVE_PATH \
-derivedDataPath "$XCODEBUILD_DERIVED_DATA_PATH" \
-scheme "$scheme" \
-archivePath "$XCODEBUILD_ARCHIVE_PATH" \
-sdk "$sdk" \
-destination "$destination" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
INSTALL_PATH='Library/Frameworks' \
OTHER_SWIFT_FLAGS=-no-verify-emitted-module-interface

FRAMEWORK_MODULES_PATH="$XCODEBUILD_ARCHIVE_PATH/Products/Library/Frameworks/$scheme.framework/Modules"
mkdir -p "$FRAMEWORK_MODULES_PATH"
cp -r \
"$XCODEBUILD_DERIVED_DATA_PATH/Build/Intermediates.noindex/ArchiveIntermediates/$scheme/BuildProductsPath/Release-$sdk/$scheme.swiftmodule" \
"$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule"
# Delete private swiftinterface
rm -f "$FRAMEWORK_MODULES_PATH/$scheme.swiftmodule/*.private.swiftinterface"
OTHER_SWIFT_FLAGS='-no-verify-emitted-module-interface'
}

# Remove the sed command if Package.swift is already correctly configured
sed -i '' '/Replace this/ s/.*/type: .dynamic,/' Package.swift

build_framework "iphonesimulator" "generic/platform=iOS Simulator" "$PACKAGE_NAME"
Expand All @@ -52,7 +39,10 @@ build_framework "iphoneos" "generic/platform=iOS" "$PACKAGE_NAME"
echo "Builds completed successfully."

rm -rf "$PACKAGE_NAME.xcframework"
xcodebuild -create-xcframework -framework $PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework -framework $PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework -output $PACKAGE_NAME.xcframework
xcodebuild -create-xcframework \
-framework "$PACKAGE_NAME-iphonesimulator.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework" \
-framework "$PACKAGE_NAME-iphoneos.xcarchive/Products/Library/Frameworks/$PACKAGE_NAME.framework" \
-output "$PACKAGE_NAME.xcframework"

cp -r $PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs $PACKAGE_NAME.xcframework/ios-arm64_x86_64-simulator
cp -r $PACKAGE_NAME-iphoneos.xcarchive/dSYMs $PACKAGE_NAME.xcframework/ios-arm64
cp -r "$PACKAGE_NAME-iphonesimulator.xcarchive/dSYMs" "$PACKAGE_NAME.xcframework/ios-arm64_x86_64-simulator"
cp -r "$PACKAGE_NAME-iphoneos.xcarchive/dSYMs" "$PACKAGE_NAME.xcframework/ios-arm64"

0 comments on commit c12b529

Please sign in to comment.