Skip to content

Commit

Permalink
add ios build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sphaero committed Jan 26, 2023
1 parent 5b0a52a commit 2da939b
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
24 changes: 24 additions & 0 deletions builds/ios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# iOS Build

## Prerequisites

The build script require to be run on MacOs with XCode and the developer SDK installed.

This project is tested against SDK 15.5.

If you want to specify another version you need to set the environment variable below:

export SDK_VERSION=15.5

You can list all the versions of the SDK installed on your Mac using the command below:

xcodebuild -showsdks

## Build

In the ios directory, run:
./build.sh [ iPhoneOS armv7 | iPhoneOS armv7s | iPhoneOS arm64 | iPhoneSimulator i386 | iPhoneSimulator x86_64 ]

Note that certain target architectures may or may not be available depending on your target SDK Version. For example, iOS 10 is the maximum deployment target for 32-bit targets.

[This website](https://docs.elementscompiler.com/Platforms/Cocoa/CpuArchitectures/) can help you choose which architecture you need to target depending on your SDK version.
70 changes: 70 additions & 0 deletions builds/ios/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

set -e

function usage {
echo "Usage ./build.sh [ iPhoneOS armv7 | iPhoneOS armv7s | iPhoneOS arm64 | iPhoneSimulator i386 | iPhoneSimulator x86_64 ]"
}

PLATFORM=$1
if [ -z PLATFORM ]; then
usage
exit 1
fi

if [[ $PLATFORM == "iPhoneOS" ]]; then
SDK="iphoneos"
elif [[ $PLATFORM == "iPhoneSimulator" ]]; then
SDK="iphonesimulator"
else
echo "Unknown platform '$PLATFORM'"
usage
exit 1
fi

TARGET=$2
if [ -z $TARGET ]; then
usage
exit 1
fi

if [[ $TARGET == "x86_64" ]]; then
HOST="i386"
elif [[ $TARGET == "arm64" ]]; then
HOST="arm"
else
HOST=$TARGET
fi

export SDK_VERSION=${SDK_VERSION:-"15.5"}

PLATFORM_PATH="/Applications/Xcode.app/Contents/Developer/Platforms"
TOOLCHAIN_PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
SYSROOT=$PLATFORM_PATH/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDK_VERSION.sdk
OUTPUT_DIR=output/$PLATFORM/$TARGET
PWD="$(pwd)"

export CC="$(xcrun -sdk $SDK -find clang)"
export CPP="$CC -E"
export AR="$(xcrun -sdk $SDK -find ar)"
export RANLIB="$(xcrun -sdk $SDK -find ranlib)"
export CFLAGS="-arch $TARGET -isysroot $SYSROOT -miphoneos-version-min=$SDK_VERSION -fembed-bitcode"
export CPPFLAGS="-arch $TARGET -isysroot $SYSROOT -miphoneos-version-min=$SDK_VERSION -fembed-bitcode"
export LDFLAGS="-arch $TARGET -isysroot $SYSROOT"

cd ../../
mkdir -p $OUTPUT_DIR
./autogen.sh
./configure --prefix="$PWD/$OUTPUT_DIR" --host=$HOST-apple-darwin
make
make install

echo "$PLATFORM $TARGET build successful"
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
16 changes: 16 additions & 0 deletions builds/ios/ci_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

#./build.sh "iPhoneOS" "armv7" # Only available with SDK_VERSION <= 10
#./build.sh "iPhoneOS" "armv7s" # Only available with SDK_VERSION <= 10
./build.sh "iPhoneOS" "arm64"
#./build.sh "iPhoneSimulator" "i386" # Only available with SDK_VERSION <= 10
./build.sh "iPhoneSimulator" "x86_64"

################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

0 comments on commit 2da939b

Please sign in to comment.