Xcode 5.0.2 dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest

折月煮酒 提交于 2019-11-27 05:42:21

问题


I have problems running a project in Xcode 5.0.2

I get the following error:

dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest
  Referenced from: /Users/chris/Library/Developer/Xcode/DerivedData/relatio-cwlmozvklaldmictbbjthzuoxnxz/Build/Products/Debug/relatio.app/Contents/MacOS/relatio

Reason: image not found (lldb)

How do I solve this issue?


回答1:


It looks like your main target is linking to XCTest.framework as well as your test target. It should only be linked to the main target.

1) Go to Project settings

2) Go to your apps main target -> other linker flags

3) remove '-framework XCTest'

4) make sure the 'other linker flags' field for your test target still contains '-framework XCTest'




回答2:


I ran into this error by renaming my targets one of which was a testing target. After reading the other answers I realized that my Build Phases > Compile Sources was including test classes as compile sources for non-test targets which then tried to import the XCTest framework.

Removing the test classes from my regular target’s Compile Sources solved this for my case.




回答3:


The problem here is that, according to the dyld error message you posted, your application is linking against XCTest.framework. That's incorrect; only your test bundle needs to link against XCTest.framework since only your test bundle contains tests.




回答4:


I had similar problem with OCMock library and solution is:

target :"Application Tests", :exclusive => true do
    pod 'OCMock'
end



回答5:


This is how I solved the problem:

  1. Navigate to the project's "Build Settings"
  2. Search for "Runpath Search Paths"
  3. Enter the following path in the column below the product name: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/



回答6:


In my main Target's "Link Binary With Libraries" (under Build Phases), it was the testing framework I was using (Nimble.framework) that was causing the problem. Removed it, and everything's fine!




回答7:


I solved this problem this way. I have edited scheme, at "Build" tab ticked "Run".




回答8:


enter the reference of your framework on framework search path AND Run path search path under "Build Settings"---...Now all set to invoke your projects by using import




回答9:


I have same issue is because i add a new file into the framework. So just run "pod install" solved my issue. But make sure your pod under Tests target too.




回答10:


Just for the ones that came up with the same issue:

Check on the lateral right menu which has to look like that:

And has not have to look like that:




回答11:


For our case, we want to use Mockingjay for both app target and test target

target 'MyProject' do
  pod 'Mockingjay/Core'
  # all pods that are not test go here

  target 'MyProjectTest' do
      inherit! :search_paths
      pod 'Mockingjay/XCTest'
      pod 'Quick', ' ~> 0.9.2'
      # .. all test pods go here
  end
end



回答12:


A solution that worked for me was changing your test target's inherit attribute in your Podfile from :search_paths to :complete. Although this answer suggests that :search_paths is designed for test environments.

target 'myapp' do    
  use_frameworks!

  target 'myappTests' do
    #inherit! :search_paths
    inherit! :complete
  end

end


来源:https://stackoverflow.com/questions/20340763/xcode-5-0-2-dyld-library-not-loaded-rpath-xctest-framework-versions-a-xctest

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