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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions AG/generate_swiftinterface.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

## Generate template.swiftinterface from DeviceSwiftShims sources.
##
## This compiles the DeviceSwiftShims Swift files against the AttributeGraph xcframework
## to produce a .swiftinterface, then transforms it into the template used by update.sh:
## 1. Strip the compiler header comments (update.sh generates per-platform headers)

# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

SCRIPT_DIR="$(dirname "$(filepath "$0")")"
VERSION=${DARWINPRIVATEFRAMEWORKS_TARGET_RELEASE:-2024}
FRAMEWORK_ROOT="${SCRIPT_DIR}/${VERSION}"
SHIMS_DIR="${SCRIPT_DIR}/DeviceSwiftShims"
TEMPLATE_PATH="${FRAMEWORK_ROOT}/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface"

# Verify Swift compiler version matches the expected version for this framework
EXPECTED_SWIFT_VERSION="6.1" # 2024 -> 6.1, 2025 -> 6.2
SWIFT_VERSION=$(xcrun swiftc --version 2>&1 | grep -o 'Swift version [0-9]*\.[0-9]*' | head -1 | awk '{print $3}')
if [ "${SWIFT_VERSION}" != "${EXPECTED_SWIFT_VERSION}" ]; then
echo "Error: expected Swift ${EXPECTED_SWIFT_VERSION} but found Swift ${SWIFT_VERSION}"
echo "Set DEVELOPER_DIR to the correct Xcode version"
exit 1
fi

TMPDIR_WORK=$(mktemp -d)
trap "rm -rf ${TMPDIR_WORK}" EXIT

GENERATED="${TMPDIR_WORK}/generated.swiftinterface"

# Resolve the iOS Simulator SDK version for the -target flag
IOS_SDK_VERSION=$(xcrun --sdk iphonesimulator --show-sdk-version)

# Compile DeviceSwiftShims against the simulator xcframework to emit a swiftinterface
xcrun --sdk iphonesimulator swiftc \
-emit-module-interface-path "${GENERATED}" \
-emit-module-path "${TMPDIR_WORK}/module.swiftmodule" \
-module-name AttributeGraph \
-enable-library-evolution \
-swift-version 5 \
-Osize \
-enable-upcoming-feature InternalImportsByDefault \
-enable-experimental-feature Extern \
-target "arm64-apple-ios${IOS_SDK_VERSION}-simulator" \
-F "${FRAMEWORK_ROOT}/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/" \
$(find "${SHIMS_DIR}" -name '*.swift') \
2>/dev/null

if [ ! -f "${GENERATED}" ]; then
echo "Error: failed to generate swiftinterface"
exit 1
fi

# Strip the compiler header comments (update.sh generates per-platform headers)
sed -e '/^\/\/ swift-/d' \
"${GENERATED}" > "${TEMPLATE_PATH}"

echo "Generated: ${TEMPLATE_PATH}"
3 changes: 3 additions & 0 deletions AG/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ update_version_in_header() {
sed -i '' "s/#define ATTRIBUTEGRAPH_RELEASE [0-9]\{4\}/#define ATTRIBUTEGRAPH_RELEASE ${version}/g" "$file"
}

# Regenerate template.swiftinterface from DeviceSwiftShims sources
DARWINPRIVATEFRAMEWORKS_TARGET_RELEASE=${VERSION} "$(dirname "$(filepath "$0")")/generate_swiftinterface.sh"

generate_framework() {
local framework_name=$1
local arch_name=$2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// swift-compiler-version: Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.16.112 clang-1800.1.29)
// swift-module-flags: -target arm64-apple-ios26.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -Osize -enable-upcoming-feature InternalImportsByDefault -enable-experimental-feature Extern -module-name Gestures
// swift-module-flags-ignorable: -interface-compiler-version 6.2

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// swift-compiler-version: Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.16.112 clang-1800.1.29)
// swift-module-flags: -target x86_64-apple-ios26.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -Osize -enable-upcoming-feature InternalImportsByDefault -enable-experimental-feature Extern -module-name Gestures
// swift-module-flags-ignorable: -interface-compiler-version 6.2

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// swift-compiler-version: Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.16.112 clang-1800.1.29)
// swift-module-flags: -target arm64-apple-macos26.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -Osize -enable-upcoming-feature InternalImportsByDefault -enable-experimental-feature Extern -module-name Gestures
// swift-module-flags-ignorable: -interface-compiler-version 6.2

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// swift-compiler-version: Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.16.112 clang-1800.1.29)
// swift-module-flags: -target arm64e-apple-macos26.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -Osize -enable-upcoming-feature InternalImportsByDefault -enable-experimental-feature Extern -module-name Gestures
// swift-module-flags-ignorable: -interface-compiler-version 6.2

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// swift-compiler-version: Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.16.112 clang-1800.1.29)
// swift-module-flags: -target x86_64-apple-macos26.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -Osize -enable-upcoming-feature InternalImportsByDefault -enable-experimental-feature Extern -module-name Gestures
// swift-module-flags-ignorable: -interface-compiler-version 6.2

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

@_exported public import Gestures
public import Swift
public import _Concurrency
Expand Down
66 changes: 66 additions & 0 deletions GF/generate_swiftinterface.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

## Generate template.swiftinterface from DeviceSwiftShims sources.
##
## This compiles the DeviceSwiftShims Swift files against the Gestures xcframework
## to produce a .swiftinterface, then transforms it into the template used by update.sh:
## 1. Strip the compiler header comments (update.sh generates per-platform headers)
## 2. Remove `Gestures.` module prefix from extension type names

# A `realpath` alternative using the default C implementation.
filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

SCRIPT_DIR="$(dirname "$(filepath "$0")")"
VERSION=${DARWINPRIVATEFRAMEWORKS_TARGET_RELEASE:-2025}
FRAMEWORK_ROOT="${SCRIPT_DIR}/${VERSION}"
SHIMS_DIR="${SCRIPT_DIR}/DeviceSwiftShims"
TEMPLATE_PATH="${FRAMEWORK_ROOT}/Sources/Modules/Gestures.swiftmodule/template.swiftinterface"

# Verify Swift compiler version matches the expected version for this framework
EXPECTED_SWIFT_VERSION="6.2" # 2024 -> 6.1, 2025 -> 6.2
SWIFT_VERSION=$(xcrun swiftc --version 2>&1 | grep -o 'Swift version [0-9]*\.[0-9]*' | head -1 | awk '{print $3}')
if [ "${SWIFT_VERSION}" != "${EXPECTED_SWIFT_VERSION}" ]; then
echo "Error: expected Swift ${EXPECTED_SWIFT_VERSION} but found Swift ${SWIFT_VERSION}"
echo "Set DEVELOPER_DIR to the correct Xcode version"
exit 1
fi

TMPDIR_WORK=$(mktemp -d)
trap "rm -rf ${TMPDIR_WORK}" EXIT

GENERATED="${TMPDIR_WORK}/generated.swiftinterface"

# Resolve the iOS Simulator SDK version for the -target flag
IOS_SDK_VERSION=$(xcrun --sdk iphonesimulator --show-sdk-version)

# Compile DeviceSwiftShims against the simulator xcframework to emit a swiftinterface
xcrun --sdk iphonesimulator swiftc \
-emit-module-interface-path "${GENERATED}" \
-emit-module-path "${TMPDIR_WORK}/module.swiftmodule" \
-module-name Gestures \
-enable-library-evolution \
-swift-version 5 \
-Osize \
-enable-upcoming-feature InternalImportsByDefault \
-enable-experimental-feature Extern \
-target "arm64-apple-ios${IOS_SDK_VERSION}-simulator" \
-F "${FRAMEWORK_ROOT}/Gestures.xcframework/ios-arm64-x86_64-simulator/" \
"${SHIMS_DIR}/Export.swift" \
$(find "${SHIMS_DIR}/Extension" -name '*.swift' 2>/dev/null) \
2>/dev/null

if [ ! -f "${GENERATED}" ]; then
echo "Error: failed to generate swiftinterface"
exit 1
fi

# Transform:
# 1. Strip the compiler header comments (update.sh generates per-platform headers)
# 2. Remove `Gestures.` module prefix from extension declarations
sed -e '/^\/\/ swift-/d' \
-e 's/extension Gestures\./extension /g' \
"${GENERATED}" > "${TEMPLATE_PATH}"

echo "Generated: ${TEMPLATE_PATH}"
3 changes: 3 additions & 0 deletions GF/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ generate_xcframework() {
cp ${FRAMEWORK_ROOT}/Info.plist ${path}/
}

# Regenerate template.swiftinterface from DeviceSwiftShims sources
DARWINPRIVATEFRAMEWORKS_TARGET_RELEASE=${VERSION} "$(dirname "$(filepath "$0")")/generate_swiftinterface.sh"

generate_xcframework $framework_name

generate_framework $framework_name ios-arm64-arm64e
Expand Down
Loading