As the title states, I am experiencing a crash when using the xcframework on the simulator. Before this, I would have a fat file generated from the lipo command which worked quite well on both the device as well as the simulator. The individual frameworks for the simulator and device are built through CMake and generate a framework
file each with their own Info.plist, acknowledgements.plist, a directory for the public headers (This is a CC++ library), and the framework. Using the generated frameworks I then call xcodebuild -framework <path-to-ios-framework>.framework -framework <path-to-ios-simulator-framework>.framework -output <output-path>.xcframework
. I see that this generates the correct xcframework with both iOS and simulator included, so far so good.
Once the xcframework is built, I include in the Xcode project for my objective-c application and start a build before running on the device through Xcode. Which again works with no issue. If I build for the simulator, it builds fine, but upon starting the application, again through Xcode, I get an EXC_BAD_ACCESS
on Thread 1 with the only items in the stack trace being memcpy
and _dyld_start
. If I try to continue I get a SIGKILL
with the only output being what looks like the library not able to be found @rpath/framework.framework/framework
. If I run the application on the simulator without going through Xcode, the application runs fine.
My overall question is why would running on the simulator through Xcode produce this crash and what can be done to resolve it. Searching for answers online has lead me to dead ends. I am running Xcode 12.4 using the 8th Gen iPad Simulator running iOS 14.4. The OS is Big Sur 11.2.1. One other note is that after I included the xcframework in the actual application, I had to specify the HEADER_SEARCH_PATHS for both the iphoneos and iphonesimulator in both Release and Debug configurations, otherwise the application failed to compile.
2
Answers
I know that this is an old topic, but only recently was this resolved by upgrading to CMake version 3.21.4. Looks like in CMake 3.20 there was a fix to how the
-rpath
linker flag was being handled. See Release notes for CMake 3.20Try to do as shown in this [video](https://www.youtube.com/watch?v=TCnhvHUcjrY).
Try not to use the `lipo` and do everything through the terminal.
Also note that when importing frameworks, they need to set the value “Embed & Sign”.