Skip to content

Commit 5835b55

Browse files
authored
bindings/c: Add support for Intel architecture (#2218)
A continuation of #2202 I added support only for arm64 archs, but the Apple tooling still requires x86_64 to be present, even though intel macs are phased out This just modifies the make file to create a fat dylib for ios
2 parents 99e6ad3 + cd605eb commit 5835b55

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

bindings/c/Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,30 @@ package-dylibs:
5757
mkdir -p generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers
5858
cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers/
5959

60-
# Pack simulator dylibs
61-
cp ../../target/aarch64-apple-ios-sim/release/$(IOS_LIB_FILE) generated/$(IOS_FINAL_LIB_FILE)
62-
63-
cp generated/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/
64-
install_name_tool -id @rpath/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
65-
codesign -f -s - --identifier com.turso.libsql-experimental generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
60+
# Pack simulator dylibs (fat binary: arm64 + x86_64)
61+
lipo -create \
62+
../../target/aarch64-apple-ios-sim/release/$(IOS_LIB_FILE) \
63+
../../target/x86_64-apple-ios/release/$(IOS_LIB_FILE) \
64+
-output generated/$(IOS_FINAL_LIB_FILE)
65+
66+
cp generated/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/
67+
install_name_tool -id @rpath/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
68+
codesign -f -s - --identifier com.turso.libsql-experimental generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/$(IOS_FINAL_LIB_FILE)
6669

67-
mkdir -p generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers
68-
cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers/
70+
mkdir -p generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/Headers
71+
cp include/$(HEADER) generated/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/Headers/
6972

7073
ios-build:
7174
cargo build --release --target aarch64-apple-ios
7275
cargo build --release --target aarch64-apple-ios-sim
76+
SDKROOT=$$(xcrun --sdk iphonesimulator --show-sdk-path) \
77+
CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios-simulator" \
78+
CXXFLAGS_x86_64_apple_ios="-target x86_64-apple-ios-simulator" \
79+
CC_x86_64_apple_ios=$$(xcrun --sdk iphonesimulator --find clang) \
80+
CXX_x86_64_apple_ios=$$(xcrun --sdk iphonesimulator --find clang++) \
81+
CMAKE_SYSTEM_NAME=iOS \
82+
CMAKE_OSX_SYSROOT=$$(xcrun --sdk iphonesimulator --show-sdk-path) \
83+
cargo build --release --target x86_64-apple-ios
7384

7485
android: $(ARCHS_ANDROID)
7586
rm -rf generated

bindings/c/templates/libsql_experimental.xcframework/Info.plist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
</dict>
1919
<dict>
2020
<key>LibraryIdentifier</key>
21-
<string>ios-arm64-simulator</string>
21+
<string>ios-arm64_x86_64-simulator</string>
2222
<key>LibraryPath</key>
2323
<string>libsql_experimental.framework</string>
2424
<key>SupportedArchitectures</key>
2525
<array>
2626
<string>arm64</string>
27+
<string>x86_64</string>
2728
</array>
2829
<key>SupportedPlatform</key>
2930
<string>ios</string>

bindings/c/templates/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist renamed to bindings/c/templates/libsql_experimental.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.framework/Info.plist

File renamed without changes.

0 commit comments

Comments
 (0)