Xcode 苹果 Mach-O 链接器错误 1

10
在重命名了我的项目之后,每当我尝试构建应用程序时,都会收到一个“Apple Mach-O Linker Error”错误。以下是来自Xcode本身的输出:

在重命名项目后构建应用程序时出现“Apple Mach-O 链接器错误”。以下是来自Xcode本身的输出:

Ld /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/Broadcast!Tests.xctest/Broadcast!Tests normal x86_64
    cd "/Users/joshevans/Desktop/sn app/SwifferApp"
    export IPHONEOS_DEPLOYMENT_TARGET=8.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk
-L/Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator
-F/Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks
-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/Developer/Library/Frameworks
-filelist /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast!Tests.LinkFileList
-Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -bundle_loader /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/SwifferApp.app/SwifferApp
-Xlinker -objc_abi_version -Xlinker 2 -framework XCTest -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
-Xlinker -add_ast_path -Xlinker /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast_Tests.swiftmodule
-mios-simulator-version-min=8.0 -Xlinker -dependency_info -Xlinker /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Intermediates/Broadcast!.build/Debug-iphonesimulator/Broadcast!Tests.build/Objects-normal/x86_64/Broadcast!Tests_dependency_info.dat
-o /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/Broadcast!Tests.xctest/Broadcast!Tests ld: file not found: /Users/joshevans/Library/Developer/Xcode/DerivedData/Broadcast!-gbvxmzbukuqqgxcmlipegtnzosze/Build/Products/Debug-iphonesimulator/SwifferApp.app/SwifferApp clang: error: linker command failed with exit code 1 (use -v to see invocation)

感谢您的帮助,因为我对Xcode和Swift语言都很陌生。 Josh


Clang 建议使用 -v 以查看调用。你试过了吗? - johnnieb
我对Xcode不熟悉,最好的方法是什么? - Josh
你的项目名称中包含感叹号吗? - Acey
是的,产品名称是Broadcast!而且捆绑标识符是com.wasd.broadcast-,这可能会导致问题吗? - Josh
我已经再次重命名了项目,省略了感叹号,但仍然没有运气,构建时仍会出现相同的错误。 - Josh
@josh2205 我们如何更改项目名称? - Allister Bah
2个回答

34

将名称更改后,请转到项目文件(您将看到选项卡:常规、功能、信息等)

在左侧列表中选择 YourAppTests

进入图像描述

您可能会看到这张图片 进入图像描述

将主机应用程序设置为项目名称即可。


2
非常感谢!我不知道它是如何进入这种状态的。 - JZ.
2
救命稻草!在重命名后,我按照您的指示更改后,一切都完美了!非常感谢。我的设置在Xcode 6上是自定义的,现在更改为新名称 - 完美。 - ZipNFC
1
我们在天上的父啊,愿人都尊你的名为圣。愿你的国降临,愿你的旨意行在地上,如同行在天上。求主赐福给mutant_america,因他在解决问题时给出了卓越的答案。阿门。 - GeneCode

0

在尝试实现AdMob广告时,我偶尔会遇到Apple Mach-O Linker Error 1。我处理它的方法是首先进入我的应用程序的构建设置,找到“库搜索路径”并清除所有搜索路径。然后,我重新将AdMob文件夹添加到项目中,错误就消失了。

现在显然你的情况有些不同。个人建议将文件重命名为以前的名称。如果错误仍然存在,则清除库搜索路径。还是出现错误?当我一直收到错误时,我创建了一个新的Xcode项目,并将所有文件复制到新项目中。这是一个简单的过程,特别是对于初学者来说,可能不会花费太长时间。希望这可以帮助到你!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接