Skip to content

Commit 50a9ff7

Browse files
authored
feat: Add a new dynamic framework with arm64e (#5788)
* feat: Add a new dynamic framework with arm64e and remove it from the default * Fix typo * Remove empty space * Use same variant id * use override name for uploaded xcframework * Update changelog * Extract architecture removal into a new script * Add a script to build locally * Added changelog note * Fix redundant loop * Apply comments to changelog note * Remove duplicated changelog entry
1 parent 7cc23cf commit 50a9ff7

File tree

7 files changed

+149
-20
lines changed

7 files changed

+149
-20
lines changed

.github/workflows/assemble-xcframework-variant.yml

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Assemble XCFramework Variant
33
on:
44
workflow_call:
55
inputs:
6-
name:
6+
scheme:
77
description: |-
88
The Sentry project target to build an XCFramework slice for.
99
Possible values: Sentry, SentrySwiftUI.
@@ -51,9 +51,21 @@ on:
5151
required: false
5252
type: string
5353

54+
excluded-archs:
55+
description: |-
56+
The archs to exclude from the XCFramework.
57+
required: false
58+
type: string
59+
60+
override-name:
61+
description: |-
62+
The name to use for the XCFramework. If not provided, the default name will be used.
63+
required: false
64+
type: string
65+
5466
jobs:
5567
assemble-xcframework-variant:
56-
name: ${{inputs.name}}${{inputs.suffix}}
68+
name: ${{ inputs.override-name || format('{0}{1}', inputs.scheme, inputs.suffix) }}
5769

5870
runs-on: macos-14
5971
steps:
@@ -86,6 +98,15 @@ jobs:
8698
fi
8799
shell: sh
88100

101+
- name: Set XCFramework name
102+
id: set-xcframework-name
103+
run: |
104+
if [ -n "${{ inputs.override-name }}" ]; then
105+
echo "XCFRAMEWORK_NAME=${{ inputs.override-name }}" >> $GITHUB_ENV
106+
else
107+
echo "XCFRAMEWORK_NAME=${{ inputs.scheme }}${{inputs.suffix}}" >> $GITHUB_ENV
108+
fi
109+
89110
- name: Compute cache key
90111
run: |
91112
sdks_string=${{inputs.sdks}}
@@ -97,7 +118,7 @@ jobs:
97118
uses: actions/cache@v4
98119
with:
99120
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
100-
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip
121+
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
101122

102123
- name: Download ${{inputs.variant-id}} Slices
103124
if: steps.cache-xcframework.outputs.cache-hit != 'true'
@@ -112,26 +133,33 @@ jobs:
112133
find xcframework-slices -type f -print0 | xargs -t0I @ unzip @ -d xcframework-slices
113134
shell: bash
114135

136+
- name: Remove excluded archs
137+
if: ${{ steps.cache-xcframework.outputs.cache-hit != 'true' && inputs.excluded-archs != '' }}
138+
run: ./scripts/remove-architectures.sh xcframework-slices/ "${{ inputs.excluded-archs }}"
139+
shell: bash
140+
115141
- name: Assemble XCFramework
116142
if: steps.cache-xcframework.outputs.cache-hit != 'true'
117-
run: ./scripts/assemble-xcframework.sh "${{inputs.name}}" "${{inputs.suffix}}" "${{inputs.configuration-suffix}}" "${{inputs.sdks}}" "/Users/runner/work/sentry-cocoa/sentry-cocoa/xcframework-slices/SDK_NAME.xcarchive"
143+
run: ./scripts/assemble-xcframework.sh "${{inputs.scheme}}" "${{inputs.suffix}}" "${{inputs.configuration-suffix}}" "${{inputs.sdks}}" "/Users/runner/work/sentry-cocoa/sentry-cocoa/xcframework-slices/SDK_NAME.xcarchive"
118144
shell: bash
119145

120146
- name: Zip XCFramework
121147
if: steps.cache-xcframework.outputs.cache-hit != 'true'
122-
run: ./scripts/compress-xcframework.sh ${{inputs.signed && '--sign' || '--not-signed'}} ${{inputs.name}}${{inputs.suffix}}
148+
run: |
149+
./scripts/compress-xcframework.sh ${{inputs.signed && '--sign' || '--not-signed'}} ${{inputs.scheme}}${{inputs.suffix}}
150+
mv ${{inputs.scheme}}${{inputs.suffix}}.xcframework.zip ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
123151
shell: bash
124152

125153
- name: Cache XCFramework
126154
uses: actions/cache@v4
127155
with:
128156
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
129-
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip
157+
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
130158

131159
- name: Upload XCFramework
132160
uses: actions/upload-artifact@v4
133161
with:
134162
overwrite: true
135-
name: xcframework-${{github.sha}}-${{inputs.variant-id}}
163+
name: xcframework-${{github.sha}}-${{inputs.override-name || inputs.variant-id}}
136164
if-no-files-found: error
137-
path: ${{inputs.name}}${{inputs.suffix}}.xcframework.zip
165+
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip

.github/workflows/release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,34 @@ jobs:
7575
uses: ./.github/workflows/assemble-xcframework-variant.yml
7676
secrets: inherit
7777
with:
78-
name: ${{matrix.variant.name}}
78+
scheme: ${{matrix.variant.scheme}}
7979
suffix: ${{matrix.variant.suffix}}
8080
configuration-suffix: ${{matrix.variant.configuration-suffix}}
8181
variant-id: ${{matrix.variant.id}}
8282
signed: true
8383
release-version: ${{ github.event.inputs.version }}
84+
excluded-archs: ${{matrix.variant.excluded-archs}}
85+
override-name: ${{matrix.variant.override-name}}
8486
strategy:
8587
matrix:
8688
variant:
87-
- name: Sentry
89+
- scheme: Sentry
8890
macho-type: mh_dylib
8991
suffix: "-Dynamic"
9092
id: sentry-dynamic
91-
- name: Sentry
93+
excluded-archs: arm64e
94+
- scheme: Sentry
95+
macho-type: mh_dylib
96+
suffix: "-Dynamic"
97+
id: sentry-dynamic
98+
override-name: Sentry-Dynamic-WithARM64e
99+
- scheme: Sentry
92100
macho-type: staticlib
93101
id: sentry-static
94-
- name: SentrySwiftUI
102+
- scheme: SentrySwiftUI
95103
macho-type: mh_dylib
96104
id: sentry-swiftui
97-
- name: Sentry
105+
- scheme: Sentry
98106
macho-type: mh_dylib
99107
suffix: "-WithoutUIKitOrAppKit"
100108
configuration-suffix: WithoutUIKit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,6 @@ TestSamples/SwiftUICrashTest/SwiftUICrashTest.xcodeproj
100100

101101
Sentry.xcframework*
102102
Sentry-Dynamic.xcframework*
103+
Sentry-Dynamic-WithARM64e.xcframework*
103104
SentrySwiftUI.xcframework*
104105
Sentry-WithoutUIKitOrAppKit.xcframework*

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## Unreleased
44

5+
> [!Important]
6+
> Xcode 26 is not allowing individual frameworks to contain arm64e slices anymore if the main binary doesn't contain it.
7+
> We have decided to split the Dynamic variant of Sentry into two variants:
8+
>
9+
> - `Sentry-Dynamic`: Without arm64e
10+
> - `Sentry-Dynamic-WithARM64e`: _With_ ARM64e slice
11+
>
12+
> If your app does not need arm64e, you don't need to do any changes.
13+
> But if your app _needs arm64e_ please use `Sentry-Dynamic-WithARM64e` from 8.55.0 so you don't have issues uploading to the AppStore.
14+
15+
### Features
16+
17+
- Add a new prebuilt framework with arm64e and remove it from the regular one (#5788)
18+
519
### Fixes
620

721
- Add support for PDFKit views in session replay (#5750)

scripts/build-xcframework-local.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,31 @@ rm -rf Carthage/
1010
mkdir Carthage
1111

1212
if [ "$variants" = "DynamicOnly" ] || [ "$variants" = "AllVariants" ]; then
13-
./scripts/build-xcframework-variant.sh "Sentry" "-Dynamic" "mh_dylib" "" "$sdks"
13+
./scripts/build-xcframework-variant.sh "Sentry" "-Dynamic" "mh_dylib" "" "$sdks" "arm64e"
1414
./scripts/compress-xcframework.sh "$signed" Sentry-Dynamic
1515
mv Sentry-Dynamic.xcframework.zip Carthage/Sentry-Dynamic.xcframework.zip
1616
fi
1717

18+
if [ "$variants" = "DynamicWithARM64eOnly" ] || [ "$variants" = "AllVariants" ]; then
19+
./scripts/build-xcframework-variant.sh "Sentry" "-Dynamic-WithARM64e" "mh_dylib" "" "$sdks" ""
20+
./scripts/compress-xcframework.sh "$signed" Sentry-Dynamic-WithARM64e
21+
mv Sentry-Dynamic-WithARM64e.xcframework.zip Carthage/Sentry-Dynamic-WithARM64e.xcframework.zip
22+
fi
23+
1824
if [ "$variants" = "StaticOnly" ] || [ "$variants" = "AllVariants" ]; then
19-
./scripts/build-xcframework-variant.sh "Sentry" "" "staticlib" "" "$sdks"
25+
./scripts/build-xcframework-variant.sh "Sentry" "" "staticlib" "" "$sdks" ""
2026
./scripts/compress-xcframework.sh "$signed" Sentry
2127
mv Sentry.xcframework.zip Carthage/Sentry.xcframework.zip
2228
fi
2329

2430
if [ "$variants" = "SwiftUIOnly" ] || [ "$variants" = "AllVariants" ]; then
25-
./scripts/build-xcframework-variant.sh "SentrySwiftUI" "" "mh_dylib" "" "$sdks"
31+
./scripts/build-xcframework-variant.sh "SentrySwiftUI" "" "mh_dylib" "" "$sdks" ""
2632
./scripts/compress-xcframework.sh "$signed" SentrySwiftUI
2733
mv SentrySwiftUI.xcframework.zip Carthage/SentrySwiftUI.xcframework.zip
2834
fi
2935

3036
if [ "$variants" = "WithoutUIKitOnly" ] || [ "$variants" = "AllVariants" ]; then
31-
./scripts/build-xcframework-variant.sh "Sentry" "-WithoutUIKitOrAppKit" "mh_dylib" "WithoutUIKit" "$sdks"
37+
./scripts/build-xcframework-variant.sh "Sentry" "-WithoutUIKitOrAppKit" "mh_dylib" "WithoutUIKit" "$sdks" ""
3238
./scripts/compress-xcframework.sh "$signed" Sentry-WithoutUIKitOrAppKit
3339
mv Sentry-WithoutUIKitOrAppKit.xcframework.zip Carthage/Sentry-WithoutUIKitOrAppKit.xcframework.zip
3440
fi

scripts/build-xcframework-variant.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ suffix="${2:-}"
77
MACH_O_TYPE="${3-mh_dylib}"
88
configuration_suffix="${4-}"
99
sdks_to_build="${5:-}"
10+
excluded_archs="${6:-}"
1011

1112
if [ "$sdks_to_build" = "iOSOnly" ]; then
1213
sdks=( iphoneos iphonesimulator )
@@ -18,9 +19,13 @@ else
1819
sdks=( iphoneos iphonesimulator macosx maccatalyst appletvos appletvsimulator watchos watchsimulator xros xrsimulator )
1920
fi
2021

21-
for sdk in "${sdks[@]}"; do
22-
./scripts/build-xcframework-slice.sh "$sdk" "$scheme" "$suffix" "$MACH_O_TYPE" "$configuration_suffix"
23-
done
22+
for sdk in "${sdks[@]}"; do
23+
./scripts/build-xcframework-slice.sh "$sdk" "$scheme" "$suffix" "$MACH_O_TYPE" "$configuration_suffix"
24+
done
25+
26+
if [ -n "$excluded_archs" ]; then
27+
./scripts/remove-architectures.sh "$(pwd)/Carthage/archive/$scheme$suffix/" "$excluded_archs"
28+
fi
2429

2530
xcframework_sdks="$(IFS=,; echo "${sdks[*]}")"
2631
./scripts/assemble-xcframework.sh "$scheme" "$suffix" "$configuration_suffix" "$xcframework_sdks" "$(pwd)/Carthage/archive/$scheme$suffix/SDK_NAME.xcarchive"

scripts/remove-architectures.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# Script to remove specific architectures from framework binaries in XCFramework slices
4+
# Usage: ./scripts/remove-architectures.sh <xcarchive_path> <excluded_architectures>
5+
# Example: ./scripts/remove-architectures.sh xcframework-slices/iphoneos.xcarchive "arm64"
6+
7+
set -e
8+
9+
# Check if required arguments are provided
10+
if [ $# -ne 2 ]; then
11+
echo "Usage: $0 <xcarchive_path> <excluded_architectures>"
12+
echo "Example: $0 xcframework-slices/iphoneos.xcarchive \"arm64e\""
13+
exit 1
14+
fi
15+
16+
XCARCHIVE_PATH="$1"
17+
EXCLUDED_ARCH="$2"
18+
19+
# Validate that the xcarchive path exists
20+
if [ ! -d "$XCARCHIVE_PATH" ]; then
21+
echo "Error: XCArchive path does not exist: $XCARCHIVE_PATH"
22+
exit 1
23+
fi
24+
25+
# Check if excluded architectures are provided
26+
if [ -z "$EXCLUDED_ARCH" ]; then
27+
echo "Warning: No excluded architecture specified. Nothing to do."
28+
exit 0
29+
fi
30+
31+
echo "Removing architectures from frameworks in: $XCARCHIVE_PATH"
32+
echo "Excluded architectures: $EXCLUDED_ARCH"
33+
34+
# Find all framework directories and process their binaries
35+
find "$XCARCHIVE_PATH" -name "*.framework" -type d | while read -r framework_path; do
36+
binary_path="$framework_path/$(basename "$framework_path" .framework)"
37+
if [ -f "$binary_path" ]; then
38+
echo "Processing binary: $binary_path"
39+
40+
# Check what architectures are currently in the binary
41+
echo "Current architectures in binary:"
42+
lipo -info "$binary_path"
43+
44+
should_remove=""
45+
46+
# Check if the excluded architectures are actually present
47+
if lipo -info "$binary_path" | grep -q "$EXCLUDED_ARCH"; then
48+
echo "Architecture '$EXCLUDED_ARCH' found in binary, will remove it"
49+
should_remove=true
50+
else
51+
echo "Warning: Architecture '$EXCLUDED_ARCH' not found in binary, skipping removal"
52+
fi
53+
54+
# Only perform removal if there are architectures to remove
55+
if [ -n "$should_remove" ]; then
56+
echo "Removing architectures:$EXCLUDED_ARCH"
57+
temp_binary="${binary_path}.tmp"
58+
lipo -remove "$EXCLUDED_ARCH" "$binary_path" -output "$temp_binary"
59+
mv "$temp_binary" "$binary_path"
60+
echo "Updated binary: $binary_path"
61+
else
62+
echo "No architectures to remove for this binary"
63+
fi
64+
fi
65+
done
66+
67+
echo "Architecture removal completed successfully."

0 commit comments

Comments
 (0)