Skip to content

Commit

Permalink
Merge pull request #5 from amplitude/precompiled_framework
Browse files Browse the repository at this point in the history
feat: distribute precompiled framework
  • Loading branch information
crleona authored Oct 29, 2024
2 parents ee91cc5 + 9bc2082 commit e67d034
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set Xcode 13.4
- name: Set Xcode 14.3.1
run: |
sudo xcode-select -switch /Applications/Xcode_13.4.app
sudo xcode-select -switch /Applications/Xcode_14.3.1.app
- name: iOS Build
run: |
Expand Down 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
2 changes: 1 addition & 1 deletion .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
pr-title-check:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: PR title is valid
if: >
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set Xcode 13.4
- name: Set Xcode 14.3.1
run: |
sudo xcode-select -switch /Applications/Xcode_13.4.app
sudo xcode-select -switch /Applications/Xcode_14.3.1.app
- name: iOS Build
run: |
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
45 changes: 45 additions & 0 deletions scripts/build_framework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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"
xcodebuild archive \
-scheme "$SCHEME" \
-configuration "$CONFIGURATION" \
-archivePath "$ARCHIVE" \
-destination "generic/platform=$PLATFORM" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
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 e67d034

Please sign in to comment.