I have been trying to generate a framework/xcframework that can run on both simulator and device. This is for tensorflow lite and I have been following these instructions:
bazel build --config=ios_fat -c opt --cxxopt=--std=c++17 \
//tensorflow/lite/ios:TensorFlowLiteC_framework
from
https://www.tensorflow.org/lite/guide/build_ios#build_tensorflowlitec_dynamic_framework_recommended
If I use config=ios_fat
, then I cannot build for simulator. If I use config=ios
, I can build for simulator but not device.
I either get
/path/Module/Framework/VideoProcessing/VideoProcessing.xcodeproj Building for iOS, but the linked framework 'TensorFlowLiteC.framework' was built for iOS Simulator.
or
building for iOS Simulator, but linking in object file built for iOS, file 'path/Module/thirdparty/installdir/tensorflow_device/frameworks/TensorFlowLiteC.framework/TensorFlowLiteC' for architecture arm64
The second error does not say it was not built for simulator, but the architecture is incorrect.
I have tried to combine these frameworks with
xcodebuild -create-xcframework -framework tensorflow_device/frameworks/TensorFlowLiteC.framework -framework tensorflow_simulator/framework/TensorFlowLiteC.framework
but this gives
error: binaries with multiple platforms are not supported '/pathModule/thirdparty/installdir/tensorflow_device/frameworks/TensorFlowLiteC.framework/TensorFlowLiteC
I have also tried to combine the libs with
lipo -create tensorflow_device/frameworks/TensorFlowLiteC.framework/TensorFlowLiteC tensorflow_simulator/framework/TensorFlowLiteC.framework/TensorFlowLiteC -output tensorflow/TensorFlowLiteC.framework/TensorFlowLiteC
Which gives the error
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: tensorflow_device/frameworks/TensorFlowLiteC.framework/TensorFlowLiteC and tensorflow_simulator/framework/TensorFlowLiteC.framework/TensorFlowLiteC have the same architectures (arm64) and can't be in the same fat output file
I can compile for iphone_simulator
if I exclude arm64 as architecture. But I guess I will need that for device, so would be nice if there is a solution where I can just change target.