Skip to content

Commit

Permalink
feat: distribute precompiled framework
Browse files Browse the repository at this point in the history
  • Loading branch information
crleona committed Oct 25, 2024
1 parent ee91cc5 commit 0e883e2
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ jobs:
- name: Validate Podfile
run: pod lib lint --allow-warnings

- name: Build xcframework
run: scripts/build_framework.sh

- name: Zip xcframework
run: zip -r .build/artifacts/AnalyticsConnector.xcframework.zip .build/artifacts/AnalyticsConnector.xcframework

- name: Semantic Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
env:
Expand Down
7 changes: 6 additions & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ module.exports = {
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/github",
[
"@semantic-release/github", {
"assets": [
{ "path": ".build/artifacts/AnalyticsConnector.xcframework.zip" },
]
}],
[
"@google/semantic-release-replace-plugin",
{
Expand Down
56 changes: 56 additions & 0 deletions scripts/build_framework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -e

SCHEME="AnalyticsConnector"
FRAMEWORK="AnalyticsConnector"
BUILD_DIR="./.build/artifacts"
OUTPUT_PATH="$BUILD_DIR/$FRAMEWORK.xcframework"
PLATFORMS=("macOS" "iOS" "iOS Simulator" "tvOS" "tvOS Simulator" "watchOS" "watchOS Simulator")

build_framework_with_configuration_and_name() {
CONFIGURATION=${1}
# Create a framework for each supported sdk
declare -a ARCHIVES
for PLATFORM in "${PLATFORMS[@]}"
do
ARCHIVE="$BUILD_DIR/$CONFIGURATION/$FRAMEWORK-$PLATFORM.xcarchive"
if [[ "$DESTINATION" == "macOS Cataylst" ]]; then
xcodebuild archive \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-archivePath "$ARCHIVE" \
-destination "generic/platform=macOS,variant=Mac Catalyst" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

else
xcodebuild archive \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-archivePath "$ARCHIVE" \
-destination "generic/platform=$PLATFORM" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
fi
ARCHIVES+=("$ARCHIVE")
done

# then bundle them into an xcframework
CREATE_XCFRAMEWORK="xcodebuild -create-xcframework -output '$OUTPUT_PATH'"
for ARCHIVE in "${ARCHIVES[@]}"
do
CREATE_XCFRAMEWORK="$CREATE_XCFRAMEWORK -archive '$ARCHIVE' -framework '$FRAMEWORK.framework'"
done
eval "$CREATE_XCFRAMEWORK"

# Fixup - Resolve module/class name conflicts
for SWIFT_INTERFACE in $(find "$OUTPUT_PATH" -name "*.private.swiftinterface")
do
sed -i "" "s/AnalyticsConnector\.//" "$SWIFT_INTERFACE"
done
}

rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
build_framework_with_configuration_and_name "Release" "AnalyticsConnector"

0 comments on commit 0e883e2

Please sign in to comment.