Running unit tests on iOS 11 device from Xcode 14 fails

There appears to be an interoperability issue between Xcode 14 and iOS 11 devices. Specifically with libswiftCoreGraphics.dylib. I build a Swift based framework that has a deployment target of iOS 11. When I build the SDK with Xcode 13.4.1 and run the unit tests on iOS 11, everything works as expected. When I switched to Xcode 14, it continually fails when attempting to run the unit tests on an iOS 11 device. I began digging into this and was trying to determine if it was an issue with some dependency or something in my project.

I created a test project with Xcode 13.4.1, Xcode14-iOS11_Bug, which consists of a simple Swift application and one unit test file. When I run the unit from Xcode 13.4.1 targeting an iPhone 7 running iOS 11.4.1, it runs as expected.

I then opened the same project with Xcode 14 and attempted to run the unit test I am greeted with the same error about libswiftCoreGraphics.dylib not being loaded.

2022-09-14 15:19:00.871686-0400 Xcode14-iOS11_Bug[616:100103] Failed to load test bundle from file:///var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
  Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib
  Reason: image not found" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests, NSDebugDescription=dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
  Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib
  Reason: image not found, NSBundlePath=/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest, NSLocalizedDescription=The bundle “Xcode14-iOS11_BugTests” couldn’t be loaded because it is damaged or missing necessary resources.}
2022-09-14 15:19:01.221551-0400 Xcode14-iOS11_Bug[616:100103] The bundle “Xcode14-iOS11_BugTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2022-09-14 15:19:01.221599-0400 Xcode14-iOS11_Bug[616:100103] (dlopen_preflight(/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/PlugIns/Xcode14-iOS11_BugTests.xctest/Xcode14-iOS11_BugTests): Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
  Referenced from: /private/var/containers/Bundle/Application/5E87802C-9C84-48FD-9D2D-8441983B61E8/Xcode14-iOS11_Bug.app/Frameworks/libXCTestSwiftSupport.dylib
  Reason: image not found)

From what I have read, Xcode 14 is still supposed to have iOS 11 support, so it would appear something is broken.

I have filed FB11512459 for this issue.

Replies

I also encountered the same problem, do you have a solution

My situation is the same as yours. Xcode 13.4.1 runs and packages normally under iOS11 - iOS2.2, and crashed directly under Xcode 14. My solution is to make the following settings in each target (including Pods target) using Swift under Xcode14: General ->Frameworks and Libraries Add a reference to libswiftCoreGraphics.tbd, and it will be normal after re running and packaging

Just found a way to work around here: https://developer.apple.com/forums/thread/714795 It saved my day and hope you do too.