Xcode 10 – UITests – Reason: image not found –
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 (v1.6.0.beta.1)
to install my frameworks. I’m running Xcode 10
with Swift 4.2
and iOS 12
. Also, 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:
-
Clean Xcode builds folder and deleted derived data, IOS device logs, and User Data folders.
-
Restarted Xcode, Mac, as well as my device and simulators, and recloned repository, and pod update && pod install
-
Have ‘Always embed swift standard libraries’ as yes
-
Checked my Target Application is correct
-
Made sure offending framework (MapboxGeocoder.framework) is included in Embed Pod Frameworks
Solution :
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
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