ios Xcode 4.5.1 中的“找不到文件”、“链接器命令失败,退出代码为 1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15950653/
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-08-30 23:08:49  来源:igfitidea点击:

“File not found”, “linker command failed with exit code 1” in Xcode 4.5.1

iosunit-testinglinker-errorsfile-not-found

提问by Yuvaraj.M

Am developing an existing iOS application and I have to write unit test cases for this project. It is building and running in Simulator 6.0. Whenever I try to test the project, it is showing the error message below.Am not able to figure the exact error.

我正在开发一个现有的 iOS 应用程序,我必须为这个项目编写单元测试用例。它正在 Simulator 6.0 中构建和运行。每当我尝试测试项目时,它都会显示以下错误消息。我无法弄清楚确切的错误。

id: file not found: /Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp
clag: error: linker command failed with exit code 1 (use -v to see invocation)

Could you please help me to solve this linker error and test the app?

你能帮我解决这个链接器错误并测试应用程序吗?

回答by raja

Steps to resolve:

解决步骤:

  1. Create new scheme with different name
  2. Delete old scheme

  3. Add new scheme

  1. 创建具有不同名称的新方案
  2. 删除旧方案

  3. 添加新方案

Where the problem came from:

问题出在哪里:

I changed my product name and disabled the snapshot option. Then, suddenly, this error popped out:

我更改了产品名称并禁用了快照选项。然后,突然,这个错误弹出:

ld: file not found:.././previousproductname.app/previousproductname

ld: file not found:.././previousproductname.app/previousproductname

Steps I followed unsuccessfully to debug:

我调试失败的步骤:

  1. Deleted deriveddata, restarted Xcode. - not resolved.

  2. Followed the steps of this: link http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/- same error; not resolved.

  3. Finally, I changed the Scheme name, deleted my old scheme and added new, have solved my issue.

  1. 删除了派生数据,重新启动了 Xcode。- 没有解决。

  2. 按照以下步骤操作:链接http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/- 同样的错误;没有解决。

  3. 最后,我更改了方案名称,删除了旧方案并添加了新方案,解决了我的问题。

回答by ahalls

I encountered the same error message. Turned out I had renamed my app target and had not updated the test target, Build Settings, Bundle Loader setting to my new app name.

我遇到了同样的错误信息。结果我重命名了我的应用程序目标并且没有将测试目标、构建设置、捆绑加载器设置更新为我的新应用程序名称。

More details on this setting can be found at Adding Unit Tests to an existing iOS project with Xcode 4I reviewed the same steps and it helped me fix my project in Xcode 5.

可以在使用 Xcode 4 添加单元测试到现有 iOS 项目中找到有关此设置的更多详细信息,我查看了相同的步骤,它帮助我修复了 Xcode 5 中的项目。

回答by Kuldeep

You must have changed your product name. Due to mis-match of your workspace name and product(application)name this error occurs.

您必须更改了产品名称。由于您的工作区名称和产品(应用程序)名称不匹配,会发生此错误。

You just need to replace the workspace name to product(application) name in the TEST HOST Build settings of the ProjectName-Tests targe as stated in the image. To catch up that, select to ProjectName-Tests target, select Build Settings, search for the Test Host term.

您只需要在 ProjectName-Tests 目标的 TEST HOST Build 设置中将工作区名称替换为产品(应用程序)名称,如图所示。为了赶上它,选择 ProjectName-Tests 目标,选择 Build Settings,搜索 Test Host 术语。

enter image description here

在此处输入图片说明

This is the standard configuration solution for this error.

这是此错误的标准配置解决方案。

Cheers!!

干杯!!

回答by haotang

Delete your scheme then re-create it (click new icon or using autocreate of xcode). It works for me.

删除您的方案,然后重新创建它(单击新图标或使用 xcode 的自动创建)。这个对我有用。

回答by Eli

On xcode 6 you need to:

在 xcode 6 上,您需要:

  1. go to products folder
  2. click on file .xctext
  3. on "TARGETS" choose Tests
  4. and on Host Application choose your application.
  5. Click build app.
  1. 转到产品文件夹
  2. 单击文件 .xctext
  3. 在“目标”上选择测试
  4. 并在主机应用程序上选择您的应用程序。
  5. 单击构建应用程序。

Works for me!

为我工作!

回答by bitwit

ARGH! This is a terribly frustrating issue that came out of the blue from my XCode 8.2

啊!这是一个非常令人沮丧的问题,从我的 XCode 8.2 中突然出现

In my case it came down to removing my Tests target from the scheme, building and running the main app, then readding the Tests target to the 'Test' section.

就我而言,它归结为从方案中删除我的测试目标,构建并运行主应用程序,然后将测试目标读取到“测试”部分。

It appears that the Tests target was trying to find something it wanted in the Derived Data which wasn't built yet. Running the app without trying to build tests too allowed the previously missing derived data to be prepared.

似乎测试目标试图在尚未构建的派生数据中找到它想要的东西。在不尝试构建测试的情况下运行应用程序也允许准备先前丢失的派生数据。

...Insanity is doing the same thing in XCode twice and expecting the same result :|

...Insanity 在 XCode 中做同样的事情两次并期待相同的结果:|

回答by snakeoil

Create a new scheme. The bundle id / target name / executable / project name etc. are all slightly different concepts. If you change one (as I did) the old scheme may still be set to look for the old value as the name of the executable, while the build process may have been updated to no longer build that executable.

创建一个新的方案。bundle id / target name / executable / project name等都是稍微不同的概念。如果您更改一个(就像我所做的那样),旧方案可能仍会设置为查找旧值作为可执行文件的名称,而构建过程可能已更新为不再构建该可执行文件。

回答by Owen Hartnett

Your linker is looking for a file at: /Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp

您的链接器正在查找位于以下位置的文件:/Users/Yuva/Library/Developer/Xcode/DerivedData/FlyApp-aexukpgtbathuadgxlnm/Build/Products/Debug-iphonesimulator/FlyApp.app/FlyApp

Did you follow the path to ascertain if the file is there? Note that FlyApp.app is probably a package and you'll have to "see package contents" if you're viewing from the Finder. If it's not there, either 1) you need to build FlyApp.app first, or 2) you have something in your test code that depends on it being there, which can't be determined from your question.

您是否按照路径确定文件是否存在?请注意,FlyApp.app 可能是一个包,如果您从 Finder 中查看,则必须“查看包内容”。如果它不存在,要么 1)您需要先构建 FlyApp.app,要么 2)您的测试代码中有一些依赖于它存在的东西,这无法从您的问题中确定。

回答by Askar Hussain

The answer lies on your Build Settings > Library Search Paths entry. Make sure there are no fully qualified paths listed there. Decorate them with the $SRCROOT idiom and enclose the path with double quotes. If there are any escape backslashes make sure to remove them as well.

答案在于您的构建设置 > 库搜索路径条目。确保那里没有列出完全限定的路径。用 $SRCROOT 成语装饰它们并用双引号将路径括起来。如果有任何转义反斜杠,请确保也将其删除。

Do a Clean and then Build and you should be back in business. This seem to be an issue with Xcode 5.x

先清理,然后再构建,你应该重新开始营业。这似乎是 Xcode 5.x 的问题

回答by shyam_ssr

In Xcode 11 select Product -> Scheme -> new Scheme

在 Xcode 11 中选择 Product -> Scheme -> new Scheme

this worked for me. Image

这对我有用。 图片