蘋果Mach-O鏈接器錯誤。Linker命令以退出代碼1失敗。

[英]Apple Mach-O Linker Error. Linker command failed with exit code 1


My App worked fine the last couple of days, but suddenly I get this error.

我的應用程序在過去的幾天里運行良好,但我突然發現了這個錯誤。

I already tried these things:

我已經試過了

  • Restart Xcode & mac
  • 重啟Xcode & mac
  • Clean Projects
  • 清潔項目
  • Clean Derived Data Folder
  • 干凈的派生數據文件夾

Here is the error:

這是錯誤:

ld /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator/sampleappTests.xctest/sampleappTests normal x86_64
    cd /Users/someuser/Development/Workspaces/2015/ios/myapp
    export IPHONEOS_DEPLOYMENT_TARGET=8.2
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk -L/Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator -F/Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator -F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk/Developer/Library/Frameworks -F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk/Developer/Library/Frameworks -filelist /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Intermediates/sampleapp.build/Debug-iphonesimulator/sampleappTests.build/Objects-normal/x86_64/sampleappTests.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -bundle_loader /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator/myapp.app/myapp -Xlinker -objc_abi_version -Xlinker 2 -framework XCTest -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Intermediates/sampleapp.build/Debug-iphonesimulator/sampleappTests.build/Objects-normal/x86_64/sampleappTests.swiftmodule -mios-simulator-version-min=8.2 -Xlinker -dependency_info -Xlinker /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Intermediates/sampleapp.build/Debug-iphonesimulator/sampleappTests.build/Objects-normal/x86_64/sampleappTests_dependency_info.dat -o /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator/sampleappTests.xctest/sampleappTests

ld: file not found: /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dohndrkqlwlrkeggboazluaanniz/Build/Products/Debug-iphonesimulator/myapp.app/myapp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Linker flags

And here is one more warning

這里還有一個警告。

ld: warning: linking against dylib not safe for use in application extensions: /Users/someuser/Library/Developer/Xcode/DerivedData/myapp-dsaagxaaoxqxgxcwdhubkhreboeb/Build/Products/Debug-iphonesimulator/Pods/Alamofire.framework/Alamofire

2 个解决方案

#1


1  

Removing the Checkbox for the Test-Targets fixed the problem.

刪除測試目標的復選框解決了問題。

enter image description here

#2


0  

If you run into this problem with Cocoapods during unit testing, you can just add pods to your testing target and run pod update in the terminal. Here comes my example and it solves the problem:

如果在單元測試期間使用Cocoapods遇到這個問題,您可以將pod添加到測試目標中,並在終端中運行pod更新。我的例子來了,它解決了這個問題:

target 'YourProject' do
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
    use_frameworks!

    # Pods for YourProject
    pod 'RAMAnimatedTabBarController', '~> 2.0.13'
    pod 'XLPagerTabStrip', '~> 7.0'
    pod 'ZFRippleButton'
    pod 'Alamofire', '~> 4.4'
    pod 'SWXMLHash', '~> 4.0.0'
    pod 'SQLite.swift', '~> 0.11.3'
    pod 'DZNEmptyDataSet'
    pod 'PKHUD', '~> 4.0'

    target 'YourProjectTests' do
        # inherit! :search_paths
        # Pods for testing
        pod 'RAMAnimatedTabBarController', '~> 2.0.13'
        pod 'XLPagerTabStrip', '~> 7.0'
        pod 'ZFRippleButton'
        pod 'Alamofire', '~> 4.4'
        pod 'SWXMLHash', '~> 4.0.0'
        pod 'SQLite.swift', '~> 0.11.3'
        pod 'DZNEmptyDataSet'
        pod 'PKHUD', '~> 4.0'
    end

    target 'YourProjectUITests' do
        inherit! :search_paths
        # Pods for testing
    end

end

After adding pods above, run pod update.

在上面添加pod之后,運行pod更新。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/03/29/725b16fc2a90c64e935a3629afea8c80.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com