Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,22 @@ jobs:
exit 1
}

# Xcode collects *.signature files from build products into the archive,
# and App Store Connect rejects any that is not an XCFramework code
# signature (ITMS-91063, #4539). No build phase may leave one there.
# The react-native-webgpu release the example installs still writes
# .rnwgpu-dawn.signature (fixed in wcandillon/react-native-webgpu#655):
# drop the exclusion once the example is on a release with that fix.
- name: Check build products for *.signature files
run: |
signatures=$(find "$DERIVED_DATA/Build/Products" -name '*.signature' \
-not -path '*/ReactNativeWebGPUBinaries/*')
if [ -n "$signatures" ]; then
echo "::error::Build products contain *.signature files, which App Store Connect rejects (ITMS-91063):"
echo "$signatures"
exit 1
fi

# React Native's prebuilt core, which the example installs since 0.88, is
# compiled with Metro on 8081: an RCT_METRO_PORT build setting no longer
# reaches it.
Expand Down
93 changes: 93 additions & 0 deletions packages/skia/scripts/__tests__/prepare-apple-binaries.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { execFileSync } from "child_process";
import fs from "fs";
import os from "os";
import path from "path";

const script = path.join(__dirname, "..", "prepare-apple-binaries.sh");

// Every file below `directory`, relative to it.
const walk = (directory: string): string[] =>
fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
const file = path.join(directory, entry.name);
return entry.isDirectory()
? walk(file).map((child) => path.join(entry.name, child))
: [entry.name];
});

// Runs the assembly and linker staging steps of the Xcode phase against a
// local archive. The macOS-only ditto and plutil are stubbed so the test also
// runs on Linux.
const prepare = (root: string) =>
execFileSync(
"/bin/bash",
[
"-c",
`set -Eeuo pipefail
source "$1"
ditto() { mkdir -p "$2"; cp -R "$1"/. "$2"; }
json_strings() { echo arm64; }
WORK_DIR="$2/work"; mkdir -p "$WORK_DIR"; TEMP_PATHS=()
SDK=iphoneos VERSION=0.0.0 SOURCE_SIGNATURE=source MODULE=skia
MODULE_LIBRARIES=(libskia.a) META_IDENTIFIER=ios-arm64 META_ARCHS=arm64
SOURCE_DIRECTORY="$2/source" CONTAINERS="$2/assembly" OUTPUT="$2/output"
assemble_module
CONTAINER_ROOT="$CONTAINERS/$MODULE"
stage_module`,
"prepare",
script,
root,
],
{ stdio: "pipe" }
);

// Xcode collects *.signature files from build products into the archive, and
// App Store Connect rejects any that is not an XCFramework code signature
// (ITMS-91063, #4539). Build bookkeeping must never use that extension.
describe("prepare-apple-binaries.sh", () => {
let root: string;

beforeEach(() => {
root = fs.mkdtempSync(path.join(os.tmpdir(), "rnskia-prepare-"));
fs.mkdirSync(path.join(root, "source"));
fs.writeFileSync(path.join(root, "source", "libskia.a"), "archive");
fs.writeFileSync(
path.join(root, "source", "metadata.json"),
'{"architectures":["arm64"]}'
);
});

afterEach(() => fs.rmSync(root, { recursive: true, force: true }));

const signatures = () =>
["output", "assembly"].flatMap((directory) =>
walk(path.join(root, directory))
.filter((file) => file.endsWith(".signature"))
.map((file) => path.join(directory, file))
);

it("stages the library without writing *.signature files", () => {
prepare(root);
expect(
fs.readFileSync(path.join(root, "output", "librnskia_skia.a"), "utf8")
).toBe("archive");
expect(signatures()).toEqual([]);
// An incremental build reuses the stamps and still writes none.
prepare(root);
expect(signatures()).toEqual([]);
});

it("removes the *.signature stamps of earlier releases", () => {
// Archive build folders persist, so 3.12 stamps would still be uploaded.
fs.mkdirSync(path.join(root, "output"));
fs.writeFileSync(path.join(root, "output", ".rnskia-skia.signature"), "");
fs.mkdirSync(path.join(root, "assembly", "skia", ".slices"), {
recursive: true,
});
fs.writeFileSync(
path.join(root, "assembly", "skia", ".slices", "iphoneos.signature"),
""
);
prepare(root);
expect(signatures()).toEqual([]);
});
});
12 changes: 9 additions & 3 deletions packages/skia/scripts/prepare-apple-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ copy_library() {
# The caller holds the assembly lock across both assembly and linker staging.
assemble_module() {
local root="$CONTAINERS/$MODULE" library existing=true temporary previous='' old_archs platform variant ignored deployment
local signature_file="$CONTAINERS/$MODULE/.slices/$SDK.signature"
local signature_file="$CONTAINERS/$MODULE/.slices/$SDK.stamp"
CONTAINER_ROOT="$root"
for library in "${MODULE_LIBRARIES[@]}"; do
if [[ ! -f "$root/${library%.a}.xcframework/$META_IDENTIFIER/$library" || ! -f "$root/${library%.a}.xcframework/Info.plist" ]]; then existing=false; fi
Expand All @@ -228,6 +228,7 @@ assemble_module() {
previous="$platform-$(printf '%s\n' "$old_archs" | LC_ALL=C sort | paste -sd _ -)${variant:+-$variant}"
fi
mkdir -p "$temporary/.slices"
rm -f "$temporary/.slices/$SDK.signature"
cp "$SOURCE_DIRECTORY/metadata.json" "$temporary/.slices/$SDK.json"
for library in "${MODULE_LIBRARIES[@]}"; do
local container="$temporary/${library%.a}.xcframework"
Expand All @@ -236,7 +237,7 @@ assemble_module() {
copy_library "$SOURCE_DIRECTORY/$library" "$container/$META_IDENTIFIER/$library"
write_xcframework_plist "$container" "$library" "$temporary/.slices"
done
printf '%s\n' "$SOURCE_SIGNATURE" > "$temporary/.slices/$SDK.signature"
printf '%s\n' "$SOURCE_SIGNATURE" > "$temporary/.slices/$SDK.stamp"
replace_directory "$temporary" "$root"
note "Prepared $SDK XCFramework slices ($(printf '%s' "$META_ARCHS" | tr '\n' ' '))"
}
Expand All @@ -248,10 +249,15 @@ assemble_module() {
# rather than dynamic frameworks copied into the app's Frameworks directory.
# Build-product stamps include SDK/version/source identity, avoiding equal-size
# archives from another platform and unnecessary copies on incremental builds.
# Stamps must never use the .signature extension: Xcode collects *.signature
# files from build products into the archive, and App Store Connect rejects
# them as invalid XCFramework code signatures (ITMS-91063).
stage_module() {
local library destination temporary stamp="$OUTPUT/.rnskia-$MODULE.signature"
local library destination temporary stamp="$OUTPUT/.rnskia-$MODULE.stamp"
local signature="$SDK:$VERSION:$SOURCE_SIGNATURE" name
mkdir -p "$OUTPUT"
# Archive build folders persist across runs; drop stamps from older releases.
rm -f "$OUTPUT/.rnskia-$MODULE.signature"
for library in "${MODULE_LIBRARIES[@]}"; do
name="${library#lib}"
destination="$OUTPUT/librnskia_$name"
Expand Down
Loading