Skip to content

Commit f252d19

Browse files
authored
Update create_frameworks.sh to put each .swiftmodule into correspondi… (#11088)
1 parent ba79cb6 commit f252d19

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

scripts/create_frameworks.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,27 @@ create_xcframework() {
138138
echo "No .swiftmodule file found in ${module_source_dir}"
139139
exit 1
140140
fi
141-
142-
local dir_suffix
143-
dir_suffix=$(echo "$dir" | cut -d'/' -f1 | tr '[:upper:]' '[:lower:]' | sed 's/[\/\.~]/_/g')
144-
for slice_path in "${xcframework}/${dir_suffix}-"*; do
145-
if [ -d "${slice_path}/Headers" ]; then
146-
echo " - Copying ${swiftmodule_file##*/} to ${slice_path}/Headers/${swift_module}.swiftmodule"
147-
cp "${swiftmodule_file}" "${slice_path}/Headers/${swift_module}.swiftmodule"
148-
fi
149-
done
141+
local base=$(basename "$swiftmodule_file" .swiftmodule)
142+
local arch="${base%%-*}"
143+
local rest="${base#*-apple-}"
144+
local platform_tag
145+
local variant
146+
if [[ "$rest" == *-simulator ]]; then
147+
platform_tag="${rest%-simulator}"
148+
variant="-simulator"
149+
else
150+
platform_tag="$rest"
151+
variant=""
152+
fi
153+
local slice_name="${platform_tag}-${arch}${variant}"
154+
local slice_path="${xcframework}/${slice_name}"
155+
if [ ! -d "$slice_path" ]; then
156+
echo "Warning: slice '${slice_name}' not found in ${xcframework}, skipping"
157+
continue
158+
fi
159+
echo " - Copying ${swift_module}.swiftmodule into slice ${slice_name}"
160+
cp "$swiftmodule_file" "${slice_path}/${swift_module}.swiftmodule"
161+
ln -sf "../${swift_module}.swiftmodule" "${slice_path}/Headers/${swift_module}.swiftmodule"
150162
done
151163
fi
152164

0 commit comments

Comments
 (0)