Skip to content

Instantly share code, notes, and snippets.

@jsantell
Forked from cdata/xcode-local-build.sh
Created April 12, 2023 15:51
Show Gist options
  • Save jsantell/94e3196bf0c8cb410e3fa3eb496dea29 to your computer and use it in GitHub Desktop.
Save jsantell/94e3196bf0c8cb410e3fa3eb496dea29 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