简体   繁体   English

Xcode 9 - 链接器命令失败,退出代码为1

[英]Xcode 9 - linker command failed with exit code 1

While compiling the application getting as following error 编译应用程序时会出现以下错误

" compiled with older version of Swift language (3.0) than previous files (4.0) file " “使用旧版本的Swift语言(3.0)编译,而不是以前的文件(4.0)文件”

Could you please help me? 请你帮助我好吗?

Use the xcworkspace to build instead of the xcproject? 使用xcworkspace来构建而不是xcproject?

This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries. 这通常发生在使用Cocoapods并且您正在使用不知道cocoapod库的xcproject构建时。

Delete the derived data and do a clean build. 删除派生数据并执行干净构建。

And if you are building a framework, make sure you've selected Generic IOS Device while building or set the Build for Active Architecture only as true in Build Settings . 如果您正在构建框架,请确保在Build Settings Build for Active Architecture only选择Generic IOS Device ,或者在Build Settings中将Build for Active Architecture only Build Settings为true。

I think this happens because you changed your app name or maybe the target 我认为这是因为您更改了应用名称或目标

look to solve this problem see your target in Podfile 期待解决此问题,请在Podfile中查看您的目标

and then come back to your xcode in the targets select your target app and in linked Frameworks and Libraries (the last one down) see if there's any pods with light color and a strange name than your target in the podfile and remove it using the minus button down . 再回过头来在目标 Xcode的选择目标应用程序,并在链接的框架和库 (最后一跌),看看是否有浅色和一个陌生的名字比podfile目标的任何吊舱和使用减号删除按下按钮。

I'd rather fix the specific problem, but if none of the other answers worked a full reset can solve it. 我宁愿修复具体问题,但如果没有其他答案工作,完全重置可以解决它。 If you are getting this error and you are also getting error readouts that refer to "duplicate symbol files", AND all other efforts have failed, then a full reset could work for you. 如果您收到此错误并且您还收到引用“重复符号文件”的错误读数,并且所有其他工作都失败了,那么完全重置可能对您有用。

What worked for me: 什么对我有用:

  1. Read the error report to identify the repo that supposedly contains duplicate files. 阅读错误报告以确定应该包含重复文件的repo。
  2. Drag repo to the trash. 将repo拖到垃圾箱。
  3. re-clone your repo. 重新克隆你的回购。
  4. set up your repo with correct remote tracking. 使用正确的远程跟踪设置您的仓库。 git remote add <url.git> , or git remote set-url <url.git> git remote add <url.git> ,或git remote set-url <url.git>

This absolutely worked for me. 这绝对适合我。 In my case for some elusive reason, when I ran git pull upstream develop for a local dependency, git would pull in/generate duplicate files from multiple commits. 在我的情况下,由于一些难以捉摸的原因,当我运行git pull upstream develop本地依赖时, git将从多个提交中引入/生成重复文件。

After following the above steps, the issue went away and git pull upstream develop was no longer pulling from multiple commits at once. 按照上述步骤后,问题就消失了, git pull upstream develop不再一次从多次提交中撤出。 Perhaps there was a weird git cache for my repo. 也许我的回购有一个奇怪的git缓存。

I am probably late for you, but for future devs in problems... 我可能会迟到,但对于未来的开发人员来说......

If you have been manipulating the podfile or creating new targets or maybe changing the name of any of them, check that in build phases options your just have correct pod framework for the name of the targets. 如果您一直在操作podfile或创建新目标或者可能更改其中任何一个的名称,请检查在构建阶段选项中您是否拥有正确的目标名称的pod框架。

I had the two copies of files in the codebase. 我在代码库中有两个文件副本。 Deleting one copy helped code to build successfully 删除一个副本有助于代码成功构建

如果你有pod第一个清理项目并关闭Xcode然后打开终端并转到Project的文件夹然后pod update打开项目并在我的案例工作中运行!

I fixed this problem today by running the app in the simulator using the target associated with the bundle file named in the Build Settings-->Bundle Loader setting of the test target. 我今天修复了这个问题,方法是使用与测试目标的Build Settings - > Bundle Loader设置中指定的bundle文件相关联的目标在模拟器中运行app。 Previously I had deleted my derived data folder while working on a different target that has a different Product Name than the one associated with the test target bundle file. 以前我在使用不同的目标时删除了我的派生数据文件夹,该目标的产品名称与与测试目标捆绑文件关联的产品名称不同。 Rerunning the app in the simulator must have recreated the bundle file in the derived data folder that the test target is looking for and then my tests started running fine. 在模拟器中重新运行应用程序必须在测试目标正在查找的派生数据文件夹中重新创建捆绑文件,然后我的测试开始正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM