Xcode 5.0.2 dyld:库未加载:@rpath/XCTest.framework/Versions/A/XCTest

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20340763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:01:25  来源:igfitidea点击:

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

xcodedyldxctest

提问by user637338

I have problems running a project in Xcode 5.0.2

我在 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)

原因:找不到图像(lldb)

How do I solve this issue?

我该如何解决这个问题?

回答by Robert Wagstaff

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.

看起来您的主要目标正在链接到 XCTest.framework 以及您的测试目标。它应该只链接到主要目标。

1) Go to Project settings

1) 进入项目设置

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

2) 转到您的应用程序主要目标 -> 其他链接器标志

3) remove '-framework XCTest'

3) 删除'-framework XCTest'

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

4)确保测试目标的“其他链接器标志”字段仍包含“-framework XCTest”

回答by JoePasq

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 sourcesfor non-test targets which then tried to import the XCTest framework.

我通过重命名我的目标而遇到了这个错误,其中一个是测试目标。阅读其他答案后,我意识到我的 Build Phases > Compile Sources包含测试类作为非测试目标的编译源,然后尝试导入 XCTest 框架。

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

从我的常规目标的编译源中删除测试类解决了我的情况。

回答by Chris Hanson

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

这里的问题是,根据您发布的 dyld 错误消息,您的应用程序正在链接 XCTest.framework。那是不正确的;只有您的测试包需要链接到 XCTest.framework 因为只有您的测试包包含测试。

回答by Leszek Zarna

I had similar problem with OCMock library and solution is:

我对 OCMock 库有类似的问题,解决方案是:

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

回答by user637338

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/
  1. 导航到项目的“构建设置”
  2. 搜索“运行路径搜索路径”
  3. 在产品名称下方的栏中输入以下路径:/Applications/Xcode.app/Contents/Developer/Library/Frameworks/

回答by Hot'n'Young

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

我是这样解决这个问题的。我已经编辑了方案,在“构建”选项卡上勾选了“运行”。

enter image description here

在此处输入图片说明

回答by Rogare

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!

在我的主要 Target 的“Link Binary With Libraries”(在构建阶段下)中,是我使用的测试框架 (Nimble.framework) 导致了问题。删除了,一切正常!

回答by milczi

In my case It was RxTests added by Swift Package Manager to main application target. In pods you decide which Rx components add to which target, but SPM adds it all to main target as default.

就我而言,它是由 Swift Package Manager 添加到主要应用程序目标的 RxTests。在 pod 中,您决定将哪些 Rx 组件添加到哪个目标,但 SPM 默认将其全部添加到主目标。

回答by Ashok Natarajan

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

在“构建设置”下的框架搜索路径和运行路径搜索路径上输入您的框架的引用---...现在全部设置为使用导入调用您的项目

回答by William Hu

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 Teststarget too.

我有同样的问题是因为我在框架中添加了一个新文件。所以只需运行“ pod install”就解决了我的问题。但请确保您的 podTests也在目标之下。