Add iOS support (#65)
This commit is contained in:
12
.gitignore
vendored
12
.gitignore
vendored
@@ -21,3 +21,15 @@ run-zh.sh
|
|||||||
decode-file-c-api
|
decode-file-c-api
|
||||||
run-decode-file-c-api.sh
|
run-decode-file-c-api.sh
|
||||||
sherpa-onnx-ffmpeg
|
sherpa-onnx-ffmpeg
|
||||||
|
build-ios
|
||||||
|
build-swift-macos
|
||||||
|
aa.sh
|
||||||
|
client-2.sh
|
||||||
|
ffmpeg-examples/run-3.sh
|
||||||
|
python-api-examples/decode-file-multiple-bak-2.py
|
||||||
|
run-en-zipformer-microphone*
|
||||||
|
run-websocket-server*
|
||||||
|
decode-file
|
||||||
|
*.dylib
|
||||||
|
tokens.txt
|
||||||
|
*.onnx
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="RUNNING_DEVICE_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="SERIAL_NUMBER" />
|
|
||||||
<value value="50e6c115" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</runningDeviceTargetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2023-02-23T09:59:16.822185Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
1
android/SherpaOnnx/.idea/gradle.xml
generated
1
android/SherpaOnnx/.idea/gradle.xml
generated
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|||||||
158
build-ios.sh
Executable file
158
build-ios.sh
Executable file
@@ -0,0 +1,158 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
dir=build-ios
|
||||||
|
mkdir -p $dir
|
||||||
|
cd $dir
|
||||||
|
|
||||||
|
if [ ! -f ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a ]; then
|
||||||
|
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/ios-onnxruntime
|
||||||
|
pushd ios-onnxruntime
|
||||||
|
git lfs pull --include onnxruntime.xcframework/ios-arm64/onnxruntime.a
|
||||||
|
git lfs pull --include onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check filesize
|
||||||
|
filesize=$(ls -l ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a | tr -s " " " " | cut -d " " -f 5)
|
||||||
|
if (( $filesize < 1000 )); then
|
||||||
|
ls -lh ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a
|
||||||
|
echo "Please use: git lfs pull to download ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64/onnxruntime.a"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filesize=$(ls -l ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a | tr -s " " " " | cut -d " " -f 5)
|
||||||
|
if (( $filesize < 1000 )); then
|
||||||
|
ls -lh ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a
|
||||||
|
echo "Please use: git lfs pull to download ./ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator/onnxruntime.a"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# First, for simulator
|
||||||
|
echo "Building for simulator (x86_64)"
|
||||||
|
|
||||||
|
export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64_x86_64-simulator
|
||||||
|
export SHERPA_ONNXRUNTIME_INCLUDE_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/Headers
|
||||||
|
|
||||||
|
echo "SHERPA_ONNXRUNTIME_LIB_DIR: $SHERPA_ONNXRUNTIME_LIB_DIR"
|
||||||
|
echo "SHERPA_ONNXRUNTIME_INCLUDE_DIR $SHERPA_ONNXRUNTIME_INCLUDE_DIR"
|
||||||
|
|
||||||
|
# Note: We use -DENABLE_ARC=1 here to fix the linking error:
|
||||||
|
#
|
||||||
|
# The symbol _NSLog is not defined
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-S .. \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \
|
||||||
|
-DPLATFORM=SIMULATOR64 \
|
||||||
|
-DENABLE_BITCODE=0 \
|
||||||
|
-DENABLE_ARC=1 \
|
||||||
|
-DENABLE_VISIBILITY=0 \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_JNI=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_C_API=ON \
|
||||||
|
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||||
|
-DDEPLOYMENT_TARGET=13.0 \
|
||||||
|
-B build/simulator_x86_64
|
||||||
|
|
||||||
|
cmake --build build/simulator_x86_64 -j 4 --verbose
|
||||||
|
|
||||||
|
echo "Building for simulator (arm64)"
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-S .. \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \
|
||||||
|
-DPLATFORM=SIMULATORARM64 \
|
||||||
|
-DENABLE_BITCODE=0 \
|
||||||
|
-DENABLE_ARC=1 \
|
||||||
|
-DENABLE_VISIBILITY=0 \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=./install \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_JNI=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_C_API=ON \
|
||||||
|
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||||
|
-DDEPLOYMENT_TARGET=13.0 \
|
||||||
|
-B build/simulator_arm64
|
||||||
|
|
||||||
|
cmake --build build/simulator_arm64 -j 4 --verbose
|
||||||
|
|
||||||
|
echo "Building for arm64"
|
||||||
|
|
||||||
|
export SHERPA_ONNXRUNTIME_LIB_DIR=$PWD/ios-onnxruntime/onnxruntime.xcframework/ios-arm64
|
||||||
|
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-S .. \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=./toolchains/ios.toolchain.cmake \
|
||||||
|
-DPLATFORM=OS64 \
|
||||||
|
-DENABLE_BITCODE=0 \
|
||||||
|
-DENABLE_ARC=1 \
|
||||||
|
-DENABLE_VISIBILITY=0 \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=./install \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_JNI=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_C_API=ON \
|
||||||
|
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||||
|
-DDEPLOYMENT_TARGET=13.0 \
|
||||||
|
-B build/os64
|
||||||
|
|
||||||
|
cmake --build build/os64 -j 4
|
||||||
|
# Generate headers for sherpa-onnx.xcframework
|
||||||
|
cmake --build build/os64 --target install
|
||||||
|
|
||||||
|
echo "Generate xcframework"
|
||||||
|
|
||||||
|
mkdir -p "build/simulator/lib"
|
||||||
|
for f in libkaldi-native-fbank-core.a libsherpa-onnx-c-api.a libsherpa-onnx-core.a; do
|
||||||
|
lipo -create build/simulator_arm64/lib/${f} \
|
||||||
|
build/simulator_x86_64/lib/${f} \
|
||||||
|
-output build/simulator/lib/${f}
|
||||||
|
done
|
||||||
|
|
||||||
|
# Merge archive first, because the following xcodebuild create xcframework
|
||||||
|
# cannot accept multi archive with the same architecture.
|
||||||
|
libtool -static -o build/simulator/sherpa-onnx.a \
|
||||||
|
build/simulator/lib/libkaldi-native-fbank-core.a \
|
||||||
|
build/simulator/lib/libsherpa-onnx-c-api.a \
|
||||||
|
build/simulator/lib/libsherpa-onnx-core.a
|
||||||
|
|
||||||
|
libtool -static -o build/os64/sherpa-onnx.a \
|
||||||
|
build/os64/lib/libkaldi-native-fbank-core.a \
|
||||||
|
build/os64/lib/libsherpa-onnx-c-api.a \
|
||||||
|
build/os64/lib/libsherpa-onnx-core.a
|
||||||
|
|
||||||
|
|
||||||
|
rm -rf sherpa-onnx.xcframework
|
||||||
|
|
||||||
|
xcodebuild -create-xcframework \
|
||||||
|
-library "build/os64/sherpa-onnx.a" \
|
||||||
|
-library "build/simulator/sherpa-onnx.a" \
|
||||||
|
-output sherpa-onnx.xcframework
|
||||||
|
|
||||||
|
# Copy Headers
|
||||||
|
mkdir -p sherpa-onnx.xcframework/Headers
|
||||||
|
cp -av install/include/* sherpa-onnx.xcframework/Headers
|
||||||
|
|
||||||
|
pushd sherpa-onnx.xcframework/ios-arm64_x86_64-simulator
|
||||||
|
ln -s sherpa-onnx.a libsherpa-onnx.a
|
||||||
|
popd
|
||||||
|
|
||||||
|
pushd sherpa-onnx.xcframework/ios-arm64
|
||||||
|
ln -s sherpa-onnx.a libsherpa-onnx.a
|
||||||
29
build-swift-macos.sh
Executable file
29
build-swift-macos.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
dir=build-swift-macos
|
||||||
|
mkdir -p $dir
|
||||||
|
cd $dir
|
||||||
|
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=./install \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_JNI=OFF \
|
||||||
|
-DSHERPA_ONNX_ENABLE_C_API=ON \
|
||||||
|
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
|
||||||
|
../
|
||||||
|
|
||||||
|
make VERBOSE=1 -j4
|
||||||
|
make install
|
||||||
|
|
||||||
|
libtool -static -o ./install/lib/libsherpa-onnx.a \
|
||||||
|
./install/lib/libsherpa-onnx-c-api.a \
|
||||||
|
./install/lib/libsherpa-onnx-core.a \
|
||||||
|
./install/lib/libkaldi-native-fbank-core.a
|
||||||
@@ -134,7 +134,7 @@ endfunction()
|
|||||||
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
|
||||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
|
||||||
if(ANDROID)
|
if(DEFINED ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
|
||||||
set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
|
set(location_onnxruntime_header_dir $ENV{SHERPA_ONNXRUNTIME_INCLUDE_DIR})
|
||||||
else()
|
else()
|
||||||
find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h
|
find_path(location_onnxruntime_header_dir onnxruntime_cxx_api.h
|
||||||
@@ -146,8 +146,11 @@ endif()
|
|||||||
|
|
||||||
message(STATUS "location_onnxruntime_header_dir: ${location_onnxruntime_header_dir}")
|
message(STATUS "location_onnxruntime_header_dir: ${location_onnxruntime_header_dir}")
|
||||||
|
|
||||||
if(ANDROID)
|
if(DEFINED ENV{SHERPA_ONNXRUNTIME_LIB_DIR})
|
||||||
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so)
|
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.so)
|
||||||
|
if(NOT EXISTS ${location_onnxruntime_lib})
|
||||||
|
set(location_onnxruntime_lib $ENV{SHERPA_ONNXRUNTIME_LIB_DIR}/libonnxruntime.a)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
find_library(location_onnxruntime_lib onnxruntime
|
find_library(location_onnxruntime_lib onnxruntime
|
||||||
PATHS
|
PATHS
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ ifeq ($(GDB), TRUE)
|
|||||||
OPTFLAG += -g
|
OPTFLAG += -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG}
|
# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG}
|
||||||
|
CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 ${OPTFLAG}
|
||||||
LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS))
|
LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS))
|
||||||
|
|
||||||
CUR_DIR :=$(shell pwd)
|
CUR_DIR :=$(shell pwd)
|
||||||
|
|||||||
635
ios-swift/SherpaOnnx/SherpaOnnx.xcodeproj/project.pbxproj
Normal file
635
ios-swift/SherpaOnnx/SherpaOnnx.xcodeproj/project.pbxproj
Normal file
@@ -0,0 +1,635 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 56;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
C984A7E829A9EEB700D74C52 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7E729A9EEB700D74C52 /* AppDelegate.swift */; };
|
||||||
|
C984A7EA29A9EEB700D74C52 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */; };
|
||||||
|
C984A7F129A9EEB900D74C52 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C984A7F029A9EEB900D74C52 /* Assets.xcassets */; };
|
||||||
|
C984A7F429A9EEB900D74C52 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */; };
|
||||||
|
C984A7FF29A9EEBA00D74C52 /* SherpaOnnxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */; };
|
||||||
|
C984A80929A9EEBA00D74C52 /* SherpaOnnxUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */; };
|
||||||
|
C984A80B29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */; };
|
||||||
|
C984A81929AA119400D74C52 /* SherpaOnnx.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A81829AA119400D74C52 /* SherpaOnnx.swift */; };
|
||||||
|
C984A82829AA196100D74C52 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C984A82629AA196100D74C52 /* Main.storyboard */; };
|
||||||
|
C984A82A29AA19AC00D74C52 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A82929AA19AC00D74C52 /* Model.swift */; };
|
||||||
|
C984A83C29AA430B00D74C52 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C984A83B29AA430B00D74C52 /* ViewController.swift */; };
|
||||||
|
C984A83D29AA43D900D74C52 /* sherpa-onnx.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */; };
|
||||||
|
C984A83F29AA43EE00D74C52 /* onnxruntime.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
C984A7FB29A9EEBA00D74C52 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = C984A7DC29A9EEB700D74C52 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = C984A7E329A9EEB700D74C52;
|
||||||
|
remoteInfo = SherpaOnnx;
|
||||||
|
};
|
||||||
|
C984A80529A9EEBA00D74C52 /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = C984A7DC29A9EEB700D74C52 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = C984A7E329A9EEB700D74C52;
|
||||||
|
remoteInfo = SherpaOnnx;
|
||||||
|
};
|
||||||
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SherpaOnnx.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
C984A7E729A9EEB700D74C52 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
C984A7F029A9EEB900D74C52 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
C984A7F329A9EEB900D74C52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
|
C984A7F529A9EEB900D74C52 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SherpaOnnxTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxTests.swift; sourceTree = "<group>"; };
|
||||||
|
C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SherpaOnnxUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITests.swift; sourceTree = "<group>"; };
|
||||||
|
C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SherpaOnnxUITestsLaunchTests.swift; sourceTree = "<group>"; };
|
||||||
|
C984A81729A9F51B00D74C52 /* SherpaOnnx-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "SherpaOnnx-Bridging-Header.h"; path = "../../../swift-api-examples/SherpaOnnx-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
|
C984A81829AA119400D74C52 /* SherpaOnnx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SherpaOnnx.swift; path = "../../../swift-api-examples/SherpaOnnx.swift"; sourceTree = "<group>"; };
|
||||||
|
C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "sherpa-onnx.xcframework"; path = "../../build-ios/sherpa-onnx.xcframework"; sourceTree = "<group>"; };
|
||||||
|
C984A82029AA139600D74C52 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/onnxruntime.xcframework"; sourceTree = "<group>"; };
|
||||||
|
C984A82729AA196100D74C52 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
|
C984A82929AA19AC00D74C52 /* Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = "<group>"; };
|
||||||
|
C984A83B29AA430B00D74C52 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||||
|
C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = onnxruntime.xcframework; path = "../../build-ios/ios-onnxruntime/onnxruntime.xcframework"; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
C984A7E129A9EEB700D74C52 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C984A83F29AA43EE00D74C52 /* onnxruntime.xcframework in Frameworks */,
|
||||||
|
C984A83D29AA43D900D74C52 /* sherpa-onnx.xcframework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A7F729A9EEBA00D74C52 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A80129A9EEBA00D74C52 /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
C984A7DB29A9EEB700D74C52 = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A7E629A9EEB700D74C52 /* SherpaOnnx */,
|
||||||
|
C984A7FD29A9EEBA00D74C52 /* SherpaOnnxTests */,
|
||||||
|
C984A80729A9EEBA00D74C52 /* SherpaOnnxUITests */,
|
||||||
|
C984A7E529A9EEB700D74C52 /* Products */,
|
||||||
|
C984A81A29AA11C500D74C52 /* Frameworks */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A7E529A9EEB700D74C52 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */,
|
||||||
|
C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */,
|
||||||
|
C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A7E629A9EEB700D74C52 /* SherpaOnnx */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A83B29AA430B00D74C52 /* ViewController.swift */,
|
||||||
|
C984A82929AA19AC00D74C52 /* Model.swift */,
|
||||||
|
C984A81829AA119400D74C52 /* SherpaOnnx.swift */,
|
||||||
|
C984A81729A9F51B00D74C52 /* SherpaOnnx-Bridging-Header.h */,
|
||||||
|
C984A7E729A9EEB700D74C52 /* AppDelegate.swift */,
|
||||||
|
C984A7E929A9EEB700D74C52 /* SceneDelegate.swift */,
|
||||||
|
C984A82629AA196100D74C52 /* Main.storyboard */,
|
||||||
|
C984A7F029A9EEB900D74C52 /* Assets.xcassets */,
|
||||||
|
C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */,
|
||||||
|
C984A7F529A9EEB900D74C52 /* Info.plist */,
|
||||||
|
);
|
||||||
|
path = SherpaOnnx;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A7FD29A9EEBA00D74C52 /* SherpaOnnxTests */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A7FE29A9EEBA00D74C52 /* SherpaOnnxTests.swift */,
|
||||||
|
);
|
||||||
|
path = SherpaOnnxTests;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A80729A9EEBA00D74C52 /* SherpaOnnxUITests */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A80829A9EEBA00D74C52 /* SherpaOnnxUITests.swift */,
|
||||||
|
C984A80A29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift */,
|
||||||
|
);
|
||||||
|
path = SherpaOnnxUITests;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A81A29AA11C500D74C52 /* Frameworks */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
C984A82029AA139600D74C52 /* onnxruntime.xcframework */,
|
||||||
|
C984A83E29AA43EE00D74C52 /* onnxruntime.xcframework */,
|
||||||
|
C984A81B29AA11C500D74C52 /* sherpa-onnx.xcframework */,
|
||||||
|
);
|
||||||
|
name = Frameworks;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
C984A7E329A9EEB700D74C52 /* SherpaOnnx */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C984A80E29A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnx" */;
|
||||||
|
buildPhases = (
|
||||||
|
C984A7E029A9EEB700D74C52 /* Sources */,
|
||||||
|
C984A7E129A9EEB700D74C52 /* Frameworks */,
|
||||||
|
C984A7E229A9EEB700D74C52 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = SherpaOnnx;
|
||||||
|
productName = SherpaOnnx;
|
||||||
|
productReference = C984A7E429A9EEB700D74C52 /* SherpaOnnx.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
C984A7F929A9EEBA00D74C52 /* SherpaOnnxTests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C984A81129A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxTests" */;
|
||||||
|
buildPhases = (
|
||||||
|
C984A7F629A9EEBA00D74C52 /* Sources */,
|
||||||
|
C984A7F729A9EEBA00D74C52 /* Frameworks */,
|
||||||
|
C984A7F829A9EEBA00D74C52 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
C984A7FC29A9EEBA00D74C52 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = SherpaOnnxTests;
|
||||||
|
productName = SherpaOnnxTests;
|
||||||
|
productReference = C984A7FA29A9EEBA00D74C52 /* SherpaOnnxTests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.unit-test";
|
||||||
|
};
|
||||||
|
C984A80329A9EEBA00D74C52 /* SherpaOnnxUITests */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = C984A81429A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxUITests" */;
|
||||||
|
buildPhases = (
|
||||||
|
C984A80029A9EEBA00D74C52 /* Sources */,
|
||||||
|
C984A80129A9EEBA00D74C52 /* Frameworks */,
|
||||||
|
C984A80229A9EEBA00D74C52 /* Resources */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
C984A80629A9EEBA00D74C52 /* PBXTargetDependency */,
|
||||||
|
);
|
||||||
|
name = SherpaOnnxUITests;
|
||||||
|
productName = SherpaOnnxUITests;
|
||||||
|
productReference = C984A80429A9EEBA00D74C52 /* SherpaOnnxUITests.xctest */;
|
||||||
|
productType = "com.apple.product-type.bundle.ui-testing";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
C984A7DC29A9EEB700D74C52 /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastSwiftUpdateCheck = 1420;
|
||||||
|
LastUpgradeCheck = 1420;
|
||||||
|
TargetAttributes = {
|
||||||
|
C984A7E329A9EEB700D74C52 = {
|
||||||
|
CreatedOnToolsVersion = 14.2;
|
||||||
|
};
|
||||||
|
C984A7F929A9EEBA00D74C52 = {
|
||||||
|
CreatedOnToolsVersion = 14.2;
|
||||||
|
TestTargetID = C984A7E329A9EEB700D74C52;
|
||||||
|
};
|
||||||
|
C984A80329A9EEBA00D74C52 = {
|
||||||
|
CreatedOnToolsVersion = 14.2;
|
||||||
|
TestTargetID = C984A7E329A9EEB700D74C52;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = C984A7DF29A9EEB700D74C52 /* Build configuration list for PBXProject "SherpaOnnx" */;
|
||||||
|
compatibilityVersion = "Xcode 14.0";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = C984A7DB29A9EEB700D74C52;
|
||||||
|
productRefGroup = C984A7E529A9EEB700D74C52 /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
C984A7E329A9EEB700D74C52 /* SherpaOnnx */,
|
||||||
|
C984A7F929A9EEBA00D74C52 /* SherpaOnnxTests */,
|
||||||
|
C984A80329A9EEBA00D74C52 /* SherpaOnnxUITests */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
C984A7E229A9EEB700D74C52 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C984A82829AA196100D74C52 /* Main.storyboard in Resources */,
|
||||||
|
C984A7F429A9EEB900D74C52 /* LaunchScreen.storyboard in Resources */,
|
||||||
|
C984A7F129A9EEB900D74C52 /* Assets.xcassets in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A7F829A9EEBA00D74C52 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A80229A9EEBA00D74C52 /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
C984A7E029A9EEB700D74C52 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C984A83C29AA430B00D74C52 /* ViewController.swift in Sources */,
|
||||||
|
C984A82A29AA19AC00D74C52 /* Model.swift in Sources */,
|
||||||
|
C984A81929AA119400D74C52 /* SherpaOnnx.swift in Sources */,
|
||||||
|
C984A7E829A9EEB700D74C52 /* AppDelegate.swift in Sources */,
|
||||||
|
C984A7EA29A9EEB700D74C52 /* SceneDelegate.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A7F629A9EEBA00D74C52 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C984A7FF29A9EEBA00D74C52 /* SherpaOnnxTests.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
C984A80029A9EEBA00D74C52 /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
C984A80B29A9EEBA00D74C52 /* SherpaOnnxUITestsLaunchTests.swift in Sources */,
|
||||||
|
C984A80929A9EEBA00D74C52 /* SherpaOnnxUITests.swift in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXTargetDependency section */
|
||||||
|
C984A7FC29A9EEBA00D74C52 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = C984A7E329A9EEB700D74C52 /* SherpaOnnx */;
|
||||||
|
targetProxy = C984A7FB29A9EEBA00D74C52 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
C984A80629A9EEBA00D74C52 /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = C984A7E329A9EEB700D74C52 /* SherpaOnnx */;
|
||||||
|
targetProxy = C984A80529A9EEBA00D74C52 /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
C984A7F229A9EEB900D74C52 /* LaunchScreen.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
C984A7F329A9EEB900D74C52 /* Base */,
|
||||||
|
);
|
||||||
|
name = LaunchScreen.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
C984A82629AA196100D74C52 /* Main.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
C984A82729AA196100D74C52 /* Base */,
|
||||||
|
);
|
||||||
|
name = Main.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
C984A80C29A9EEBA00D74C52 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C984A80D29A9EEBA00D74C52 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C984A80F29A9EEBA00D74C52 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers/";
|
||||||
|
INFOPLIST_FILE = SherpaOnnx/Info.plist;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||||
|
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
OTHER_LDFLAGS = "-lc++";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C984A81029A9EEBA00D74C52 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
HEADER_SEARCH_PATHS = "${PROJECT_DIR}/../../build-ios/sherpa-onnx.xcframework/Headers/";
|
||||||
|
INFOPLIST_FILE = SherpaOnnx/Info.plist;
|
||||||
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
|
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||||
|
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
OTHER_LDFLAGS = "-lc++";
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnx";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "${PROJECT_DIR}/../../swift-api-examples/SherpaOnnx-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C984A81229A9EEBA00D74C52 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SherpaOnnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/SherpaOnnx";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C984A81329A9EEBA00D74C52 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxTests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SherpaOnnx.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/SherpaOnnx";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
C984A81529A9EEBA00D74C52 /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxUITests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = SherpaOnnx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
C984A81629A9EEBA00D74C52 /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
MARKETING_VERSION = 1.0;
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = "com.k2-fsa.org.SherpaOnnxUITests";
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
TEST_TARGET_NAME = SherpaOnnx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
C984A7DF29A9EEB700D74C52 /* Build configuration list for PBXProject "SherpaOnnx" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C984A80C29A9EEBA00D74C52 /* Debug */,
|
||||||
|
C984A80D29A9EEBA00D74C52 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C984A80E29A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnx" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C984A80F29A9EEBA00D74C52 /* Debug */,
|
||||||
|
C984A81029A9EEBA00D74C52 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C984A81129A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxTests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C984A81229A9EEBA00D74C52 /* Debug */,
|
||||||
|
C984A81329A9EEBA00D74C52 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
C984A81429A9EEBA00D74C52 /* Build configuration list for PBXNativeTarget "SherpaOnnxUITests" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
C984A81529A9EEBA00D74C52 /* Debug */,
|
||||||
|
C984A81629A9EEBA00D74C52 /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = C984A7DC29A9EEB700D74C52 /* Project object */;
|
||||||
|
}
|
||||||
7
ios-swift/SherpaOnnx/SherpaOnnx.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
ios-swift/SherpaOnnx/SherpaOnnx.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>SherpaOnnx.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
36
ios-swift/SherpaOnnx/SherpaOnnx/AppDelegate.swift
Normal file
36
ios-swift/SherpaOnnx/SherpaOnnx/AppDelegate.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// AppDelegate.swift
|
||||||
|
// SherpaOnnx
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/2/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
@main
|
||||||
|
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
// Override point for customization after application launch.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: UISceneSession Lifecycle
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||||
|
// Called when a new scene session is being created.
|
||||||
|
// Use this method to select a configuration to create the new scene with.
|
||||||
|
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||||
|
}
|
||||||
|
|
||||||
|
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||||
|
// Called when the user discards a scene session.
|
||||||
|
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||||
|
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"colors" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "k2-1024x1024.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"platform" : "ios",
|
||||||
|
"size" : "1024x1024"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 411 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
60
ios-swift/SherpaOnnx/SherpaOnnx/Base.lproj/Main.storyboard
Normal file
60
ios-swift/SherpaOnnx/SherpaOnnx/Base.lproj/Main.storyboard
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||||
|
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="tne-QT-ifu">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="SherpaNcnn" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7q8-Y3-WbJ">
|
||||||
|
<rect key="frame" x="166" y="773" width="61.333333333333343" height="35"/>
|
||||||
|
<state key="normal" title="Button"/>
|
||||||
|
<buttonConfiguration key="configuration" style="plain" title="Start"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="onRecordBtnClick:" destination="BYZ-38-t0r" eventType="touchUpInside" id="rS6-DT-XWm"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jfS-7J-m9C">
|
||||||
|
<rect key="frame" x="8" y="67" width="377" height="20.333333333333329"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="jfS-7J-m9C" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="8" id="HX3-rI-U9E"/>
|
||||||
|
<constraint firstItem="jfS-7J-m9C" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="8" id="NEv-PD-DHj"/>
|
||||||
|
<constraint firstItem="7q8-Y3-WbJ" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="Nha-gf-R2b"/>
|
||||||
|
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="jfS-7J-m9C" secondAttribute="trailing" constant="8" id="P2f-hG-O2e"/>
|
||||||
|
<constraint firstAttribute="bottomMargin" secondItem="7q8-Y3-WbJ" secondAttribute="bottom" constant="10" id="Pgb-4G-ySa"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="recordBtn" destination="7q8-Y3-WbJ" id="mFd-cu-zjn"/>
|
||||||
|
<outlet property="resultLabel" destination="jfS-7J-m9C" id="xQU-ID-m5Q"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="32.824427480916029" y="3.5211267605633805"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<systemColor name="systemBackgroundColor">
|
||||||
|
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
</systemColor>
|
||||||
|
</resources>
|
||||||
|
</document>
|
||||||
27
ios-swift/SherpaOnnx/SherpaOnnx/Info.plist
Normal file
27
ios-swift/SherpaOnnx/SherpaOnnx/Info.plist
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>Need microphone access for Next-gen Kaldi to work</string>
|
||||||
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIApplicationSupportsMultipleScenes</key>
|
||||||
|
<false/>
|
||||||
|
<key>UISceneConfigurations</key>
|
||||||
|
<dict>
|
||||||
|
<key>UIWindowSceneSessionRoleApplication</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UISceneConfigurationName</key>
|
||||||
|
<string>Default Configuration</string>
|
||||||
|
<key>UISceneDelegateClassName</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||||
|
<key>UISceneStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
35
ios-swift/SherpaOnnx/SherpaOnnx/Model.swift
Normal file
35
ios-swift/SherpaOnnx/SherpaOnnx/Model.swift
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
func getResource(_ forResource: String, _ ofType: String) -> String {
|
||||||
|
let path = Bundle.main.path(forResource: forResource, ofType: ofType)
|
||||||
|
precondition(
|
||||||
|
path != nil,
|
||||||
|
"\(forResource).\(ofType) does not exist!\n" + "Remember to change \n"
|
||||||
|
+ " Build Phases -> Copy Bundle Resources\n" + "to add it!"
|
||||||
|
)
|
||||||
|
return path!
|
||||||
|
}
|
||||||
|
/// Please refer to
|
||||||
|
/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||||
|
/// to download pre-trained models
|
||||||
|
|
||||||
|
/// sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 (Bilingual, Chinese + English)
|
||||||
|
/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/zipformer-transducer-models.html
|
||||||
|
func getBilingualStreamZhEnZipformer20230220() -> SherpaOnnxOnlineTransducerModelConfig {
|
||||||
|
let encoder = getResource("encoder-epoch-99-avg-1", "onnx")
|
||||||
|
let decoder = getResource("decoder-epoch-99-avg-1", "onnx")
|
||||||
|
let joiner = getResource("joiner-epoch-99-avg-1", "onnx")
|
||||||
|
let tokens = getResource("tokens", "txt")
|
||||||
|
|
||||||
|
return sherpaOnnxOnlineTransducerModelConfig(
|
||||||
|
encoder: encoder,
|
||||||
|
decoder: decoder,
|
||||||
|
joiner: joiner,
|
||||||
|
tokens: tokens,
|
||||||
|
numThreads: 2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Please refer to
|
||||||
|
/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||||
|
/// to add more models if you need
|
||||||
52
ios-swift/SherpaOnnx/SherpaOnnx/SceneDelegate.swift
Normal file
52
ios-swift/SherpaOnnx/SherpaOnnx/SceneDelegate.swift
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// SceneDelegate.swift
|
||||||
|
// SherpaOnnx
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/2/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||||
|
|
||||||
|
var window: UIWindow?
|
||||||
|
|
||||||
|
|
||||||
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||||
|
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||||
|
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||||
|
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||||
|
guard let _ = (scene as? UIWindowScene) else { return }
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidDisconnect(_ scene: UIScene) {
|
||||||
|
// Called as the scene is being released by the system.
|
||||||
|
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||||
|
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||||
|
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene has moved from an inactive state to an active state.
|
||||||
|
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillResignActive(_ scene: UIScene) {
|
||||||
|
// Called when the scene will move from an active state to an inactive state.
|
||||||
|
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the background to the foreground.
|
||||||
|
// Use this method to undo the changes made on entering the background.
|
||||||
|
}
|
||||||
|
|
||||||
|
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||||
|
// Called as the scene transitions from the foreground to the background.
|
||||||
|
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||||
|
// to restore the scene back to its current state.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
197
ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift
Normal file
197
ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
//
|
||||||
|
// ViewController.swift
|
||||||
|
// SherpaOnnx
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/1/28.
|
||||||
|
//
|
||||||
|
|
||||||
|
import AVFoundation
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
extension AudioBuffer {
|
||||||
|
func array() -> [Float] {
|
||||||
|
return Array(UnsafeBufferPointer(self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AVAudioPCMBuffer {
|
||||||
|
func array() -> [Float] {
|
||||||
|
return self.audioBufferList.pointee.mBuffers.array()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewController: UIViewController {
|
||||||
|
@IBOutlet weak var resultLabel: UILabel!
|
||||||
|
@IBOutlet weak var recordBtn: UIButton!
|
||||||
|
|
||||||
|
var audioEngine: AVAudioEngine? = nil
|
||||||
|
var recognizer: SherpaOnnxRecognizer! = nil
|
||||||
|
|
||||||
|
/// It saves the decoded results so far
|
||||||
|
var sentences: [String] = [] {
|
||||||
|
didSet {
|
||||||
|
updateLabel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var lastSentence: String = ""
|
||||||
|
let maxSentence: Int = 20
|
||||||
|
var results: String {
|
||||||
|
if sentences.isEmpty && lastSentence.isEmpty {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if sentences.isEmpty {
|
||||||
|
return "0: \(lastSentence.lowercased())"
|
||||||
|
}
|
||||||
|
|
||||||
|
let start = max(sentences.count - maxSentence, 0)
|
||||||
|
if lastSentence.isEmpty {
|
||||||
|
return sentences.enumerated().map { (index, s) in "\(index): \(s.lowercased())" }[start...]
|
||||||
|
.joined(separator: "\n")
|
||||||
|
} else {
|
||||||
|
return sentences.enumerated().map { (index, s) in "\(index): \(s.lowercased())" }[start...]
|
||||||
|
.joined(separator: "\n") + "\n\(sentences.count): \(lastSentence.lowercased())"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateLabel() {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.resultLabel.text = self.results
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
// Do any additional setup after loading the view.
|
||||||
|
|
||||||
|
resultLabel.text = "ASR with Next-gen Kaldi\n\nPress the Start button to run!"
|
||||||
|
recordBtn.setTitle("Start", for: .normal)
|
||||||
|
initRecognizer()
|
||||||
|
initRecorder()
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func onRecordBtnClick(_ sender: UIButton) {
|
||||||
|
if recordBtn.currentTitle == "Start" {
|
||||||
|
startRecorder()
|
||||||
|
recordBtn.setTitle("Stop", for: .normal)
|
||||||
|
} else {
|
||||||
|
stopRecorder()
|
||||||
|
recordBtn.setTitle("Start", for: .normal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func initRecognizer() {
|
||||||
|
// Please select one model that is best suitable for you.
|
||||||
|
//
|
||||||
|
// You can also modify Model.swift to add new pre-trained models from
|
||||||
|
// https://k2-fsa.github.io/sherpa/ncnn/pretrained_models/index.html
|
||||||
|
|
||||||
|
let modelConfig = getBilingualStreamZhEnZipformer20230220()
|
||||||
|
|
||||||
|
let featConfig = sherpaOnnxFeatureConfig(
|
||||||
|
sampleRate: 16000,
|
||||||
|
featureDim: 80)
|
||||||
|
|
||||||
|
var config = sherpaOnnxOnlineRecognizerConfig(
|
||||||
|
featConfig: featConfig,
|
||||||
|
modelConfig: modelConfig,
|
||||||
|
enableEndpoint: true,
|
||||||
|
rule1MinTrailingSilence: 2.4,
|
||||||
|
rule2MinTrailingSilence: 0.8,
|
||||||
|
rule3MinUtteranceLength: 30
|
||||||
|
)
|
||||||
|
recognizer = SherpaOnnxRecognizer(config: &config)
|
||||||
|
}
|
||||||
|
|
||||||
|
func initRecorder() {
|
||||||
|
print("init recorder")
|
||||||
|
audioEngine = AVAudioEngine()
|
||||||
|
let inputNode = self.audioEngine?.inputNode
|
||||||
|
let bus = 0
|
||||||
|
let inputFormat = inputNode?.outputFormat(forBus: bus)
|
||||||
|
let outputFormat = AVAudioFormat(
|
||||||
|
commonFormat: .pcmFormatFloat32,
|
||||||
|
sampleRate: 16000, channels: 1,
|
||||||
|
interleaved: false)!
|
||||||
|
|
||||||
|
let converter = AVAudioConverter(from: inputFormat!, to: outputFormat)!
|
||||||
|
|
||||||
|
inputNode!.installTap(
|
||||||
|
onBus: bus,
|
||||||
|
bufferSize: 1024,
|
||||||
|
format: inputFormat
|
||||||
|
) {
|
||||||
|
(buffer: AVAudioPCMBuffer, when: AVAudioTime) in
|
||||||
|
var newBufferAvailable = true
|
||||||
|
|
||||||
|
let inputCallback: AVAudioConverterInputBlock = {
|
||||||
|
inNumPackets, outStatus in
|
||||||
|
if newBufferAvailable {
|
||||||
|
outStatus.pointee = .haveData
|
||||||
|
newBufferAvailable = false
|
||||||
|
|
||||||
|
return buffer
|
||||||
|
} else {
|
||||||
|
outStatus.pointee = .noDataNow
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let convertedBuffer = AVAudioPCMBuffer(
|
||||||
|
pcmFormat: outputFormat,
|
||||||
|
frameCapacity:
|
||||||
|
AVAudioFrameCount(outputFormat.sampleRate)
|
||||||
|
* buffer.frameLength
|
||||||
|
/ AVAudioFrameCount(buffer.format.sampleRate))!
|
||||||
|
|
||||||
|
var error: NSError?
|
||||||
|
let _ = converter.convert(
|
||||||
|
to: convertedBuffer,
|
||||||
|
error: &error, withInputFrom: inputCallback)
|
||||||
|
|
||||||
|
// TODO(fangjun): Handle status != haveData
|
||||||
|
|
||||||
|
let array = convertedBuffer.array()
|
||||||
|
if !array.isEmpty {
|
||||||
|
self.recognizer.acceptWaveform(samples: array)
|
||||||
|
while (self.recognizer.isReady()){
|
||||||
|
self.recognizer.decode()
|
||||||
|
}
|
||||||
|
let isEndpoint = self.recognizer.isEndpoint()
|
||||||
|
let text = self.recognizer.getResult().text
|
||||||
|
|
||||||
|
if !text.isEmpty && self.lastSentence != text {
|
||||||
|
self.lastSentence = text
|
||||||
|
self.updateLabel()
|
||||||
|
print(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
if isEndpoint {
|
||||||
|
if !text.isEmpty {
|
||||||
|
let tmp = self.lastSentence
|
||||||
|
self.lastSentence = ""
|
||||||
|
self.sentences.append(tmp)
|
||||||
|
}
|
||||||
|
self.recognizer.reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func startRecorder() {
|
||||||
|
lastSentence = ""
|
||||||
|
sentences = []
|
||||||
|
|
||||||
|
do {
|
||||||
|
try self.audioEngine?.start()
|
||||||
|
} catch let error as NSError {
|
||||||
|
print("Got an error starting audioEngine: \(error.domain), \(error)")
|
||||||
|
}
|
||||||
|
print("started")
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopRecorder() {
|
||||||
|
audioEngine?.stop()
|
||||||
|
print("stopped")
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
ios-swift/SherpaOnnx/SherpaOnnx/k2-1024x1024.png
Normal file
BIN
ios-swift/SherpaOnnx/SherpaOnnx/k2-1024x1024.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 411 KiB |
36
ios-swift/SherpaOnnx/SherpaOnnxTests/SherpaOnnxTests.swift
Normal file
36
ios-swift/SherpaOnnx/SherpaOnnxTests/SherpaOnnxTests.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// SherpaOnnxTests.swift
|
||||||
|
// SherpaOnnxTests
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/2/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
@testable import SherpaOnnx
|
||||||
|
|
||||||
|
final class SherpaOnnxTests: XCTestCase {
|
||||||
|
|
||||||
|
override func setUpWithError() throws {
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDownWithError() throws {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testExample() throws {
|
||||||
|
// This is an example of a functional test case.
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
|
// Any test you write for XCTest can be annotated as throws and async.
|
||||||
|
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
|
||||||
|
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testPerformanceExample() throws {
|
||||||
|
// This is an example of a performance test case.
|
||||||
|
self.measure {
|
||||||
|
// Put the code you want to measure the time of here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// SherpaOnnxUITests.swift
|
||||||
|
// SherpaOnnxUITests
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/2/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
final class SherpaOnnxUITests: XCTestCase {
|
||||||
|
|
||||||
|
override func setUpWithError() throws {
|
||||||
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||||
|
|
||||||
|
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||||
|
continueAfterFailure = false
|
||||||
|
|
||||||
|
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDownWithError() throws {
|
||||||
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testExample() throws {
|
||||||
|
// UI tests must launch the application that they test.
|
||||||
|
let app = XCUIApplication()
|
||||||
|
app.launch()
|
||||||
|
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||||
|
}
|
||||||
|
|
||||||
|
func testLaunchPerformance() throws {
|
||||||
|
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
|
||||||
|
// This measures how long it takes to launch your application.
|
||||||
|
measure(metrics: [XCTApplicationLaunchMetric()]) {
|
||||||
|
XCUIApplication().launch()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// SherpaOnnxUITestsLaunchTests.swift
|
||||||
|
// SherpaOnnxUITests
|
||||||
|
//
|
||||||
|
// Created by fangjun on 2023/2/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
final class SherpaOnnxUITestsLaunchTests: XCTestCase {
|
||||||
|
|
||||||
|
override class var runsForEachTargetApplicationUIConfiguration: Bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
override func setUpWithError() throws {
|
||||||
|
continueAfterFailure = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func testLaunch() throws {
|
||||||
|
let app = XCUIApplication()
|
||||||
|
app.launch()
|
||||||
|
|
||||||
|
// Insert steps here to perform after app launch but before taking a screenshot,
|
||||||
|
// such as logging into a test account or navigating somewhere in the app
|
||||||
|
|
||||||
|
let attachment = XCTAttachment(screenshot: app.screenshot())
|
||||||
|
attachment.name = "Launch Screen"
|
||||||
|
attachment.lifetime = .keepAlways
|
||||||
|
add(attachment)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -160,14 +160,17 @@ class OnlineRecognizer::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Reset(OnlineStream *s) const {
|
void Reset(OnlineStream *s) const {
|
||||||
// reset result and neural network model state,
|
// reset result, neural network model state, and
|
||||||
// but keep the feature extractor state
|
// the feature extractor state
|
||||||
|
|
||||||
// reset result
|
// reset result
|
||||||
s->SetResult(decoder_->GetEmptyResult());
|
s->SetResult(decoder_->GetEmptyResult());
|
||||||
|
|
||||||
// reset neural network model state
|
// reset neural network model state
|
||||||
s->SetStates(model_->GetEncoderInitStates());
|
s->SetStates(model_->GetEncoderInitStates());
|
||||||
|
|
||||||
|
// reset feature extractor
|
||||||
|
s->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ class OnlineStream::Impl {
|
|||||||
return feat_extractor_.GetFrames(frame_index, n);
|
return feat_extractor_.GetFrames(frame_index, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset() { feat_extractor_.Reset(); }
|
void Reset() {
|
||||||
|
feat_extractor_.Reset();
|
||||||
|
num_processed_frames_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t &GetNumProcessedFrames() { return num_processed_frames_; }
|
int32_t &GetNumProcessedFrames() { return num_processed_frames_; }
|
||||||
|
|
||||||
|
|||||||
9
swift-api-examples/SherpaOnnx-Bridging-Header.h
Normal file
9
swift-api-examples/SherpaOnnx-Bridging-Header.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// swfit-api-examples/SherpaOnnx-Bridging-Header.h
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Xiaomi Corporation
|
||||||
|
#ifndef SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_
|
||||||
|
#define SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_
|
||||||
|
|
||||||
|
#import "sherpa-onnx/c-api/c-api.h"
|
||||||
|
|
||||||
|
#endif // SWIFT_API_EXAMPLES_SHERPAONNX_BRIDGING_HEADER_H_
|
||||||
171
swift-api-examples/SherpaOnnx.swift
Normal file
171
swift-api-examples/SherpaOnnx.swift
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/// swfit-api-examples/SherpaOnnx.swift
|
||||||
|
/// Copyright (c) 2023 Xiaomi Corporation
|
||||||
|
|
||||||
|
import Foundation // For NSString
|
||||||
|
|
||||||
|
/// Convert a String from swift to a `const char*` so that we can pass it to
|
||||||
|
/// the C language.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - s: The String to convert.
|
||||||
|
/// - Returns: A pointer that can be passed to C as `const char*`
|
||||||
|
|
||||||
|
func toCPointer(_ s: String) -> UnsafePointer<Int8>! {
|
||||||
|
let cs = (s as NSString).utf8String
|
||||||
|
return UnsafePointer<Int8>(cs)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return an instance of SherpaOnnxOnlineTransducerModelConfig.
|
||||||
|
///
|
||||||
|
/// Please refer to
|
||||||
|
/// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||||
|
/// to download the required `.onnx` files.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - encoder: Path to encoder.onnx
|
||||||
|
/// - decoder: Path to decoder.onnx
|
||||||
|
/// - joiner: Path to joiner.onnx
|
||||||
|
/// - tokens: Path to tokens.txt
|
||||||
|
/// - numThreads: Number of threads to use for neural network computation.
|
||||||
|
///
|
||||||
|
/// - Returns: Return an instance of SherpaOnnxOnlineTransducerModelConfig
|
||||||
|
func sherpaOnnxOnlineTransducerModelConfig(
|
||||||
|
encoder: String,
|
||||||
|
decoder: String,
|
||||||
|
joiner: String,
|
||||||
|
tokens: String,
|
||||||
|
numThreads: Int = 2,
|
||||||
|
debug: Int = 0
|
||||||
|
) -> SherpaOnnxOnlineTransducerModelConfig{
|
||||||
|
return SherpaOnnxOnlineTransducerModelConfig(
|
||||||
|
encoder: toCPointer(encoder),
|
||||||
|
decoder: toCPointer(decoder),
|
||||||
|
joiner: toCPointer(joiner),
|
||||||
|
tokens: toCPointer(tokens),
|
||||||
|
num_threads: Int32(numThreads),
|
||||||
|
debug: Int32(debug)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sherpaOnnxFeatureConfig(
|
||||||
|
sampleRate: Int = 16000,
|
||||||
|
featureDim: Int = 80
|
||||||
|
) -> SherpaOnnxFeatureConfig {
|
||||||
|
return SherpaOnnxFeatureConfig(
|
||||||
|
sample_rate: Int32(sampleRate),
|
||||||
|
feature_dim: Int32(featureDim))
|
||||||
|
}
|
||||||
|
|
||||||
|
func sherpaOnnxOnlineRecognizerConfig(
|
||||||
|
featConfig: SherpaOnnxFeatureConfig,
|
||||||
|
modelConfig: SherpaOnnxOnlineTransducerModelConfig,
|
||||||
|
enableEndpoint: Bool = false,
|
||||||
|
rule1MinTrailingSilence: Float = 2.4,
|
||||||
|
rule2MinTrailingSilence: Float = 1.2,
|
||||||
|
rule3MinUtteranceLength: Float = 30
|
||||||
|
) -> SherpaOnnxOnlineRecognizerConfig{
|
||||||
|
return SherpaOnnxOnlineRecognizerConfig(
|
||||||
|
feat_config: featConfig,
|
||||||
|
model_config: modelConfig,
|
||||||
|
enable_endpoint: enableEndpoint ? 1 : 0,
|
||||||
|
rule1_min_trailing_silence: rule1MinTrailingSilence,
|
||||||
|
rule2_min_trailing_silence: rule2MinTrailingSilence,
|
||||||
|
rule3_min_utterance_length: rule3MinUtteranceLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wrapper for recognition result.
|
||||||
|
///
|
||||||
|
/// Usage:
|
||||||
|
///
|
||||||
|
/// let result = recognizer.getResult()
|
||||||
|
/// print("text: \(result.text)")
|
||||||
|
///
|
||||||
|
class SherpaOnnxOnlineRecongitionResult {
|
||||||
|
/// A pointer to the underlying counterpart in C
|
||||||
|
let result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!
|
||||||
|
|
||||||
|
/// Return the actual recognition result.
|
||||||
|
/// For English models, it contains words separated by spaces.
|
||||||
|
/// For Chinese models, it contains Chinese words.
|
||||||
|
var text: String {
|
||||||
|
return String(cString: result.pointee.text)
|
||||||
|
}
|
||||||
|
|
||||||
|
init(result: UnsafePointer<SherpaOnnxOnlineRecognizerResult>!) {
|
||||||
|
self.result = result
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
if let result {
|
||||||
|
DestroyOnlineRecognizerResult(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SherpaOnnxRecognizer {
|
||||||
|
/// A pointer to the underlying counterpart in C
|
||||||
|
let recognizer: OpaquePointer!
|
||||||
|
let stream: OpaquePointer!
|
||||||
|
|
||||||
|
/// Constructor taking a model config and a decoder config.
|
||||||
|
init(
|
||||||
|
config: UnsafePointer<SherpaOnnxOnlineRecognizerConfig>!
|
||||||
|
) {
|
||||||
|
recognizer = CreateOnlineRecognizer(config)
|
||||||
|
stream = CreateOnlineStream(recognizer)
|
||||||
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
if let stream {
|
||||||
|
DestoryOnlineStream(stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
if let recognizer {
|
||||||
|
DestroyOnlineRecognizer(recognizer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decode wave samples.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - samples: Audio samples normalzed to the range [-1, 1]
|
||||||
|
/// - sampleRate: Sample rate of the input audio samples. Must match
|
||||||
|
/// the one expected by the model. It must be 16000 for
|
||||||
|
/// models from icefall.
|
||||||
|
func acceptWaveform(samples: [Float], sampleRate: Float = 16000) {
|
||||||
|
AcceptWaveform(stream, sampleRate, samples, Int32(samples.count))
|
||||||
|
}
|
||||||
|
|
||||||
|
func isReady() -> Bool {
|
||||||
|
return IsOnlineStreamReady(recognizer, stream) == 1 ? true : false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// If there are enough number of feature frames, it invokes the neural
|
||||||
|
/// network computation and decoding. Otherwise, it is a no-op.
|
||||||
|
func decode() {
|
||||||
|
DecodeOnlineStream(recognizer, stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the decoding results so far
|
||||||
|
func getResult() -> SherpaOnnxOnlineRecongitionResult {
|
||||||
|
let result: UnsafeMutablePointer<SherpaOnnxOnlineRecognizerResult>? = GetOnlineStreamResult(recognizer, stream)
|
||||||
|
return SherpaOnnxOnlineRecongitionResult(result: result)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reset the recognizer, which clears the neural network model state
|
||||||
|
/// and the state for decoding.
|
||||||
|
func reset() {
|
||||||
|
Reset(recognizer, stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Signal that no more audio samples would be available.
|
||||||
|
/// After this call, you cannot call acceptWaveform() any more.
|
||||||
|
func inputFinished() {
|
||||||
|
InputFinished(stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return true is an endpoint has been detected.
|
||||||
|
func isEndpoint() -> Bool {
|
||||||
|
return IsEndpoint(recognizer, stream) == 1 ? true : false
|
||||||
|
}
|
||||||
|
}
|
||||||
74
swift-api-examples/decode-file.swift
Normal file
74
swift-api-examples/decode-file.swift
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import AVFoundation
|
||||||
|
|
||||||
|
extension AudioBuffer {
|
||||||
|
func array() -> [Float] {
|
||||||
|
return Array(UnsafeBufferPointer(self))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension AVAudioPCMBuffer {
|
||||||
|
func array() -> [Float] {
|
||||||
|
return self.audioBufferList.pointee.mBuffers.array()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run() {
|
||||||
|
let encoder = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx"
|
||||||
|
let decoder = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx"
|
||||||
|
let joiner = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx"
|
||||||
|
let tokens = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/tokens.txt"
|
||||||
|
|
||||||
|
let modelConfig = sherpaOnnxOnlineTransducerModelConfig(
|
||||||
|
encoder: encoder,
|
||||||
|
decoder: decoder,
|
||||||
|
joiner: joiner,
|
||||||
|
tokens: tokens,
|
||||||
|
numThreads: 2)
|
||||||
|
|
||||||
|
let featConfig = sherpaOnnxFeatureConfig(
|
||||||
|
sampleRate: 16000,
|
||||||
|
featureDim: 80
|
||||||
|
)
|
||||||
|
var config = sherpaOnnxOnlineRecognizerConfig(
|
||||||
|
featConfig: featConfig,
|
||||||
|
modelConfig: modelConfig,
|
||||||
|
enableEndpoint: false
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
let recognizer = SherpaOnnxRecognizer(config: &config)
|
||||||
|
|
||||||
|
let filePath = "./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/test_wavs/1.wav"
|
||||||
|
let fileURL: NSURL = NSURL(fileURLWithPath: filePath)
|
||||||
|
let audioFile = try! AVAudioFile(forReading: fileURL as URL)
|
||||||
|
|
||||||
|
let audioFormat = audioFile.processingFormat
|
||||||
|
assert(audioFormat.sampleRate == 16000)
|
||||||
|
assert(audioFormat.channelCount == 1)
|
||||||
|
assert(audioFormat.commonFormat == AVAudioCommonFormat.pcmFormatFloat32)
|
||||||
|
|
||||||
|
let audioFrameCount = UInt32(audioFile.length)
|
||||||
|
let audioFileBuffer = AVAudioPCMBuffer(pcmFormat: audioFormat, frameCapacity: audioFrameCount)
|
||||||
|
|
||||||
|
try! audioFile.read(into: audioFileBuffer!)
|
||||||
|
let array: [Float]! = audioFileBuffer?.array()
|
||||||
|
recognizer.acceptWaveform(samples: array)
|
||||||
|
|
||||||
|
let tailPadding = [Float](repeating: 0.0, count: 3200)
|
||||||
|
recognizer.acceptWaveform(samples: tailPadding)
|
||||||
|
|
||||||
|
recognizer.inputFinished()
|
||||||
|
while (recognizer.isReady()) {
|
||||||
|
recognizer.decode()
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = recognizer.getResult()
|
||||||
|
print("\nresult is:\n\(result.text)")
|
||||||
|
}
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct App {
|
||||||
|
static func main() {
|
||||||
|
run()
|
||||||
|
}
|
||||||
|
}
|
||||||
36
swift-api-examples/run-decode-file.sh
Executable file
36
swift-api-examples/run-decode-file.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
if [ ! -d ../build-swift-macos ]; then
|
||||||
|
echo "Please run ../build-swift-macos.sh first!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
|
||||||
|
echo "Please download the pre-trained model for testing."
|
||||||
|
echo "You can refer to"
|
||||||
|
echo ""
|
||||||
|
echo "https://k2-fsa.github.io/sherpa/onnx/pretrained_models/zipformer-transducer-models.html#sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20-bilingual-chinese-english"
|
||||||
|
echo ""
|
||||||
|
echo "for help"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e ./decode-file ]; then
|
||||||
|
# Note: We use -lc++ to link against libc++ instead of libstdc++
|
||||||
|
swiftc \
|
||||||
|
-lc++ \
|
||||||
|
-I ../build-swift-macos/install/include \
|
||||||
|
-import-objc-header ./SherpaOnnx-Bridging-Header.h \
|
||||||
|
./decode-file.swift ./SherpaOnnx.swift \
|
||||||
|
-L ../build-swift-macos/install/lib/ \
|
||||||
|
-l sherpa-onnx \
|
||||||
|
-l onnxruntime \
|
||||||
|
-o decode-file
|
||||||
|
else
|
||||||
|
echo "./decode-file exists - skip building"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export DYLD_LIBRARY_PATH=$PWD/../build-swift-macos/install/lib:$DYLD_LIBRARY_PATH
|
||||||
|
./decode-file
|
||||||
927
toolchains/ios.toolchain.cmake
Normal file
927
toolchains/ios.toolchain.cmake
Normal file
@@ -0,0 +1,927 @@
|
|||||||
|
# This file is part of the ios-cmake project. It was retrieved from
|
||||||
|
# https://github.com/leetal/ios-cmake.git, which is a fork of
|
||||||
|
# https://github.com/gerstrong/ios-cmake.git, which is a fork of
|
||||||
|
# https://github.com/cristeab/ios-cmake.git, which is a fork of
|
||||||
|
# https://code.google.com/p/ios-cmake/. Which in turn is based off of
|
||||||
|
# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
|
||||||
|
# are included with CMake 2.8.4
|
||||||
|
#
|
||||||
|
# The ios-cmake project is licensed under the new BSD license.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
|
||||||
|
# Kitware, Inc., Insight Software Consortium. All rights reserved.
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived from
|
||||||
|
# this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
# This file is based off of the Platform/Darwin.cmake and
|
||||||
|
# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
|
||||||
|
# It has been altered for iOS development.
|
||||||
|
#
|
||||||
|
# Updated by Alex Stewart (alexs.mac@gmail.com)
|
||||||
|
#
|
||||||
|
# *****************************************************************************
|
||||||
|
# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
|
||||||
|
# under the BSD-3-Clause license
|
||||||
|
# https://github.com/leetal/ios-cmake
|
||||||
|
# *****************************************************************************
|
||||||
|
#
|
||||||
|
# INFORMATION / HELP
|
||||||
|
#
|
||||||
|
# The following options control the behaviour of this toolchain:
|
||||||
|
#
|
||||||
|
# PLATFORM: (default "OS64")
|
||||||
|
# OS = Build for iPhoneOS.
|
||||||
|
# OS64 = Build for arm64 iphoneOS.
|
||||||
|
# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
|
||||||
|
# SIMULATOR = Build for x86 i386 iphoneOS Simulator.
|
||||||
|
# SIMULATOR64 = Build for x86_64 iphoneOS Simulator.
|
||||||
|
# SIMULATORARM64 = Build for arm64 iphoneOS Simulator.
|
||||||
|
# TVOS = Build for arm64 tvOS.
|
||||||
|
# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
|
||||||
|
# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator.
|
||||||
|
# WATCHOS = Build for armv7k arm64_32 for watchOS.
|
||||||
|
# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
|
||||||
|
# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
|
||||||
|
# MAC = Build for x86_64 macOS.
|
||||||
|
# MAC_ARM64 = Build for Apple Silicon macOS.
|
||||||
|
# MAC_CATALYST = Build for x86_64 macOS with Catalyst support (iOS toolchain on macOS).
|
||||||
|
# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS
|
||||||
|
# MAC_CATALYST_ARM64 = Build for Apple Silicon macOS with Catalyst support (iOS toolchain on macOS).
|
||||||
|
# Note: The build argument "MACOSX_DEPLOYMENT_TARGET" can be used to control min-version of macOS
|
||||||
|
#
|
||||||
|
# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is
|
||||||
|
# automatically determined from PLATFORM and xcodebuild, but
|
||||||
|
# can also be manually specified (although this should not be required).
|
||||||
|
#
|
||||||
|
# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform
|
||||||
|
# being compiled for. By default this is automatically determined from
|
||||||
|
# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
|
||||||
|
# not be required).
|
||||||
|
#
|
||||||
|
# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS
|
||||||
|
#
|
||||||
|
# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
|
||||||
|
#
|
||||||
|
# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
|
||||||
|
#
|
||||||
|
# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
|
||||||
|
#
|
||||||
|
# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker
|
||||||
|
# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY)
|
||||||
|
#
|
||||||
|
# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM
|
||||||
|
# OS = armv7 armv7s arm64 (if applicable)
|
||||||
|
# OS64 = arm64 (if applicable)
|
||||||
|
# SIMULATOR = i386
|
||||||
|
# SIMULATOR64 = x86_64
|
||||||
|
# SIMULATORARM64 = arm64
|
||||||
|
# TVOS = arm64
|
||||||
|
# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
|
||||||
|
# WATCHOS = armv7k arm64_32 (if applicable)
|
||||||
|
# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
|
||||||
|
# MAC = x86_64
|
||||||
|
# MAC_ARM64 = arm64
|
||||||
|
# MAC_CATALYST = x86_64
|
||||||
|
# MAC_CATALYST_ARM64 = arm64
|
||||||
|
#
|
||||||
|
# This toolchain defines the following properties (available via get_property()) for use externally:
|
||||||
|
#
|
||||||
|
# PLATFORM: The currently targeted platform.
|
||||||
|
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
|
||||||
|
# SDK_VERSION: Version of SDK being used.
|
||||||
|
# OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM).
|
||||||
|
# APPLE_TARGET_TRIPLE: Used by autoconf build systems. NOTE: If "ARCHS" are overridden, this will *NOT* be set!
|
||||||
|
#
|
||||||
|
# This toolchain defines the following macros for use externally:
|
||||||
|
#
|
||||||
|
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
|
||||||
|
# A convenience macro for setting xcode specific properties on targets.
|
||||||
|
# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
|
||||||
|
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
|
||||||
|
#
|
||||||
|
# find_host_package (PROGRAM ARGS)
|
||||||
|
# A macro used to find executable programs on the host system, not within the
|
||||||
|
# environment. Thanks to the android-cmake project for providing the
|
||||||
|
# command.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.8.0)
|
||||||
|
|
||||||
|
# CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds.
|
||||||
|
if(IOS_TOOLCHAIN_HAS_RUN)
|
||||||
|
return()
|
||||||
|
endif(IOS_TOOLCHAIN_HAS_RUN)
|
||||||
|
set(IOS_TOOLCHAIN_HAS_RUN true)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OPTIONS #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
option(DROP_32_BIT "Drops the 32-bit targets universally." YES)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# END OPTIONS #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
# List of supported platform values
|
||||||
|
list(APPEND _supported_platforms
|
||||||
|
"OS" "OS64" "OS64COMBINED" "SIMULATOR" "SIMULATOR64" "SIMULATORARM64"
|
||||||
|
"TVOS" "TVOSCOMBINED" "SIMULATOR_TVOS"
|
||||||
|
"WATCHOS" "WATCHOSCOMBINED" "SIMULATOR_WATCHOS"
|
||||||
|
"MAC" "MAC_ARM64"
|
||||||
|
"MAC_CATALYST" "MAC_CATALYST_ARM64")
|
||||||
|
|
||||||
|
# Cache what generator is used
|
||||||
|
set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
|
||||||
|
|
||||||
|
# Check if using a CMake version capable of building combined FAT builds (simulator and target slices combined in one static lib)
|
||||||
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
|
||||||
|
set(MODERN_CMAKE YES)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Get the Xcode version being used.
|
||||||
|
# Problem: CMake runs toolchain files multiple times, but can't read cache variables on some runs.
|
||||||
|
# Workaround: On first run (in which cache variables are always accessible), set an intermediary environment variable.
|
||||||
|
#
|
||||||
|
# NOTE: This pattern is used i many places in this toolchain to speed up checks of all sorts
|
||||||
|
if(DEFINED XCODE_VERSION_INT)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_XCODE_VERSION_INT} "${XCODE_VERSION_INT}")
|
||||||
|
elseif(DEFINED ENV{_XCODE_VERSION_INT})
|
||||||
|
set(XCODE_VERSION_INT "$ENV{_XCODE_VERSION_INT}")
|
||||||
|
elseif(NOT DEFINED XCODE_VERSION_INT)
|
||||||
|
find_program(XCODEBUILD_EXECUTABLE xcodebuild)
|
||||||
|
if(NOT XCODEBUILD_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "xcodebuild not found. Please install either the standalone commandline tools or Xcode.")
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version
|
||||||
|
OUTPUT_VARIABLE XCODE_VERSION_INT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION_INT "${XCODE_VERSION_INT}")
|
||||||
|
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION_INT "${XCODE_VERSION_INT}")
|
||||||
|
set(XCODE_VERSION_INT "${XCODE_VERSION_INT}" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur)
|
||||||
|
# if you don't set a deployment target it will be set the way you only get 64-bit builds
|
||||||
|
if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0)
|
||||||
|
# Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if the platform variable is set
|
||||||
|
if(DEFINED PLATFORM)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_PLATFORM} "${PLATFORM}")
|
||||||
|
elseif(DEFINED ENV{_PLATFORM})
|
||||||
|
set(PLATFORM "$ENV{_PLATFORM}")
|
||||||
|
elseif(NOT DEFINED PLATFORM)
|
||||||
|
message(FATAL_ERROR "PLATFORM argument not set. Bailing configure since I don't know what target you want to build for!")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Safeguard that the platform value is set and is one of the supported values
|
||||||
|
list(FIND _supported_platforms ${PLATFORM} contains_PLATFORM)
|
||||||
|
if("${contains_PLATFORM}" EQUAL "-1")
|
||||||
|
string(REPLACE ";" "\n * " _supported_platforms_formatted "${_supported_platforms}")
|
||||||
|
message(FATAL_ERROR " Invalid PLATFORM specified! Current value: ${PLATFORM}.\n"
|
||||||
|
" Supported PLATFORM values: \n * ${_supported_platforms_formatted}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if Apple Silicon is supported
|
||||||
|
if(PLATFORM MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$" AND ${CMAKE_VERSION} VERSION_LESS "3.19.5")
|
||||||
|
message(FATAL_ERROR "Apple Silicon builds requires a minimum of CMake 3.19.5")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Touch toolchain variable to suppress "unused variable" warning.
|
||||||
|
# This happens if CMake is invoked with the same command line the second time.
|
||||||
|
if(CMAKE_TOOLCHAIN_FILE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Fix for PThread library not in path
|
||||||
|
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
|
||||||
|
set(CMAKE_HAVE_THREADS_LIBRARY 1)
|
||||||
|
set(CMAKE_USE_WIN32_THREADS_INIT 0)
|
||||||
|
set(CMAKE_USE_PTHREADS_INIT 1)
|
||||||
|
|
||||||
|
# Specify minimum version of deployment target.
|
||||||
|
if(NOT DEFINED DEPLOYMENT_TARGET)
|
||||||
|
if (PLATFORM MATCHES "WATCHOS")
|
||||||
|
# Unless specified, SDK version 4.0 is used by default as minimum target version (watchOS).
|
||||||
|
set(DEPLOYMENT_TARGET "4.0")
|
||||||
|
elseif(PLATFORM STREQUAL "MAC")
|
||||||
|
# Unless specified, SDK version 10.13 (High sierra) is used by default as minimum target version (macos).
|
||||||
|
set(DEPLOYMENT_TARGET "10.13")
|
||||||
|
elseif(PLATFORM STREQUAL "MAC_ARM64")
|
||||||
|
# Unless specified, SDK version 11.0 (Big Sur) is used by default as minimum target version (macos on arm).
|
||||||
|
set(DEPLOYMENT_TARGET "11.0")
|
||||||
|
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")
|
||||||
|
# Unless specified, SDK version 13.0 is used by default as minimum target version (mac catalyst minimum requirement).
|
||||||
|
set(DEPLOYMENT_TARGET "13.0")
|
||||||
|
else()
|
||||||
|
# Unless specified, SDK version 11.0 is used by default as minimum target version (iOS, tvOS).
|
||||||
|
set(DEPLOYMENT_TARGET "11.0")
|
||||||
|
endif()
|
||||||
|
message(STATUS "[DEFAULTS] Using the default min-version since DEPLOYMENT_TARGET not provided!")
|
||||||
|
elseif(DEFINED DEPLOYMENT_TARGET AND PLATFORM STREQUAL "MAC_CATALYST" AND ${DEPLOYMENT_TARGET} VERSION_LESS "13.0")
|
||||||
|
message(FATAL_ERROR "Mac Catalyst builds requires a minimum deployment target of 13.0!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Store the DEPLOYMENT_TARGET in the cache
|
||||||
|
set(DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}" CACHE INTERNAL "")
|
||||||
|
|
||||||
|
# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially)
|
||||||
|
if(PLATFORM STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
|
||||||
|
set(PLATFORM "OS64")
|
||||||
|
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
|
||||||
|
elseif(PLATFORM STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
|
||||||
|
set(PLATFORM "SIMULATOR64")
|
||||||
|
message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PLATFORM_INT "${PLATFORM}")
|
||||||
|
|
||||||
|
if(DEFINED ARCHS)
|
||||||
|
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine the platform name and architectures for use in xcodebuild commands
|
||||||
|
# from the specified PLATFORM_INT name.
|
||||||
|
if(PLATFORM_INT STREQUAL "OS")
|
||||||
|
set(SDK_NAME iphoneos)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS armv7 armv7s arm64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT arm-apple-ios)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "OS64")
|
||||||
|
set(SDK_NAME iphoneos)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
|
||||||
|
set(ARCHS arm64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
|
||||||
|
else()
|
||||||
|
set(ARCHS arm64)
|
||||||
|
endif()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
|
||||||
|
set(SDK_NAME iphoneos)
|
||||||
|
if(MODERN_CMAKE)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
|
||||||
|
set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64")
|
||||||
|
else()
|
||||||
|
set(ARCHS arm64 x86_64)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphoneos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=iphonesimulator*] "x86_64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphoneos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=iphonesimulator*] "x86_64")
|
||||||
|
endif()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-ios)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work")
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR")
|
||||||
|
set(SDK_NAME iphonesimulator)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS i386)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT i386-apple-ios)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios)
|
||||||
|
endif()
|
||||||
|
message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
|
||||||
|
set(SDK_NAME iphonesimulator)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS x86_64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-ios)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATORARM64")
|
||||||
|
set(SDK_NAME iphonesimulator)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS arm64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-ios)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "TVOS")
|
||||||
|
set(SDK_NAME appletvos)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS arm64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64-apple-tvos)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos)
|
||||||
|
endif()
|
||||||
|
elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED")
|
||||||
|
set(SDK_NAME appletvos)
|
||||||
|
if(MODERN_CMAKE)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS arm64 x86_64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64-x86_64-apple-tvos)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=appletvsimulator*] "x86_64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvos*] "arm64")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=appletvsimulator*] "x86_64")
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work")
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
|
||||||
|
set(SDK_NAME appletvsimulator)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS x86_64)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT x86_64-apple-tvos)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-tvos)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "WATCHOS")
|
||||||
|
set(SDK_NAME watchos)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
|
||||||
|
set(ARCHS armv7k arm64_32)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64_32-apple-watchos)
|
||||||
|
else()
|
||||||
|
set(ARCHS armv7k)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT arm-apple-watchos)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
|
||||||
|
set(SDK_NAME watchos)
|
||||||
|
if(MODERN_CMAKE)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
if (XCODE_VERSION_INT VERSION_GREATER 10.0)
|
||||||
|
set(ARCHS armv7k arm64_32 i386)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT aarch64_32-i386-apple-watchos)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k arm64_32")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k arm64_32")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
|
||||||
|
else()
|
||||||
|
set(ARCHS armv7k i386)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT arm-i386-apple-watchos)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchos*] "armv7k")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=watchsimulator*] "i386")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchos*] "armv7k")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=watchsimulator*] "i386")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work")
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
|
||||||
|
set(SDK_NAME watchsimulator)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS i386)
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT i386-apple-watchos)
|
||||||
|
else()
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-watchos)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "MAC" OR PLATFORM_INT STREQUAL "MAC_CATALYST")
|
||||||
|
set(SDK_NAME macosx)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS x86_64)
|
||||||
|
endif()
|
||||||
|
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
|
||||||
|
if(PLATFORM_INT STREQUAL "MAC")
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx)
|
||||||
|
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST")
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT MATCHES "^(MAC_ARM64)$|^(MAC_CATALYST_ARM64)$")
|
||||||
|
set(SDK_NAME macosx)
|
||||||
|
if(NOT ARCHS)
|
||||||
|
set(ARCHS arm64)
|
||||||
|
endif()
|
||||||
|
string(REPLACE ";" "-" ARCHS_SPLIT "${ARCHS}")
|
||||||
|
if(PLATFORM_INT STREQUAL "MAC_ARM64")
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-macosx)
|
||||||
|
elseif(PLATFORM_INT STREQUAL "MAC_CATALYST_ARM64")
|
||||||
|
set(APPLE_TARGET_TRIPLE_INT ${ARCHS_SPLIT}-apple-ios${DEPLOYMENT_TARGET}-macabi)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Xcode" AND PLATFORM_INT MATCHES "MAC_CATALYST_.*")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "macosx")
|
||||||
|
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-maccatalyst")
|
||||||
|
if(NOT DEFINED MACOSX_DEPLOYMENT_TARGET)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "10.15")
|
||||||
|
else()
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET "${MACOSX_DEPLOYMENT_TARGET}")
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${DEPLOYMENT_TARGET}")
|
||||||
|
if(NOT PLATFORM_INT MATCHES ".*COMBINED")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS[sdk=${SDK_NAME}*] "${ARCHS}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If user did not specify the SDK root to use, then query xcodebuild for it.
|
||||||
|
if(DEFINED CMAKE_OSX_SYSROOT_INT)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_CMAKE_OSX_SYSROOT_INT} "${CMAKE_OSX_SYSROOT_INT}")
|
||||||
|
elseif(DEFINED ENV{_CMAKE_OSX_SYSROOT_INT})
|
||||||
|
set(CMAKE_OSX_SYSROOT_INT "$ENV{_CMAKE_OSX_SYSROOT_INT}")
|
||||||
|
elseif(NOT DEFINED CMAKE_OSX_SYSROOT_INT)
|
||||||
|
execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -version -sdk ${SDK_NAME} Path
|
||||||
|
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT)
|
||||||
|
message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
|
||||||
|
"is pointing to the correct path. Please run:"
|
||||||
|
"sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
|
||||||
|
"and see if that fixes the problem for you.")
|
||||||
|
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
|
||||||
|
"does not exist.")
|
||||||
|
elseif(DEFINED CMAKE_OSX_SYSROOT_INT)
|
||||||
|
set(CMAKE_OSX_SYSROOT_INT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
|
||||||
|
# Specify the location or name of the platform SDK to be used in CMAKE_OSX_SYSROOT.
|
||||||
|
set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Use bitcode or not
|
||||||
|
if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+")
|
||||||
|
# Unless specified, enable bitcode support by default
|
||||||
|
message(STATUS "[DEFAULTS] Enabling bitcode support by default. ENABLE_BITCODE not provided!")
|
||||||
|
set(ENABLE_BITCODE TRUE)
|
||||||
|
elseif(NOT DEFINED ENABLE_BITCODE)
|
||||||
|
message(STATUS "[DEFAULTS] Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
|
||||||
|
set(ENABLE_BITCODE FALSE)
|
||||||
|
endif()
|
||||||
|
set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL
|
||||||
|
"Whether or not to enable bitcode" FORCE)
|
||||||
|
# Use ARC or not
|
||||||
|
if(NOT DEFINED ENABLE_ARC)
|
||||||
|
# Unless specified, enable ARC support by default
|
||||||
|
set(ENABLE_ARC TRUE)
|
||||||
|
message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!")
|
||||||
|
endif()
|
||||||
|
set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE)
|
||||||
|
# Use hidden visibility or not
|
||||||
|
if(NOT DEFINED ENABLE_VISIBILITY)
|
||||||
|
# Unless specified, disable symbols visibility by default
|
||||||
|
set(ENABLE_VISIBILITY FALSE)
|
||||||
|
message(STATUS "[DEFAULTS] Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
|
||||||
|
endif()
|
||||||
|
set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols from the dynamic linker (-fvisibility=hidden)" FORCE)
|
||||||
|
# Set strict compiler checks or not
|
||||||
|
if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE)
|
||||||
|
# Unless specified, disable strict try_compile()
|
||||||
|
set(ENABLE_STRICT_TRY_COMPILE FALSE)
|
||||||
|
message(STATUS "[DEFAULTS] Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!")
|
||||||
|
endif()
|
||||||
|
set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL
|
||||||
|
"Whether or not to use strict compiler checks" FORCE)
|
||||||
|
|
||||||
|
# Get the SDK version information.
|
||||||
|
if(DEFINED SDK_VERSION)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_SDK_VERSION} "${SDK_VERSION}")
|
||||||
|
elseif(DEFINED ENV{_SDK_VERSION})
|
||||||
|
set(SDK_VERSION "$ENV{_SDK_VERSION}")
|
||||||
|
elseif(NOT DEFINED SDK_VERSION)
|
||||||
|
execute_process(COMMAND ${XCODEBUILD_EXECUTABLE} -sdk ${CMAKE_OSX_SYSROOT_INT} -version SDKVersion
|
||||||
|
OUTPUT_VARIABLE SDK_VERSION
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find the Developer root for the specific iOS platform being compiled for
|
||||||
|
# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
|
||||||
|
# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
|
||||||
|
# this information from xcrun or xcodebuild.
|
||||||
|
if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT_INT} PATH)
|
||||||
|
get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)
|
||||||
|
if (NOT EXISTS "${CMAKE_DEVELOPER_ROOT}")
|
||||||
|
message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: ${CMAKE_DEVELOPER_ROOT} does not exist.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Find the C & C++ compilers for the specified SDK.
|
||||||
|
if(DEFINED CMAKE_C_COMPILER)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_CMAKE_C_COMPILER} "${CMAKE_C_COMPILER}")
|
||||||
|
elseif(DEFINED ENV{_CMAKE_C_COMPILER})
|
||||||
|
set(CMAKE_C_COMPILER "$ENV{_CMAKE_C_COMPILER}")
|
||||||
|
elseif(NOT DEFINED CMAKE_C_COMPILER)
|
||||||
|
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang
|
||||||
|
OUTPUT_VARIABLE CMAKE_C_COMPILER
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
if(DEFINED CMAKE_CXX_COMPILER)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER}")
|
||||||
|
elseif(DEFINED ENV{_CMAKE_CXX_COMPILER})
|
||||||
|
set(CMAKE_CXX_COMPILER "$ENV{_CMAKE_CXX_COMPILER}")
|
||||||
|
elseif(NOT DEFINED CMAKE_CXX_COMPILER)
|
||||||
|
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find clang++
|
||||||
|
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
# Find (Apple's) libtool.
|
||||||
|
if(DEFINED BUILD_LIBTOOL)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_BUILD_LIBTOOL} "${BUILD_LIBTOOL}")
|
||||||
|
elseif(DEFINED ENV{_BUILD_LIBTOOL})
|
||||||
|
set(BUILD_LIBTOOL "$ENV{_BUILD_LIBTOOL}")
|
||||||
|
elseif(NOT DEFINED BUILD_LIBTOOL)
|
||||||
|
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find libtool
|
||||||
|
OUTPUT_VARIABLE BUILD_LIBTOOL
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
endif()
|
||||||
|
# Find the toolchain's provided install_name_tool if none is found on the host
|
||||||
|
if(DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||||
|
# Environment variables are always preserved.
|
||||||
|
set(ENV{_CMAKE_INSTALL_NAME_TOOL} "${CMAKE_INSTALL_NAME_TOOL}")
|
||||||
|
elseif(DEFINED ENV{_CMAKE_INSTALL_NAME_TOOL})
|
||||||
|
set(CMAKE_INSTALL_NAME_TOOL "$ENV{_CMAKE_INSTALL_NAME_TOOL}")
|
||||||
|
elseif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||||
|
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT_INT} -find install_name_tool
|
||||||
|
OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configure libtool to be used instead of ar + ranlib to build static libraries.
|
||||||
|
# This is required on Xcode 7+, but should also work on previous versions of
|
||||||
|
# Xcode.
|
||||||
|
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||||
|
foreach(lang ${languages})
|
||||||
|
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> " CACHE INTERNAL "")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box.
|
||||||
|
if(MODERN_CMAKE)
|
||||||
|
if(SDK_NAME MATCHES "iphone")
|
||||||
|
set(CMAKE_SYSTEM_NAME iOS)
|
||||||
|
elseif(SDK_NAME MATCHES "macosx")
|
||||||
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
|
elseif(SDK_NAME MATCHES "appletv")
|
||||||
|
set(CMAKE_SYSTEM_NAME tvOS)
|
||||||
|
elseif(SDK_NAME MATCHES "watch")
|
||||||
|
set(CMAKE_SYSTEM_NAME watchOS)
|
||||||
|
endif()
|
||||||
|
# Provide flags for a combined FAT library build on newer CMake versions
|
||||||
|
if(PLATFORM_INT MATCHES ".*COMBINED")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH "NO")
|
||||||
|
set(CMAKE_IOS_INSTALL_COMBINED YES)
|
||||||
|
message(STATUS "Will combine built (static) artifacts into FAT lib...")
|
||||||
|
endif()
|
||||||
|
elseif(NOT DEFINED CMAKE_SYSTEM_NAME AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.10")
|
||||||
|
# Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified
|
||||||
|
set(CMAKE_SYSTEM_NAME iOS)
|
||||||
|
elseif(NOT DEFINED CMAKE_SYSTEM_NAME)
|
||||||
|
# Legacy code path prior to CMake 3.14 or fallback if no CMAKE_SYSTEM_NAME specified
|
||||||
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
|
endif()
|
||||||
|
# Standard settings.
|
||||||
|
set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
|
||||||
|
set(UNIX TRUE CACHE BOOL "")
|
||||||
|
set(APPLE TRUE CACHE BOOL "")
|
||||||
|
if(PLATFORM STREQUAL "MAC" OR PLATFORM STREQUAL "MAC_ARM64")
|
||||||
|
set(IOS FALSE CACHE BOOL "")
|
||||||
|
set(MACOS TRUE CACHE BOOL "")
|
||||||
|
elseif(PLATFORM STREQUAL "MAC_CATALYST" OR PLATFORM STREQUAL "MAC_CATALYST_ARM64")
|
||||||
|
set(IOS TRUE CACHE BOOL "")
|
||||||
|
set(MACOS TRUE CACHE BOOL "")
|
||||||
|
else()
|
||||||
|
set(IOS TRUE CACHE BOOL "")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
|
||||||
|
set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE)
|
||||||
|
# Set the architectures for which to build.
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE INTERNAL "")
|
||||||
|
# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks
|
||||||
|
if(NOT ENABLE_STRICT_TRY_COMPILE_INT)
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||||
|
endif()
|
||||||
|
# All iOS/Darwin specific settings - some may be redundant.
|
||||||
|
set(CMAKE_MACOSX_BUNDLE YES)
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||||
|
set(CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||||
|
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||||
|
set(CMAKE_C_COMPILER_ABI ELF)
|
||||||
|
set(CMAKE_CXX_COMPILER_ABI ELF)
|
||||||
|
set(CMAKE_C_HAS_ISYSROOT 1)
|
||||||
|
set(CMAKE_CXX_HAS_ISYSROOT 1)
|
||||||
|
set(CMAKE_MODULE_EXISTS 1)
|
||||||
|
set(CMAKE_DL_LIBS "")
|
||||||
|
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||||
|
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||||
|
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||||
|
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||||
|
|
||||||
|
if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+")
|
||||||
|
set(CMAKE_C_SIZEOF_DATA_PTR 8)
|
||||||
|
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
|
||||||
|
if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+")
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR "aarch64")
|
||||||
|
else()
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(CMAKE_C_SIZEOF_DATA_PTR 4)
|
||||||
|
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR "arm")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Note that only Xcode 7+ supports the newer more specific:
|
||||||
|
# -m${SDK_NAME}-version-min flags, older versions of Xcode use:
|
||||||
|
# -m(ios/ios-simulator)-version-min instead.
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS "3.11")
|
||||||
|
if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64")
|
||||||
|
if(XCODE_VERSION_INT VERSION_LESS 7.0)
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mios-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
else()
|
||||||
|
# Xcode 7.0+ uses flags we can build directly from SDK_NAME.
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_INT STREQUAL "TVOS")
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mtvos-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
elseif(PLATFORM_INT STREQUAL "WATCHOS")
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mwatchos-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
elseif(PLATFORM_INT STREQUAL "MAC")
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mmacosx-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
else()
|
||||||
|
# SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
|
||||||
|
set(SDK_NAME_VERSION_FLAGS
|
||||||
|
"-mios-simulator-version-min=${DEPLOYMENT_TARGET}")
|
||||||
|
endif()
|
||||||
|
elseif(NOT PLATFORM_INT STREQUAL "MAC_CATALYST")
|
||||||
|
# Newer versions of CMake sets the version min flags correctly, skip this for Mac Catalyst targets
|
||||||
|
set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED APPLE_TARGET_TRIPLE_INT)
|
||||||
|
set(APPLE_TARGET_TRIPLE ${APPLE_TARGET_TRIPLE_INT} CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PLATFORM_INT STREQUAL "MAC_CATALYST")
|
||||||
|
set(C_TARGET_FLAGS "-target ${APPLE_TARGET_TRIPLE_INT} -isystem ${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/usr/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_BITCODE_INT)
|
||||||
|
set(BITCODE "-fembed-bitcode")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
|
||||||
|
else()
|
||||||
|
set(BITCODE "")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ARC_INT)
|
||||||
|
set(FOBJC_ARC "-fobjc-arc")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES")
|
||||||
|
else()
|
||||||
|
set(FOBJC_ARC "-fno-objc-arc")
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ENABLE_VISIBILITY_INT)
|
||||||
|
foreach(lang ${languages})
|
||||||
|
set(CMAKE_${lang}_VISIBILITY_PRESET "hidden" CACHE INTERNAL "")
|
||||||
|
endforeach()
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "YES")
|
||||||
|
set(VISIBILITY "-fvisibility=hidden -fvisibility-inlines-hidden")
|
||||||
|
else()
|
||||||
|
foreach(lang ${languages})
|
||||||
|
set(CMAKE_${lang}_VISIBILITY_PRESET "default" CACHE INTERNAL "")
|
||||||
|
endforeach()
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN "NO")
|
||||||
|
set(VISIBILITY "-fvisibility=default")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#Check if Xcode generator is used, since that will handle these flags automagically
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.")
|
||||||
|
else()
|
||||||
|
# Hidden visibility is required for C++ on iOS.
|
||||||
|
set(CMAKE_C_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
|
set(CMAKE_C_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||||
|
set(CMAKE_CXX_LINK_FLAGS "${C_TARGET_FLAGS} ${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||||
|
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -x assembler-with-cpp -arch ${CMAKE_OSX_ARCHITECTURES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
## Print status messages to inform of the current state
|
||||||
|
message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}")
|
||||||
|
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT}")
|
||||||
|
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
|
||||||
|
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
|
||||||
|
message(STATUS "Using libtool: ${BUILD_LIBTOOL}")
|
||||||
|
message(STATUS "Using install name tool: ${CMAKE_INSTALL_NAME_TOOL}")
|
||||||
|
if(DEFINED APPLE_TARGET_TRIPLE)
|
||||||
|
message(STATUS "Autoconf target triple: ${APPLE_TARGET_TRIPLE}")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Using minimum deployment version: ${DEPLOYMENT_TARGET}"
|
||||||
|
" (SDK version: ${SDK_VERSION})")
|
||||||
|
if(MODERN_CMAKE)
|
||||||
|
message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!")
|
||||||
|
endif()
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Xcode")
|
||||||
|
message(STATUS "Using Xcode version: ${XCODE_VERSION_INT}")
|
||||||
|
endif()
|
||||||
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||||
|
if(DEFINED SDK_NAME_VERSION_FLAGS)
|
||||||
|
message(STATUS "Using version flags: ${SDK_NAME_VERSION_FLAGS}")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Using a data_ptr size of: ${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
||||||
|
if(ENABLE_BITCODE_INT)
|
||||||
|
message(STATUS "Bitcode: Enabled")
|
||||||
|
else()
|
||||||
|
message(STATUS "Bitcode: Disabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ARC_INT)
|
||||||
|
message(STATUS "ARC: Enabled")
|
||||||
|
else()
|
||||||
|
message(STATUS "ARC: Disabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_VISIBILITY_INT)
|
||||||
|
message(STATUS "Hiding symbols: Disabled")
|
||||||
|
else()
|
||||||
|
message(STATUS "Hiding symbols: Enabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set global properties
|
||||||
|
set_property(GLOBAL PROPERTY PLATFORM "${PLATFORM}")
|
||||||
|
set_property(GLOBAL PROPERTY APPLE_TARGET_TRIPLE "${APPLE_TARGET_TRIPLE_INT}")
|
||||||
|
set_property(GLOBAL PROPERTY SDK_VERSION "${SDK_VERSION}")
|
||||||
|
set_property(GLOBAL PROPERTY XCODE_VERSION "${XCODE_VERSION_INT}")
|
||||||
|
set_property(GLOBAL PROPERTY OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
|
||||||
|
|
||||||
|
# Export configurable variables for the try_compile() command.
|
||||||
|
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
|
||||||
|
PLATFORM
|
||||||
|
XCODE_VERSION_INT
|
||||||
|
SDK_VERSION
|
||||||
|
DEPLOYMENT_TARGET
|
||||||
|
CMAKE_DEVELOPER_ROOT
|
||||||
|
CMAKE_OSX_SYSROOT_INT
|
||||||
|
ENABLE_BITCODE
|
||||||
|
ENABLE_ARC
|
||||||
|
CMAKE_C_COMPILER
|
||||||
|
CMAKE_CXX_COMPILER
|
||||||
|
BUILD_LIBTOOL
|
||||||
|
CMAKE_INSTALL_NAME_TOOL
|
||||||
|
CMAKE_C_FLAGS
|
||||||
|
CMAKE_CXX_FLAGS
|
||||||
|
CMAKE_CXX_FLAGS_DEBUG
|
||||||
|
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||||
|
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
CMAKE_C_LINK_FLAGS
|
||||||
|
CMAKE_CXX_LINK_FLAGS
|
||||||
|
CMAKE_ASM_FLAGS
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
|
||||||
|
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
|
||||||
|
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||||
|
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
|
||||||
|
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
|
||||||
|
|
||||||
|
# Set the find root to the SDK developer roots.
|
||||||
|
# Note: CMAKE_FIND_ROOT_PATH is only useful when cross-compiling. Thus, do not set on macOS builds.
|
||||||
|
if(NOT PLATFORM_INT STREQUAL "MAC" AND NOT PLATFORM_INT STREQUAL "MAC_ARM64")
|
||||||
|
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
|
||||||
|
set(CMAKE_IGNORE_PATH "/System/Library/Frameworks;/usr/local/lib" CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Default to searching for frameworks first.
|
||||||
|
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||||
|
|
||||||
|
# Set up the default search directories for frameworks.
|
||||||
|
if(PLATFORM_INT MATCHES "MAC_CATALYST.*")
|
||||||
|
set(CMAKE_FRAMEWORK_PATH
|
||||||
|
${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
|
||||||
|
${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
|
||||||
|
${CMAKE_OSX_SYSROOT_INT}/System/iOSSupport/System/Library/Frameworks
|
||||||
|
${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
set(CMAKE_FRAMEWORK_PATH
|
||||||
|
${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
|
||||||
|
${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
|
||||||
|
${CMAKE_FRAMEWORK_PATH} CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# By default, search both the specified iOS SDK and the remainder of the host filesystem.
|
||||||
|
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Some helper-macros below to simplify and beautify the CMakeFile
|
||||||
|
#
|
||||||
|
|
||||||
|
# This little macro lets you set any Xcode specific property.
|
||||||
|
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
|
||||||
|
set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
|
||||||
|
if(XCODE_RELVERSION_I STREQUAL "All")
|
||||||
|
set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
|
||||||
|
else()
|
||||||
|
set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
|
||||||
|
endif()
|
||||||
|
endmacro(set_xcode_property)
|
||||||
|
|
||||||
|
# This macro lets you find executable programs on the host system.
|
||||||
|
macro(find_host_package)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
|
||||||
|
set(_TOOLCHAIN_IOS ${IOS})
|
||||||
|
set(IOS FALSE)
|
||||||
|
find_package(${ARGN})
|
||||||
|
set(IOS ${_TOOLCHAIN_IOS})
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
|
||||||
|
endmacro(find_host_package)
|
||||||
Reference in New Issue
Block a user