Skip to content

Commit 99a89e0

Browse files
mokagioclaude
andcommitted
Wire codesigning into XCFramework build
Split zip+checksum out of `build_xcframework.sh` into `package_xcframework.sh` so codesigning can happen on the unzipped `.xcframework` directory between build and package. The CI build step now runs: 1. `fastlane set_up_signing_release` — installs certs 2. `make build-resources-xcframework` — builds xcframework 3. `fastlane xcframework_sign` — codesigns xcframework 4. `./package_xcframework.sh` — zips + checksums --- Generated with the help of Claude Code, https://claude.ai/code Co-Authored-By: Claude Code Opus 4.6 <noreply@anthropic.com>
1 parent f27b6bb commit 99a89e0

4 files changed

Lines changed: 52 additions & 23 deletions

File tree

.buildkite/pipeline.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ steps:
7373
command: |
7474
buildkite-agent artifact download dist.tar.gz .
7575
tar -xzf dist.tar.gz
76+
bundle exec fastlane set_up_signing_release
7677
make build-resources-xcframework
78+
bundle exec fastlane xcframework_sign
79+
./package_xcframework.sh
7780
artifact_paths:
7881
- '*.xcframework.zip'
7982
- '*.xcframework.zip.checksum.txt'

build_xcframework.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
# - Package.swift must have `resourcesMode` set to `.local`
88
#
99
# Output:
10-
# - GutenbergKitResources-<git-sha>.xcframework.zip
11-
# - GutenbergKitResources-<git-sha>.xcframework.zip.checksum.txt
10+
# - build/GutenbergKitResources-<git-sha>.xcframework
1211
#
1312
# Adapted from:
1413
# https://github.com/OpenSwiftUIProject/ProtobufKit/blob/937eae542/Scripts/build_xcframework.sh
@@ -19,12 +18,10 @@ set -euo pipefail
1918
SCHEME="GutenbergKitResources"
2019
MINIMUM_IOS_VERSION="17.0"
2120
BUILD_DIR="$(pwd)/build"
22-
OUTPUT_DIR="${1:-$(pwd)}"
2321
DERIVED_DATA_PATH="${BUILD_DIR}/DerivedData"
2422

2523
GIT_SHA="$(git rev-parse HEAD)"
2624
XCFRAMEWORK_NAME="${SCHEME}-${GIT_SHA}.xcframework"
27-
ZIP_NAME="${XCFRAMEWORK_NAME}.zip"
2825

2926
link_dylib() {
3027
local object_file="$1"
@@ -192,16 +189,5 @@ if [ -d "${SIM_DSYMS}" ]; then
192189
cp -r "${SIM_DSYMS}" "${XCFRAMEWORK_PATH}/ios-arm64_x86_64-simulator/"
193190
fi
194191

195-
# Create ZIP archive
196-
echo "--- Creating ZIP archive"
197-
(cd "${BUILD_DIR}" && zip -r "${ZIP_NAME}" "$(basename "${XCFRAMEWORK_PATH}")" > /dev/null)
198-
cp "${BUILD_DIR}/${ZIP_NAME}" "${OUTPUT_DIR}/${ZIP_NAME}"
199-
200-
# Compute checksum
201-
echo "--- Computing checksum"
202-
CHECKSUM=$(swift package compute-checksum "${OUTPUT_DIR}/${ZIP_NAME}")
203-
echo "${CHECKSUM}" > "${OUTPUT_DIR}/${ZIP_NAME}.checksum.txt"
204-
205192
echo ""
206-
echo "XCFramework: ${OUTPUT_DIR}/${ZIP_NAME}"
207-
echo "Checksum: ${CHECKSUM}"
193+
echo "XCFramework: ${XCFRAMEWORK_PATH}"

fastlane/Fastfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,11 @@ lane :publish_to_s3 do |options|
4040
end
4141

4242
lane :xcframework_sign do
43-
require_env_vars!(*ASC_API_KEY_ENV_VARS, *CODE_SIGNING_STORAGE_ENV_VARS)
44-
45-
set_up_signing_release
46-
4743
sh(
4844
'codesign',
4945
'--timestamp',
5046
'-s', 'Apple Distribution',
51-
xcframework_file_path.sub('.zip', '')
47+
xcframework_dir_path
5248
)
5349
end
5450

@@ -75,12 +71,17 @@ end
7571

7672
def xcframework_checksum_file_path
7773
Dir.glob(File.join(PROJECT_ROOT, 'GutenbergKitResources-*.xcframework.zip.checksum.txt')).first \
78-
|| UI.user_error!('XCFramework checksum file not found. Run build_xcframework.sh first.')
74+
|| UI.user_error!('XCFramework checksum file not found. Run package_xcframework.sh first.')
75+
end
76+
77+
def xcframework_dir_path
78+
Dir.glob(File.join(PROJECT_ROOT, 'build', 'GutenbergKitResources-*.xcframework')).first \
79+
|| UI.user_error!('XCFramework not found. Run build_xcframework.sh first.')
7980
end
8081

8182
def xcframework_file_path
8283
Dir.glob(File.join(PROJECT_ROOT, 'GutenbergKitResources-*.xcframework.zip')).first \
83-
|| UI.user_error!('XCFramework zip not found. Run build_xcframework.sh first.')
84+
|| UI.user_error!('XCFramework zip not found. Run package_xcframework.sh first.')
8485
end
8586

8687
def required_version!(options)

package_xcframework.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
# Packages an XCFramework into a ZIP archive with a checksum file.
4+
#
5+
# Prerequisites:
6+
# - A built .xcframework under build/
7+
#
8+
# Output:
9+
# - GutenbergKitResources-<git-sha>.xcframework.zip
10+
# - GutenbergKitResources-<git-sha>.xcframework.zip.checksum.txt
11+
12+
set -euo pipefail
13+
14+
BUILD_DIR="$(pwd)/build"
15+
OUTPUT_DIR="${1:-$(pwd)}"
16+
17+
XCFRAMEWORK_PATH=$(find "${BUILD_DIR}" -maxdepth 1 -name "*.xcframework" -type d | head -1)
18+
19+
if [ -z "${XCFRAMEWORK_PATH}" ]; then
20+
echo "Error: No .xcframework found in ${BUILD_DIR}. Run build_xcframework.sh first." >&2
21+
exit 1
22+
fi
23+
24+
XCFRAMEWORK_NAME=$(basename "${XCFRAMEWORK_PATH}")
25+
ZIP_NAME="${XCFRAMEWORK_NAME}.zip"
26+
27+
# Create ZIP archive
28+
echo "--- Creating ZIP archive"
29+
(cd "${BUILD_DIR}" && zip -r "${ZIP_NAME}" "${XCFRAMEWORK_NAME}" > /dev/null)
30+
cp "${BUILD_DIR}/${ZIP_NAME}" "${OUTPUT_DIR}/${ZIP_NAME}"
31+
32+
# Compute checksum
33+
echo "--- Computing checksum"
34+
CHECKSUM=$(swift package compute-checksum "${OUTPUT_DIR}/${ZIP_NAME}")
35+
echo "${CHECKSUM}" > "${OUTPUT_DIR}/${ZIP_NAME}.checksum.txt"
36+
37+
echo ""
38+
echo "XCFramework: ${OUTPUT_DIR}/${ZIP_NAME}"
39+
echo "Checksum: ${CHECKSUM}"

0 commit comments

Comments
 (0)