Build libplist into an xcframework

This commit is contained in:
Jackson Coxson
2025-06-03 10:26:50 -06:00
parent 868f44e7b0
commit 491d8c6095
4 changed files with 125 additions and 1 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "ffi/libplist"]
path = ffi/libplist
url = https://github.com/libimobiledevice/libplist.git

1
ffi/libplist Submodule

Submodule ffi/libplist added at cf5897a71e

114
justfile
View File

@@ -3,7 +3,7 @@ check-features:
cargo hack check --feature-powerset --no-dev-deps cargo hack check --feature-powerset --no-dev-deps
cd .. cd ..
xcframework: # apple-build xcframework: apple-build
rm -rf swift/IDevice.xcframework rm -rf swift/IDevice.xcframework
rm -rf swift/libs rm -rf swift/libs
cp ffi/idevice.h swift/include/idevice.h cp ffi/idevice.h swift/include/idevice.h
@@ -41,3 +41,115 @@ apple-build: # requires a Mac
# macOS (native) no special env needed # macOS (native) no special env needed
cargo build --release --target aarch64-apple-darwin cargo build --release --target aarch64-apple-darwin
cargo build --release --target x86_64-apple-darwin cargo build --release --target x86_64-apple-darwin
lib_name := "plist"
src_dir := "ffi/libplist"
ios_out := "build/ios"
sim_out := "build/sim"
x86_64_sim_out := "build/x86_64_sim"
mac_out := "build/mac"
x86_64_mac_out := "build/x86_64_mac"
plist_xcframework: build_plist_ios build_plist_sim build_plist_x86_64_sim build_plist_mac build_plist_x86_64_mac merge_archs
rm -rf {{lib_name}}.xcframework
xcodebuild -create-xcframework \
-library {{ios_out}}/lib/libplist-2.0.dylib -headers {{ios_out}}/include \
-library build/universal-sim/libplist-2.0.dylib -headers {{sim_out}}/include \
-library build/universal-mac/libplist-2.0.dylib -headers {{mac_out}}/include \
-output swift/{{lib_name}}.xcframework
merge_archs:
# Merge simulator dylibs (arm64 + x86_64)
mkdir -p build/universal-sim
lipo -create \
{{sim_out}}/lib/libplist-2.0.dylib \
{{x86_64_sim_out}}/lib/libplist-2.0.dylib \
-output build/universal-sim/libplist-2.0.dylib
# Merge macOS dylibs (arm64 + x86_64)
mkdir -p build/universal-mac
lipo -create \
{{mac_out}}/lib/libplist-2.0.dylib \
{{x86_64_mac_out}}/lib/libplist-2.0.dylib \
-output build/universal-mac/libplist-2.0.dylib
build_plist_ios:
rm -rf {{ios_out}} build/build-ios
mkdir -p {{ios_out}}
mkdir -p build/build-ios && cd build/build-ios && \
../../ffi/libplist/autogen.sh \
--host=arm-apple-darwin \
--prefix="$(pwd)/../../{{ios_out}}" \
--without-cython \
--without-tools \
CC="$(xcrun --sdk iphoneos --find clang)" \
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" \
CXX="$(xcrun --sdk iphoneos --find clang++)" \
CXXFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" \
LDFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" && \
make clean && make -j$(sysctl -n hw.ncpu) && make install
build_plist_sim:
rm -rf {{sim_out}} build/build-sim
mkdir -p {{sim_out}}
mkdir -p build/build-sim && cd build/build-sim && \
../../ffi/libplist/autogen.sh \
--host=arm-apple-darwin \
--prefix="$(pwd)/../../{{sim_out}}" \
--without-cython \
--without-tools \
CC="$(xcrun --sdk iphonesimulator --find clang)" \
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" \
CXX="$(xcrun --sdk iphonesimulator --find clang++)" \
CXXFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" \
LDFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" && \
make clean && make -j$(sysctl -n hw.ncpu) && make install
build_plist_x86_64_sim:
rm -rf {{x86_64_sim_out}} build/build-sim
mkdir -p {{x86_64_sim_out}}
mkdir -p build/build-sim && cd build/build-sim && \
../../ffi/libplist/autogen.sh \
--host=x86_64-apple-darwin \
--prefix="$(pwd)/../../{{x86_64_sim_out}}" \
--without-cython \
--without-tools \
CC="$(xcrun --sdk iphonesimulator --find clang)" \
CFLAGS="-arch x86_64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" \
CXX="$(xcrun --sdk iphonesimulator --find clang++)" \
CXXFLAGS="-arch x86_64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" \
LDFLAGS="-arch x86_64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" && \
make clean && make -j$(sysctl -n hw.ncpu) && make install
build_plist_mac:
rm -rf {{mac_out}} build/build-mac
mkdir -p {{mac_out}}
mkdir -p build/build-mac && cd build/build-mac && \
../../ffi/libplist/autogen.sh \
--host=aarch64-apple-darwin \
--prefix="$(pwd)/../../{{mac_out}}" \
--without-cython \
--without-tools \
CC="$(xcrun --sdk macosx --find clang)" \
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" \
CXX="$(xcrun --sdk macosx --find clang++)" \
CXXFLAGS="-arch arm64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" \
LDFLAGS="-arch arm64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" && \
make clean && make -j$(sysctl -n hw.ncpu) && make install
build_plist_x86_64_mac:
rm -rf {{x86_64_mac_out}} build/build-mac
mkdir -p {{x86_64_mac_out}}
mkdir -p build/build-mac && cd build/build-mac && \
../../ffi/libplist/autogen.sh \
--host=x86_64-apple-darwin \
--prefix="$(pwd)/../../{{x86_64_mac_out}}" \
--without-cython \
--without-tools \
CC="$(xcrun --sdk macosx --find clang)" \
CFLAGS="-arch x86_64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" \
CXX="$(xcrun --sdk macosx --find clang++)" \
CXXFLAGS="-arch x86_64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" \
LDFLAGS="-arch x86_64 -isysroot $(xcrun --sdk macosx --show-sdk-path)" && \
make clean && make -j$(sysctl -n hw.ncpu) && make install

View File

@@ -14,11 +14,19 @@ let package = Package(
name: "IDevice", name: "IDevice",
targets: ["IDevice"] targets: ["IDevice"]
), ),
.library(
name: "plist",
targets: ["plist"],
),
], ],
targets: [ targets: [
.binaryTarget( .binaryTarget(
name: "IDevice", name: "IDevice",
path: "IDevice.xcframework" path: "IDevice.xcframework"
), ),
.binaryTarget(
name: "plist",
path: "plist.xcframework"
),
] ]
) )