44
55set -e
66
7- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
8- PROJECT_ROOT=" $( dirname " $SCRIPT_DIR " ) "
7+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd -P) "
8+ # Use realpath to get canonical path with correct case on macOS
9+ PROJECT_ROOT=" $( realpath " $( dirname " $SCRIPT_DIR " ) " ) "
10+
11+ # Ensure we're working from the canonical path
12+ cd " $PROJECT_ROOT "
13+
914OUTPUT_DIR=" ${PROJECT_ROOT} /bindings/swift"
1015XCFRAMEWORK_DIR=" ${OUTPUT_DIR} /CooklangFind.xcframework"
1116
@@ -51,13 +56,9 @@ check_requirements() {
5156
5257# Install required Rust targets
5358install_targets () {
54- log_info " Installing Rust targets for Apple platforms..."
55-
56- # macOS
57- rustup target add x86_64-apple-darwin 2> /dev/null || true
58- rustup target add aarch64-apple-darwin 2> /dev/null || true
59+ log_info " Installing Rust targets for iOS..."
5960
60- # iOS
61+ # iOS only
6162 rustup target add aarch64-apple-ios 2> /dev/null || true
6263 rustup target add aarch64-apple-ios-sim 2> /dev/null || true
6364 rustup target add x86_64-apple-ios 2> /dev/null || true
@@ -82,7 +83,7 @@ generate_bindings() {
8283
8384 # Find a built library to generate bindings from
8485 local lib_path=" "
85- for target in aarch64-apple-darwin x86_64 -apple-darwin aarch64 -apple-ios; do
86+ for target in aarch64-apple-ios aarch64 -apple-ios-sim x86_64 -apple-ios; do
8687 local candidate=" ${PROJECT_ROOT} /target/${target} /release/libcooklang_find.dylib"
8788 if [[ -f " $candidate " ]]; then
8889 lib_path=" $candidate "
@@ -105,7 +106,7 @@ generate_bindings() {
105106 fi
106107 fi
107108
108- cargo run --release --bin uniffi-bindgen -- generate \
109+ cargo run --release --features cli -- bin uniffi-bindgen -- generate \
109110 --library " $lib_path " \
110111 --language swift \
111112 --config " ${PROJECT_ROOT} /uniffi.toml" \
@@ -114,7 +115,7 @@ generate_bindings() {
114115 log_info " Swift bindings generated at: $OUTPUT_DIR /Sources/CooklangFind"
115116}
116117
117- # Create XCFramework (macOS only)
118+ # Create XCFramework (iOS only)
118119create_xcframework () {
119120 if [[ " $OSTYPE " != " darwin" * ]]; then
120121 log_warn " XCFramework creation is only supported on macOS"
@@ -128,24 +129,6 @@ create_xcframework() {
128129
129130 local framework_args=()
130131
131- # macOS universal binary
132- if [[ -f " ${PROJECT_ROOT} /target/aarch64-apple-darwin/release/libcooklang_find.a" ]] && \
133- [[ -f " ${PROJECT_ROOT} /target/x86_64-apple-darwin/release/libcooklang_find.a" ]]; then
134- log_info " Creating macOS universal binary..."
135- mkdir -p " $OUTPUT_DIR /tmp/macos"
136- lipo -create \
137- " ${PROJECT_ROOT} /target/aarch64-apple-darwin/release/libcooklang_find.a" \
138- " ${PROJECT_ROOT} /target/x86_64-apple-darwin/release/libcooklang_find.a" \
139- -output " $OUTPUT_DIR /tmp/macos/libcooklang_find.a"
140-
141- # Create module for macOS
142- mkdir -p " $OUTPUT_DIR /tmp/macos/Headers"
143- cp " $OUTPUT_DIR /Sources/CooklangFind/CooklangFindFFI.h" " $OUTPUT_DIR /tmp/macos/Headers/"
144- cp " $OUTPUT_DIR /Sources/CooklangFind/CooklangFindFFI.modulemap" " $OUTPUT_DIR /tmp/macos/Headers/module.modulemap"
145-
146- framework_args+=(-library " $OUTPUT_DIR /tmp/macos/libcooklang_find.a" -headers " $OUTPUT_DIR /tmp/macos/Headers" )
147- fi
148-
149132 # iOS device
150133 if [[ -f " ${PROJECT_ROOT} /target/aarch64-apple-ios/release/libcooklang_find.a" ]]; then
151134 log_info " Adding iOS device library..."
@@ -202,10 +185,7 @@ import PackageDescription
202185let package = Package(
203186 name: "CooklangFind",
204187 platforms: [
205- .iOS(.v13),
206- .macOS(.v10_15),
207- .tvOS(.v13),
208- .watchOS(.v6)
188+ .iOS(.v13)
209189 ],
210190 products: [
211191 .library(
@@ -250,7 +230,7 @@ main() {
250230 echo " Usage: $0 [OPTIONS]"
251231 echo " "
252232 echo " Options:"
253- echo " --all Build for all Apple platforms"
233+ echo " --all Build for all iOS platforms"
254234 echo " --generate-only Only generate Swift bindings (no compilation)"
255235 echo " --help, -h Show this help message"
256236 exit 0
@@ -273,13 +253,11 @@ main() {
273253 install_targets
274254
275255 if [[ " $OSTYPE " == " darwin" * ]]; then
276- build_target " aarch64-apple-darwin"
277- build_target " x86_64-apple-darwin"
278256 build_target " aarch64-apple-ios"
279257 build_target " aarch64-apple-ios-sim"
280258 build_target " x86_64-apple-ios"
281259 else
282- log_warn " Cross-compiling for Apple platforms requires macOS"
260+ log_warn " Cross-compiling for iOS requires macOS"
283261 log_info " Building for host platform only..."
284262 cargo build --release
285263 fi
0 commit comments