SolvedCocoaPods Resources installed using cocoapods not loaded for xctest bundle

This is my output when trying to run the tests of this project (the separate-builds branch) for the PusherSwiftTests-OSX target (and scheme): https://github.com/pusher-community/pusher-websocket-swift/tree/separate-builds

2016-01-12 12:05:14.304 xctest[37573:1030574] The bundle PusherSwiftTests couldnt be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-01-12 12:05:14.305 xctest[37573:1030574] (dlopen_preflight(/Users/Hami/Library/Developer/Xcode/DerivedData/PusherSwift-cifrlthdfybbcedmlylirqthvkky/Build/Products/Debug/PusherSwiftTests.xctest/Contents/MacOS/PusherSwiftTests): Library not loaded: @rpath/CryptoSwift.framework/Versions/A/CryptoSwift
  Referenced from: /Users/Hami/Library/Developer/Xcode/DerivedData/PusherSwift-cifrlthdfybbcedmlylirqthvkky/Build/Products/Debug/PusherSwiftTests.xctest/Contents/MacOS/PusherSwiftTests
  Reason: image not found)
Program ended with exit code: 82

I initially thought this was a problem with Nimble (see this issue: Quick/Nimble#232) but it seems to actually be about the frameworks not being loaded for the xctest bundle.

Note that for the iOS and tvOS targets, this works fine, but for the OSX one it doesn't.

Let me know if I can provide any more info.

Thanks!

47 Answers

✔️Accepted Answer

For me I fixed it by setting Host Application to main target. (In Test Target -> `General)

Other Answers:

Hello guys,

Here is my (ugly?) solution to this:

  1. In your test target, add a run script at the end
  2. Put the following content as the script content

find ${TARGET_BUILD_DIR} -type d -name "*.framework" -exec cp -Rf {} ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ \;

That's it. Any better solution is welcomed, but this one worked for me (Xcode 7.3 - cocoapods 1.1.0.rc.2)

Hope this helps!

What worked for me (when copying files to the test target) is changing the pod file.

From:

platform :ios, '8.3'
use_frameworks!

target 'LogAnalytics_Example' do
  pod 'LogAnalytics', :path => '../'

  target 'LogAnalytics_Tests' do
    inherit! :search_paths

    
  end
end

to:

platform :ios, '8.3'
use_frameworks!

target 'LogAnalytics_Example' do
    pod 'LogAnalytics', :path => '../'
    
end

target 'LogAnalytics_Tests' do
    pod 'LogAnalytics', :path => '../'
    
end

That fixed it for me (and got rid of a warning regarding a framework directory that couldn't be found when running tests) (it didn't actually solve the warning).

hey @segiddins ,
Any update on this? just updated to 7.3 and we're getting hit with this now.

Just FYI for future people landing on this thread: I tried the things I found on this thread, and others, with Xcode 8.3b2 and CocoaPods 1.2, and nothing worked. Out of desperation, I recreated my UI test target, and it magically worked. So, if you have all the latest things, and nothing else has worked, maybe try that.

(I couldn't determine what the meaningful change between the old and new targets was. Too much pbxproj churn. Sadness.)

More Issues: