Skip to content

Commit

Permalink
Major refactor of Support scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
surpher committed Dec 9, 2024
1 parent 84b4547 commit 97402cc
Show file tree
Hide file tree
Showing 11 changed files with 475 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ LIBPACT_FFI_DIR="${WORKSPACE}/pact-reference/rust/pact_ffi"
LIBPACT_FFI_VERSION=$(awk 'NR==1 {print; exit}' libpact_ffi.version)

# "import"
source "$SOURCE_DIR/utils.sh"
source "$SOURCE_DIR/configure_rust_tools"
source "$SOURCE_DIR/../utils.sh"
source "$SOURCE_DIR/../Config/configure_rust_tools.sh"

#######################
# Pre-requisite #
Expand Down
78 changes: 37 additions & 41 deletions Support/Scripts/CI/build_xcframework
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091

# PactSwiftMockService
#
Expand Down Expand Up @@ -26,8 +27,11 @@ set -o pipefail
IPHONEOS_DEPLOYMENT_TARGET=16.0
MACOSX_DEPLOYMENT_TARGET=13.0

TMP_DIR="../../.tmp/build-xcframework"
BUILD_XCFRAMEWORK_SOURCE_DIR="${BASH_SOURCE[0]%/*}"

TMP_DIR="${BUILD_XCFRAMEWORK_SOURCE_DIR}/../../../.tmp/build-xcframework"
PRODUCT_NAME="PactSwiftMockServer"
source "${BUILD_XCFRAMEWORK_SOURCE_DIR}/../utils.sh"

# Only use xcbeautify if it can be found in path.
XCBEAUTIFY=$(command -v xcbeautify || command -v cat)
Expand All @@ -40,78 +44,70 @@ XCBEAUTIFY=$(command -v xcbeautify || command -v cat)
# Otherwise a _concurrency fatal issue will be raised if PactSwiftMockSerer is
# used in a project built with Xcode 12.x

echo "⚠️ Checking for the right Xcode tools..."
xcode-select -p && xcode-select -v

echo "🚨 Are you running this using Xcode 16.x tools!?"
select yn in "Yes" "No"; do
case $yn in
Yes) break;;
No) exit 1;;
esac
done
check_xcode

# Setup

echo "ℹ️ Looking for ${PRODUCT_NAME}.xcodeproj"
if [ ! -d "${PRODUCT_NAME}.xcodeproj" ]; then
echo "🚨 Run this in the same folder as \"${PRODUCT_NAME}.xcodeproj\"."
echo "ℹ️ Looking for $PRODUCT_NAME.xcodeproj"
if [ ! -d "$PRODUCT_NAME.xcodeproj" ]; then
echo "🚨 Run this in the same folder as \"$PRODUCT_NAME.xcodeproj\"!"
echo "Your current location is: $(pwd)"
exit 1
fi

echo "ℹ️ Removing existing XCFramework"
rm -fr "./${PRODUCT_NAME}.xcframework"
echo "👍 Removed existing XCFramework"
echo "ℹ️ Removing deprecated XCFramework..."
rm -fr "./$PRODUCT_NAME.xcframework"
echo "👍 Removed deprecated XCFramework"

echo "ℹ️ Preparing ${TMP_DIR} folder"
mkdir -p $TMP_DIR
rm -fr $TMP_DIR
echo "ℹ️ Setting up $TMP_DIR folder"
rm -fr "$TMP_DIR"
mkdir -p "$TMP_DIR"

# iOS

echo "🏗 Building for iOS..."
xcodebuild archive \
-sdk iphoneos IPHONEOS_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET} \
-sdk iphoneos IPHONEOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-arch arm64 \
-scheme "${PRODUCT_NAME}-iphoneos" \
-archivePath "${TMP_DIR}/iphoneos/${PRODUCT_NAME}.xcarchive" \
-scheme "$PRODUCT_NAME-iphoneos" \
-archivePath "$TMP_DIR/iphoneos/$PRODUCT_NAME.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO | ${XCBEAUTIFY}

echo "👍 Framework for arm64 device built"
SKIP_INSTALL=NO | $XCBEAUTIFY
echo "👍 Framework for physical arm64 device built"

echo "🏗 Building for iOS Simulator..."
xcodebuild archive \
-sdk iphonesimulator IPHONEOS_DEPLOYMENT_TARGET=${IPHONEOS_DEPLOYMENT_TARGET} \
-arch x86_64 -arch arm64 \
-scheme "${PRODUCT_NAME}-iOS" \
-archivePath "${TMP_DIR}/iphonesimulator/${PRODUCT_NAME}.xcarchive" \
-sdk iphonesimulator IPHONEOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET \
-arch x86_64 \
-arch arm64 \
-scheme "$PRODUCT_NAME-iOS" \
-archivePath "$TMP_DIR/iphonesimulator/$PRODUCT_NAME.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO | ${XCBEAUTIFY}
SKIP_INSTALL=NO | $XCBEAUTIFY
echo "👍 Framework for iOS Simulator built for x86_64 and arm64 architecture"

# macOS

echo "🏗 Building for macOS..."
xcodebuild archive \
-sdk macosx MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
-arch x86_64 -arch arm64 \
-scheme "${PRODUCT_NAME}-macOS" \
-archivePath "${TMP_DIR}/macos/${PRODUCT_NAME}.xcarchive" \
-sdk macosx MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET \
-arch x86_64 \
-arch arm64 \
-scheme "$PRODUCT_NAME-macOS" \
-archivePath "$TMP_DIR/macos/$PRODUCT_NAME.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO | ${XCBEAUTIFY}
SKIP_INSTALL=NO | $XCBEAUTIFY
echo "👍 Framework for macOS built for x86_64 and arm64 architectures"

# XCFramework

echo "🏗 Building XCFramework..."
xcodebuild -create-xcframework -output ./$PRODUCT_NAME.xcframework \
-framework $TMP_DIR/iphoneos/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/$PRODUCT_NAME.framework \
-framework $TMP_DIR/iphonesimulator/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/$PRODUCT_NAME.framework \
-framework $TMP_DIR/macos/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/$PRODUCT_NAME.framework
-framework "$TMP_DIR"/iphoneos/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/"$PRODUCT_NAME".framework \
-framework "$TMP_DIR"/iphonesimulator/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/"$PRODUCT_NAME".framework \
-framework "$TMP_DIR"/macos/$PRODUCT_NAME.xcarchive/Products/Library/Frameworks/"$PRODUCT_NAME".framework

# Cleanup
echo "ℹ️ Removing $TMP_DIR folder..."
rm -fr $TMP_DIR
rm -fr "$TMP_DIR"

echo "🎉 Done!"
76 changes: 0 additions & 76 deletions Support/Scripts/CI/bump_version_number

This file was deleted.

Loading

0 comments on commit 97402cc

Please sign in to comment.