Skip to content

Instantly share code, notes, and snippets.

@cdata
Created April 12, 2023 15:45
Show Gist options
  • Save cdata/2ffb2a3937fccab9e9a2a1aeca1a71f2 to your computer and use it in GitHub Desktop.
Save cdata/2ffb2a3937fccab9e9a2a1aeca1a71f2 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
set -x
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_DIR="$SCRIPT_DIR/../"
pushd $PROJECT_DIR
rm -rf ./LibNoosphere.xcframework
rm -rf ./target/headers
mkdir -p ./target/headers
cp -r ./rust/noosphere/include ./target/headers/include
# cargo run --package noosphere --example generate_header --features headers --locked
cp ./noosphere.h ./target/headers/include/noosphere/noosphere.h
TARGETS=(
"aarch64-apple-ios"
"x86_64-apple-ios"
"aarch64-apple-ios-sim"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
)
for TARGET in "${TARGETS[@]}"; do
rustup target install $TARGET
# cargo build --package noosphere --release --target $TARGET --locked
cargo build --package noosphere --target $TARGET --locked
done
mkdir -p ./target/macos
mkdir -p ./target/simulator
lipo -create \
./target/x86_64-apple-darwin/release/libnoosphere.a \
./target/aarch64-apple-darwin/release/libnoosphere.a \
-output ./target/macos/libnoosphere.a
lipo -create \
./target/x86_64-apple-ios/release/libnoosphere.a \
./target/aarch64-apple-ios-sim/release/libnoosphere.a \
-output ./target/simulator/libnoosphere.a
xcodebuild -create-xcframework \
-library ./target/macos/libnoosphere.a \
-headers ./target/headers/include/ \
-library ./target/simulator/libnoosphere.a \
-headers ./target/headers/include/ \
-library ./target/aarch64-apple-ios/release/libnoosphere.a \
-headers ./target/headers/include/ \
-output ./LibNoosphere.xcframework
popd
set +x
set +e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment