Xcode 10 - UITests - Reason: image not found

两盒软妹~` 提交于 2019-12-03 11:14:47

问题


I'm trying to run the UItests for my app but it's crashing as soon as it loads. Here's the error.

2018-09-29 16:19:49.577151+1000 xxxUITests-Runner[6007:69633] (dlopen_preflight(/Users/Acc/Library/Developer/Xcode/DerivedData/xxx-bjuwemcifadxhlhgojgfktmmades/Build/Products/Debug-iphonesimulator/xxxUITests-Runner.app/PlugIns/xxxUITests.xctest/xxxUITests): Library not loaded: @rpath/libswiftContacts.dylib
  Referenced from: /Users/Acc/Library/Developer/Xcode/DerivedData/xxx-bjuwemcifadxhlhgojgfktmmades/Build/Products/Debug-iphonesimulator/xxxUITests-Runner.app/PlugIns/xxxUITests.xctest/Frameworks/MapboxGeocoder.framework/MapboxGeocoder
  Reason: image not found)

I'm using CocoaPods(1.6.0.beta.1) to install my frameworks. I'm running Xcode10 with swift 4.2 and IOS 12. Git is used as version control with other developers (Perhaps there're conflicts?).

My target app works perfectly, both on a simulator and a real phone, and so does my unit tests. But my UITest target fails as soon as it launches up. This problem happens on both a simulator and a real machine.

There have been many posts on the issue before, but none of them have helped me so far. I've had 2 isolated occurrences before, the first time I've solved by adding dependencies into my pod file for the UITest unit, and the second time by simply removing my target and copy & pasting the classes back into the new target (unconstructive, but last resort). I can do the same this time as well but it's a bit of a waste of time and I'm afraid that this will crop up again in the future.

This is what I've done so far:

  1. Clean Xcode builds folder and deleted derived data, IOS device logs, and User Data folders.

  2. Restarted Xcode, Mac, as well as my device and simulators, and recloned repository, and pod update && pod install

  3. Have 'Always embed swift standard libraries' as yes

  4. Checked my Target Application is correct

  5. Made sure offending framework (MapboxGeocoder.framework) is included in Embed Pod Frameworks


回答1:


So after 5 days, I managed to solve my own problem.

I solved it by moving my UITests target out of the scope of my main app in Podfile.

From:

target 'App' do
    use_frameworks!

    pods 'Firebase'

    target 'AppUITests' do
        pods 'Testingpod'
    end
end

To:

target 'App' do
    use_frameworks!

    pods 'Firebase'
end

target 'AppUITests' do
    pods 'Testingpod'
end



回答2:


Has found another solution suggested in Cocoapods issue.

As my project is a framework, so the test does not have a host application.

Changed Podfile

target 'framework' do
    use_ frameworks!
    pods my_dependencies
    target 'framework_tests' do
        inherit! :search_paths
    end
end

To

target 'framework' do
    use_ frameworks!
    pods my_dependencies
    target 'framework_tests'
end

https://github.com/CocoaPods/CocoaPods/issues/8139



来源:https://stackoverflow.com/questions/52566702/xcode-10-uitests-reason-image-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!