Skip to content

Copy .swiftinterface instead of .swiftmodule #11102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
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
3 changes: 1 addition & 2 deletions extension/apple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ set_target_properties(extension_apple PROPERTIES
Swift_MODULE_NAME "ExecuTorch"
Swift_FLAGS "${SWIFT_CLANG_INTEROP_FLAGS}"
XCODE_ATTRIBUTE_SWIFT_MODULE_NAME "ExecuTorch"
XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION YES
XCODE_ATTRIBUTE_SWIFT_ENABLE_TESTABILITY YES
XCODE_ATTRIBUTE_BUILD_LIBRARY_FOR_DISTRIBUTION "YES"
XCODE_ATTRIBUTE_OTHER_SWIFT_FLAGS "${SWIFT_CLANG_INTEROP_FLAGS}"
)

Expand Down
21 changes: 11 additions & 10 deletions scripts/create_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,23 @@ create_xcframework() {
# Create the new .xcframework.
xcodebuild -create-xcframework "${libraries[@]}" -output "${xcframework}"

# Copy the .swiftmodule files into the .xcframework if applicable.
# Copy the .swiftinterface files into the .xcframework if applicable.
if [[ -n "$swift_module" ]]; then
echo -e "\nCopying Swift module ${swift_module}.swiftmodule into ${xcframework}"
echo -e "\nCopying Swift interface ${swift_module}.swiftinterface into ${xcframework}"
for dir in "${directories[@]}"; do
local module_source_dir="${dir}/${swift_module}.swiftmodule"
if [ ! -d "$module_source_dir" ]; then
echo "Swiftmodule directory ${module_source_dir} does not exist"
exit 1
fi
local swiftmodule_file
swiftmodule_file=$(find "$module_source_dir" -maxdepth 1 -type f -name '*.swiftmodule' | head -n1)
if [[ -z "$swiftmodule_file" ]]; then
echo "No .swiftmodule file found in ${module_source_dir}"
local swiftinterface_file
swiftinterface_file=$(find "$module_source_dir" -maxdepth 1 \
-type f -name '*.swiftinterface' ! -name '*.private.swiftinterface' | head -n1)
if [[ -z "$swiftinterface_file" ]]; then
echo "No public .swiftinterface file found in ${module_source_dir}"
exit 1
fi
local base=$(basename "$swiftmodule_file" .swiftmodule)
local base=$(basename "$swiftinterface_file" .swiftinterface)
local arch="${base%%-*}"
local rest="${base#*-apple-}"
local platform_tag
Expand All @@ -156,9 +157,9 @@ create_xcframework() {
echo "Warning: slice '${slice_name}' not found in ${xcframework}, skipping"
continue
fi
echo " - Copying ${swift_module}.swiftmodule into slice ${slice_name}"
cp "$swiftmodule_file" "${slice_path}/${swift_module}.swiftmodule"
ln -sf "../${swift_module}.swiftmodule" "${slice_path}/Headers/${swift_module}.swiftmodule"
echo " - Copying ${swift_module}.swiftinterface into slice ${slice_name}"
cp "$swiftinterface_file" "${slice_path}/${swift_module}.swiftinterface"
ln -sf "../${swift_module}.swiftinterface" "${slice_path}/Headers/${swift_module}.swiftinterface"
done
fi

Expand Down
Loading