Skip to content

Commit dc15932

Browse files
authored
Merge pull request #30 from saturdaymp/feature/update-to-xcframework
Build XCFramework instead of Fat32 binary
2 parents 6252391 + d7cec10 commit dc15932

3 files changed

Lines changed: 207 additions & 39 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,44 +46,16 @@ jobs:
4646
-resultBundlePath TestResults
4747
timeout-minutes: 10
4848

49-
# In XCode 12 it will build the simulator with a arm64 CPU. We don't want this as when
50-
# we try to combine the simulator with the device build using Lipo we will get an error
51-
# because both builds have the same CPU archecture.
52-
- name: Build iOS Simulator
53-
run: |
54-
xcodebuild -sdk iphonesimulator -project "Sample Project/CheckBox.xcodeproj" -derivedDataPath build -scheme BEMCheckBox -configuration Release EXCLUDED_ARCHS="arm64"
55-
echo "Listing: build/Build/Products/Release-iphonesimulator" && ls -la build/Build/Products/Release-iphonesimulator
56-
echo "Listing: build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework" && ls -la build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework
57-
lipo -info build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework/BEMCheckBox
58-
59-
- name: Build iOS Device
60-
run: |
61-
xcodebuild -sdk iphoneos -project "Sample Project/CheckBox.xcodeproj" -derivedDataPath build -scheme BEMCheckBox -configuration Release
62-
echo "Listing: build/Build/Products/Release-iphoneos" && ls -la build/Build/Products/Release-iphoneos
63-
echo "Listing: build/Build/Products/Release-iphoneos/BEMCheckBox.framework" && ls -la build/Build/Products/Release-iphoneos/BEMCheckBox.framework
64-
lipo -info build/Build/Products/Release-iphoneos/BEMCheckBox.framework/BEMCheckBox
65-
66-
- name: Combine Builds
67-
run: |
68-
cp -R build/Build/Products/Release-iphoneos/ Release-fat
69-
echo "Listing: Release-fat" && ls -la Release-fat
70-
echo "Listing: Release-fat/BEMCheckBox.framework/BEMCheckBox" && ls -la Release-fat/BEMCheckBox.framework/BEMCheckBox
71-
72-
- name: Build fat Binary
73-
run: |
74-
lipo -create -output Release-fat/BEMCheckBox.framework/BEMCheckBox build/Build/Products/Release-iphoneos/BEMCheckBox.framework/BEMCheckBox build/Build/Products/Release-iphonesimulator/BEMCheckBox.framework/BEMCheckbox
75-
lipo -info Release-fat/BEMCheckBox.framework/BEMCheckBox
76-
file Release-fat/BEMCheckBox.framework/BEMCheckBox
77-
echo "Listing: Release-fat" && ls -la Release-fat
78-
echo "Listing: Release-fat/BEMCheckBox.framework" && ls -la Release-fat/BEMCheckBox.framework
49+
- name: Build XCFramework
50+
run: ./Scripts/build-xcframework.sh
7951

80-
# Upload the directory, not a zip file, as uploading an artificate will automatically zip it
52+
# Upload the directory, not a zip file, as uploading an artifact will automatically zip it
8153
# and we don't want a zip in a zip.
82-
- name: Upload Build Artificates to GitHub Workflow
54+
- name: Upload Build Artifacts to GitHub Workflow
8355
uses: actions/upload-artifact@v4
8456
with:
85-
name: BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.framework
86-
path: Release-fat/BEMCheckBox.framework
57+
name: BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.xcframework
58+
path: Temp/Release-fat/BEMCheckBox.xcframework
8759

8860
# Required to add the binary to the GitHub release.
8961
- name: Install GitReleaseManager
@@ -95,10 +67,10 @@ jobs:
9567
# Only update to the release on a tag push. Assume the release exists by the
9668
# time we create the tag. Also we need to create the zip as uploading to the release
9769
# does not automatically zip the file.
98-
- name: Upload fat Binary to GitHub Release
70+
- name: Upload XCFramework to GitHub Release
9971
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
10072
run: |
101-
cd Release-fat/BEMCheckBox.framework
102-
zip -r BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.framework.zip .
103-
echo "Listing: Release-fat/BEMCheckbox.framework" && ls -la
104-
dotnet gitreleasemanager addasset --token ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} --repository ${{ github.event.repository.name }} --tagName v${{ steps.gitversion.outputs.majorMinorPatch }} --assets BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.framework.zip
73+
cd Temp/Release-fat/BEMCheckBox.xcframework
74+
zip -r BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.xcframework.zip .
75+
echo "Listing: Temp/Release-fat/BEMCheckBox.xcframework" && ls -la
76+
dotnet gitreleasemanager addasset --token ${{ secrets.GITHUB_TOKEN }} --owner ${{ github.repository_owner }} --repository ${{ github.event.repository.name }} --tagName v${{ steps.gitversion.outputs.majorMinorPatch }} --assets BEMCheckBox-v${{ steps.gitversion.outputs.majorMinorPatch }}.xcframework.zip

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ fastlane/test_output
6868

6969
.build/
7070
.vscode/
71+
72+
# Temp folder for build artifacts
73+
Temp/

Scripts/build-xcframework.sh

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
#!/bin/bash
2+
3+
################################################################################
4+
# Build XCFramework Script for BEMCheckBox
5+
#
6+
# This script builds a universal XCFramework that works on both
7+
# iOS Simulator and iOS Device platforms.
8+
#
9+
# Usage:
10+
# ./Scripts/build-xcframework.sh [--help]
11+
#
12+
# Output:
13+
# Temp/Release-fat/BEMCheckBox.xcframework
14+
#
15+
################################################################################
16+
17+
set -e # Exit on error
18+
set -o pipefail # Catch errors in pipes
19+
20+
# Configuration
21+
PROJECT_PATH="Sample Project/CheckBox.xcodeproj"
22+
SCHEME="BEMCheckBox"
23+
CONFIGURATION="Release"
24+
ARCHIVE_DIR="Temp/Archives"
25+
OUTPUT_DIR="Temp/Release-fat"
26+
27+
# Archive paths
28+
IOS_SIMULATOR_ARCHIVE="$ARCHIVE_DIR/BEMCheckBox-iOS_Simulator.xcarchive"
29+
IOS_DEVICE_ARCHIVE="$ARCHIVE_DIR/BEMCheckBox-iOS.xcarchive"
30+
31+
# Colors for output
32+
RED='\033[0;31m'
33+
GREEN='\033[0;32m'
34+
YELLOW='\033[1;33m'
35+
BLUE='\033[0;34m'
36+
NC='\033[0m' # No Color
37+
38+
################################################################################
39+
# Helper Functions
40+
################################################################################
41+
42+
print_header() {
43+
echo ""
44+
echo -e "${BLUE}===================================================================${NC}"
45+
echo -e "${BLUE}$1${NC}"
46+
echo -e "${BLUE}===================================================================${NC}"
47+
echo ""
48+
}
49+
50+
print_success() {
51+
echo -e "${GREEN}$1${NC}"
52+
}
53+
54+
print_error() {
55+
echo -e "${RED}$1${NC}"
56+
}
57+
58+
print_info() {
59+
echo -e "${BLUE}$1${NC}"
60+
}
61+
62+
show_help() {
63+
cat << EOF
64+
Build XCFramework Script for BEMCheckBox
65+
66+
This script builds a universal XCFramework that works on both
67+
iOS Simulator and iOS Device platforms.
68+
69+
USAGE:
70+
./Scripts/build-xcframework.sh [--help]
71+
72+
OUTPUT:
73+
Temp/Release-fat/BEMCheckBox.xcframework
74+
75+
EOF
76+
}
77+
78+
# Reusable build function
79+
build_archive() {
80+
local platform_name="$1"
81+
local destination="$2"
82+
local archive_path="$3"
83+
84+
print_header "Building for $platform_name"
85+
86+
xcodebuild archive \
87+
-project "$PROJECT_PATH" \
88+
-scheme "$SCHEME" \
89+
-destination "$destination" \
90+
-configuration "$CONFIGURATION" \
91+
-archivePath "$archive_path" \
92+
SKIP_INSTALL=NO \
93+
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
94+
95+
print_success "$platform_name build completed"
96+
echo ""
97+
echo "Listing: $archive_path"
98+
ls -laR "$archive_path"
99+
echo ""
100+
}
101+
102+
# Validate environment
103+
validate_environment() {
104+
if ! command -v xcodebuild &> /dev/null; then
105+
print_error "xcodebuild not found. Please install Xcode."
106+
exit 1
107+
fi
108+
109+
if [[ ! -d "$PROJECT_PATH" ]]; then
110+
print_error "Project not found: $PROJECT_PATH"
111+
exit 1
112+
fi
113+
}
114+
115+
################################################################################
116+
# Parse Arguments
117+
################################################################################
118+
119+
if [[ "$1" == "--help" ]]; then
120+
show_help
121+
exit 0
122+
fi
123+
124+
################################################################################
125+
# Main Build Process
126+
################################################################################
127+
128+
START_TIME=$(date +%s)
129+
130+
print_header "BEMCheckBox XCFramework Build"
131+
132+
print_info "Configuration: $CONFIGURATION"
133+
print_info "Project: $PROJECT_PATH"
134+
print_info "Scheme: $SCHEME"
135+
echo ""
136+
137+
# Validate environment
138+
validate_environment
139+
140+
# Clean up previous builds
141+
print_info "Cleaning previous builds..."
142+
rm -rf "$ARCHIVE_DIR"
143+
rm -rf "$OUTPUT_DIR"
144+
145+
# Build for iOS Simulator
146+
build_archive \
147+
"iOS Simulator" \
148+
"generic/platform=iOS Simulator" \
149+
"$IOS_SIMULATOR_ARCHIVE"
150+
151+
# Build for iOS Device
152+
build_archive \
153+
"iOS Device" \
154+
"generic/platform=iOS" \
155+
"$IOS_DEVICE_ARCHIVE"
156+
157+
# Create XCFramework
158+
print_header "Creating XCFramework"
159+
160+
xcodebuild -create-xcframework \
161+
-archive "$IOS_SIMULATOR_ARCHIVE" -framework "BEMCheckBox.framework" \
162+
-archive "$IOS_DEVICE_ARCHIVE" -framework "BEMCheckBox.framework" \
163+
-output "$OUTPUT_DIR/BEMCheckBox.xcframework"
164+
165+
print_success "XCFramework created successfully"
166+
echo ""
167+
168+
# Show final output details
169+
print_info "Output location: $OUTPUT_DIR/BEMCheckBox.xcframework"
170+
ls -laR "$OUTPUT_DIR/BEMCheckBox.xcframework"
171+
echo ""
172+
173+
# Show supported architectures
174+
print_header "Supported Architectures"
175+
176+
print_info "iOS Simulator architectures:"
177+
file "$OUTPUT_DIR/BEMCheckBox.xcframework/ios-arm64_x86_64-simulator/BEMCheckBox.framework/BEMCheckBox"
178+
echo ""
179+
180+
print_info "iOS Device architectures:"
181+
file "$OUTPUT_DIR/BEMCheckBox.xcframework/ios-arm64/BEMCheckBox.framework/BEMCheckBox"
182+
echo ""
183+
184+
# Build summary
185+
END_TIME=$(date +%s)
186+
DURATION=$((END_TIME - START_TIME))
187+
188+
print_header "Build Summary"
189+
print_success "XCFramework: $OUTPUT_DIR/BEMCheckBox.xcframework"
190+
print_info "Size: $(du -sh "$OUTPUT_DIR/BEMCheckBox.xcframework" | cut -f1)"
191+
print_info "Configuration: $CONFIGURATION"
192+
print_info "Build time: ${DURATION}s"
193+
echo ""

0 commit comments

Comments
 (0)