I've installed Xcode 10 and upgraded my iOS application to Swift 4.2. When I run my tests (both UI and Unit) via Xcode, on an iPhone simulator running iOS 12, the tests successfully start. When I attempt to run the tests on a simulator running a prior iOS version (e.g. iOS 10.3.1), I get a "failure to load the test bundle". These tests were running successfully on Xcode 9.4. I can run my app on this older simulator without an issue.
The Xcode output is as follows ("Reading List" is the application name):
2018-09-16 15:11:36.667 ReadingList[11401:11478426] Failed to load test bundle from file:///Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests): no suitable image found. Did find: /Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests: mach-o, but not built for iOS simulator" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests, NSDebugDescription=dlopen_preflight(/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests): no suitable image found. Did find: /Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests: mach-o, but not built for iOS simulator, NSBundlePath=/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest, NSLocalizedDescription=The bundle “ReadingList_UnitTests” couldn’t be loaded because it is damaged or missing necessary resources.}
The line mach-o, but not built for iOS simulator
seems like it could be key. How can I resolve this?
In the Project Navigator, select the project file. Select the Target in the Project configuration window. Select Build Settings tab, (Basic and Levels) Scroll down to iOS Deployment Target and then select the desired OS version.
That solved the problem for me. cheers rgds Dave
The test targets had the iOS Deployment Target
setting left as the default value.
In Xcode 9.4, this is equal to "iOS 11.4", yet the tests can still be run on an "iPhone 7 (10.3)" simulator for some reason. In Xcode 10, there seems to be a change in behaviour since the tests no longer run on simulators running iOS versions prior to the default "iOS 12".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With