Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.81k stars 600 forks source link

BITCODE Link Failure #384

Closed drkibitz closed 7 years ago

drkibitz commented 7 years ago

What did you do?

Tested SwiftGit2

What did you expect to happen?

Able to link with test frameworks with BITCODE enabled.

What actually happened instead?

Failed during linking:

ld: '/src/drkibitz/SwiftGit2/DerivedData/SwiftGit2/Build/Products/Debug-iphoneos/Nimble.framework/Nimble' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I enabled BITCODE in Nimble, and was able to build and test successfully.

Environment

List the software versions you're using:

Please also mention which package manager you used and its version. Delete the other package managers in this list:

Project that demonstrates the issue

Related to SwiftGit2: https://github.com/SwiftGit2/SwiftGit2 Issue: https://github.com/SwiftGit2/SwiftGit2/issues/80

jeffh commented 7 years ago

Hey @drkibitz,

Thanks for filling an issue.

Short answer: Normally just using carthage checkout seems to work just in SwiftGit2. And as the issue that you filed on that project suggests, using the submodules will probably work fine too.


Longer answer: Bitcode is a weird state when any framework links to XCTest. It roughly approximates to the fact that XCTest doesn't actually support bitcode on any platform.

There's some trickery that goes on with xcodebuild test when linking against XCTest. xcodebuild will intelligently modify build settings (aka - disables bitcode) when building for tests. Add a tool like Carthage which builds binaries separate from a test action causes it to fail. Carthage doesn't allow Xcode to infer that the entire project is being built for tests or not.

If you'd like more context, here's two issues that cover most of it from Nimble's perspective:

I've attempted to build SwiftGit2 as your issue mentioned on SwiftGit2 and got Guanaco linker errors (carthage checkout):

xqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/Guanaco-iOS.build/Objects-normal/armv7/Guanaco (No such file or directory)
error: cannot parse the debug map for "/Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/Guanaco.framework/Guanaco": No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/GuanacoTests-iOS.build/Objects-normal/armv7/GuanacoTests (No such file or directory)
error: cannot parse the debug map for "/Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/GuanacoTests.xctest/GuanacoTests": No such file or directory
A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/jeff/workspace/SwiftGit2/Carthage/Checkouts/Guanaco/Guanaco.xcworkspace -scheme Guanaco-iOS -configuration Release -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** BUILD FAILED **

The following build commands failed:
    Ld /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/Guanaco-iOS.build/Objects-normal/armv7/Guanaco normal armv7
    Ld /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/Guanaco-iOS.build/Objects-normal/arm64/Guanaco normal arm64
    CreateUniversalBinary /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/Guanaco.framework/Guanaco normal armv7\ arm64
    GenerateDSYMFile /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/Guanaco.framework.dSYM /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/Guanaco.framework/Guanaco
    Ld /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/GuanacoTests-iOS.build/Objects-normal/armv7/GuanacoTests normal armv7
    Ld /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Intermediates/Guanaco.build/Release-iphoneos/GuanacoTests-iOS.build/Objects-normal/arm64/GuanacoTests normal arm64
    CreateUniversalBinary /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/GuanacoTests.xctest/GuanacoTests normal armv7\ arm64
    GenerateDSYMFile /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/GuanacoTests.xctest.dSYM /Users/jeff/Library/Developer/Xcode/DerivedData/Guanaco-eysiauicwtxjnxdaagvywxqejmjz/Build/Products/Release-iphoneos/GuanacoTests.xctest/GuanacoTests
(8 failures)

It seems like Guanaco needs to set ENABLE_BITCODE=NO.

If you have any other questions or issues. Feel free to reply here or open a new issue.

-Jeff