jonreid / ViewControllerPresentationSpy

Unit test presented and dismissed iOS view controllers, including alerts and action sheets
MIT License
149 stars 15 forks source link

Unit test with ViewControllerPresentationSpy will not load on an iOS 10.3.3 device #2

Closed nistap closed 3 years ago

nistap commented 3 years ago

In some of my Unit tests I use the ViewControllerPresentationSpy module, installed as a cocoaPod.

When starting a test run on an iPhone running iOS 10.3.3, the test run is aborted wit the following error message:

[2020-08-10T13:23:04.880Z] Testing failed: [2020-08-10T13:23:04.880Z] RRCNG AppTests: [2020-08-10T13:23:04.880Z] RRCNG App.app (2819) encountered an error (Failed to load the test bundle. (Underlying error: The bundle “RRCNG AppTests” couldn’t be loaded because it is damaged or missing necessary resources. The bundle is damaged or missing necessary resources. dlopen_preflight(/var/containers/Bundle/Application/4B72D919-BA08-40FC-9565-24D20271479A/RRCNG App.app/PlugIns/RRCNG AppTests.xctest/RRCNG AppTests): Library not loaded: /usr/lib/swift/libswiftXCTest.dylib [2020-08-10T13:23:04.880Z] Referenced from: /private/var/containers/Bundle/Application/4B72D919-BA08-40FC-9565-24D20271479A/RRCNG App.app/PlugIns/RRCNG AppTests.xctest/Frameworks/ViewControllerPresentationSpy.framework/ViewControllerPresentationSpy [2020-08-10T13:23:04.880Z] Reason: image not found))

============ When searching for this problem, I stumbled on the following remark:

@dvataksi16 I got a response from Apple with a non-hacky solution:

After reviewing your feedback, we have some additional information for you.

Since Xcode 11, you should be linking against libXCTestSwiftSupport.dylib instead of the old libswiftXCTest.dylib which is obsolete. The set of symbols exported by the new library should be nearly identical. Which means your "Other linker flags" should be -weak_framework XCTEST -weak-lXCTestSwiftSupport

And you should add $(PLATFORM_DIR)/Developer/usr/lib to your "Library search path"

============ See https://github.com/CocoaPods/CocoaPods/issues/9165#issuecomment-550273696 for more information.

Is it possible to look at this problem? The ViewControllerPresentationSpy is very useful in my tests, but out app has to support iOS 10 and higher at this moment, and therefore I am not able to use this library in my tests.

Thanks in advance, Nico

jonreid commented 3 years ago

Thanks for the detailed fix. If you're able to point to the tip of main branch, can you validate the change?

nistap commented 3 years ago

I'll check it

nistap commented 3 years ago

Hi John,

I repeated the tests on an iOS 10 device with the latest branch and the tests pass.

The issue is fixed. Thanks a lot 👍