Hi there.
I've recently tried to build our SDK (a XCFramework built from a SPM package for iOS) as a mergeable library and immediately ran into a problem where MainActor.assumeIsolated
crashed with a EXC_BAD_ACCESS
. Even merely accessing MainActor.shared
lead to the same crash.
I'm wondering if I've configured something wrong and appreciate if someone could shed any light on this.
I'm attaching a small sample project, which consists of the following parts:
- A Swift package
MyLibrary
which exports a functiondoSomething()
which accessesMainActor.shared
and prints "Hello World" afterwards. The library target is configured to be mergeable (.unsafeFlags(["-Wl,-make_mergeable"])
) - A bash script
build.sh
to build the XCFramework from the Swift package - An app project
TestApp
which consumes the XCFramework and callsdoSomething()
To reproduce:
Build the XCFramework by running ./build.sh
or use the bundled one from the zip. Then build & run the TestApp
project in Release mode with MERGED_BINARY_TYPE
set to automatic
(should already be the case).
Result:
The app crashes
Expected result:
"Hello World" should be printed to the console.
Alternatively you can either run the app in Debug mode or set MERGED_BINARY_TYPE = none
and run in either mode to get the desired console output.