ios Apple Mach-O 链接器和同上错误 - Xcode 8

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

Apple Mach-O Linker & Ditto Error - Xcode 8

iosswiftxcodelinker-errors

提问by LinusGeffarth

I have just updated my Xcode to Xcode 8 and am now trying to convert my project's code to Swift 2.3. I was able to build a couple times using Xcode 8 without any errors. Now, the following errors came up:

我刚刚将我的 Xcode 更新为 Xcode 8,现在正在尝试将我的项目代码转换为 Swift 2.3。我能够使用 Xcode 8 构建几次而没有任何错误。现在,出现了以下错误:

Error #1: Apple Mach-O Linker Error: Linker command failed with exit code 1

错误 #1:Apple Mach-O 链接器错误:链接器命令失败,退出代码为 1

ld: file not found: /Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbegcsbcipdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/DownloadsViewController.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ld:找不到文件:/Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbegcsbcipdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/DownloadsViewController.o
clang错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

I don't even know what a .ofile is. The swift file of DownloadsViewControlleris there, though.

我什至不知道什么是.o文件。不过 swift 文件就DownloadsViewController在那里。

Error #2: Ditto Error: Command /usr/cin/ditto failed with exit code 1

错误 #2:同上错误:命令 /usr/cin/ditto 失败,退出代码为 1

ditto: can't get real path for source '/Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbbciegrfdpdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/MyApp-Swift.h'
Command /usr/bin/ditto failed with exit code 1

同上:无法获得源'/Users/Linus/Library/Developer/Xcode/DerivedData/MyApp-asdjeshhsetnfxbbciegrfdpdreneewgr/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/x86_64/的真实路径MyApp-Swift.h'
命令 /usr/bin/ditto 失败,退出代码为 1

The ditto error occurs 3 times: for MyApp.swiftdoc, MyApp.swiftmodule, and MyApp-Swift.h.

出现该错误同上3次:对MyApp.swiftdocMyApp.swiftmoduleMyApp-Swift.h

Thanks in advance!

提前致谢!

回答by RakeshDipuna

  1. Quit Xcode
  2. Restart the System
  3. Select Xcode -> Preferences.
    This will open a pop-up window. Select 'Locations'. In Locations, you will see 'Derived Data'. Click on the arrow icon right next to the path.
    This will open a folder containing 'Derived Data', delete it.
  4. Clean the Product and Run
  1. 退出 Xcode
  2. 重启系统
  3. 选择 Xcode -> 首选项。
    这将打开一个弹出窗口。选择“位置”。在位置中,您将看到“派生数据”。单击路径旁边的箭头图标。
    这将打开一个包含“派生数据”的文件夹,将其删除。
  4. 清洁产品并运行

回答by Agu Dondo

Make sure you open the project from the .xcworkspacefile instead of the .xcodeproj

确保从.xcworkspace文件而不是从文件中打开项目.xcodeproj

回答by Parth Changela

step 1 = clicking on the project in the navigation menu

步骤 1 = 单击导航菜单中的项目

step 2 = select the project

步骤 2 = 选择项目

step 3 = build settings

第 3 步 = 构建设置

step 4 = search enable bitcode if bitcode is yes than change to No

步骤 4 = 如果 bitcode 为是,则搜索启用 bitcode,然后更改为 No

回答by Romain TAILLANDIER

None of the previous answer have solve my problem. I think it come from changes in the cocoapods podFile, from using frameworks to not using them

以前的答案都没有解决我的问题。我认为它来自 cocoapods podFile 的变化,从使用框架到不使用它们

Frameworks was still remind in Target>General Properties>Linked Frameworks. I removed them I also remove the -framework and corresponding frameworks from other linker flags (saving inherited and objC flags)

在 Target>General Properties>Linked Frameworks 中仍然提醒 Frameworks。我删除了它们我还从其他链接器标志中删除了 -framework 和相应的框架(保存继承和 objC 标志)

Hope that could help

希望能有所帮助

回答by Carlos Linares

This happened to me after I delete my app while it was running.

在我的应用程序运行时删除它后,这发生在我身上。

I solved it cleaning the project.

我解决了清理项目的问题。

Product > Clean or Shift + Command + K

产品 > 清洁或 Shift + Command + K

回答by Ewerson

This is because at some point some project file was not compiled. In my case the AppDelegate.swift was not in the compiler. So I added it manually and it worked.

这是因为在某些时候某些项目文件没有被编译。就我而言, AppDelegate.swift 不在编译器中。所以我手动添加它并且它起作用了。

enter image description here

在此处输入图片说明

回答by Asim Olmez

For my react native app, I deleted a folder of a test project inProject Navigatorand Targets. It solved my problem.

对于我的反应本机应用程序,我删除了一个测试项目的文件夹Project NavigatorTargets。它解决了我的问题。

回答by Shijing Lv

Clean XCode with following cmds and rebuild:

使用以下命令清理 XCode 并重建:

rm -rf ~/Library/Developer/Xcode/DerivedData/
killall Xcode 2> /dev/null
killall Instruments 2> /dev/null
killall 'iOS Simulator' 2> /dev/null
killall Simulator 2> /dev/null
killall 'Simulator (Watch)' 2> /dev/null
killall ibtoold 2> /dev/null
killall simctl 2> /dev/null
# There may be others
# Kill the service itself
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator

回答by Sandip Mahajan

Don't wory ,just go to your project targat and then build setting and search enable bitcode change it to YES to NO.

别担心,只需转到您的项目 targat,然后构建设置并搜索启用位码将其更改为 YES 到 NO。

回答by PiKa

Turning Bitcode to "No" solved this issue. This is found in the Build Settings.

将 Bitcode 设置为“No”解决了这个问题。这可以在构建设置中找到。