Quick/Nimble

Building through Carthage due to missing XCTest incompatibility with Bitcode

DenTelezhkin opened this issue · 10 comments

Hi!

I'm using Carthage dependency manager and Nimble. While trying to install Nimble, here's output i get:

The following build commands failed:
    Ld DerivedData/Nimble/Build/Products/Release-appletvos/Nimble.framework/Nimble normal arm64
(1 failure)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
A shell task failed with exit code 65:
** BUILD FAILED **


The following build commands failed:
    Ld DerivedData/Nimble/Build/Products/Release-appletvos/Nimble.framework/Nimble normal arm64
(1 failure)

I opened Nimble.xcodeproj, and tried to build Nimble-tvOS framework, it fails with following output:

ld: '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/Library/Frameworks/XCTest.framework/XCTest' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm using XCode 7.1, carthage 0.9.3 and trying to pull Nimble v3.0.0 or master branch.

Any idea what is going on? Thanks in advance.

PR #210 has more info.

I see the same issue, and so far, I use the zipped binaries attached to the latest release.

jeffh commented

Are you testing on the simulator or on device?

I want to be able to test on simulator of course.

Basically, framework does not build when running carthage update, but build succeeds if i take Nimble.xcodeproj and drop it into my project.

It's not working for me for TVOS either. Right now I'm just appending --platform macosx,ios to the end of the invocation, but it feels dirty.

jeffh commented

Carthage wants to build for both device and simulator platforms into one binary. I'm not sure if there's anything we can do.

It's probably better to file a radar to apple about this. A second-best solution is to see if the carthage team would want to address this.

So what's the best way to this right now? Not use Carthage for Quick and Nimble? Any suggestions here?

mdiep commented

Here's a summary of the current status:

  • tvOS requires bitcode
  • XCTest doesn't include bitcode for tvOS
  • Consequently, Nimble can't link for tvOS on the actual device
  • Carthage always builds fat binaries that include both simulator and device slices
  • Consequently, carthage build fails for Nimble for tvOS

You can work around this by:

  • Using submodules and including Nimble.xcodeproj in your project's workspace
  • Using Carthage's --platform flag if you're not building for tvOS

I think Nimble should also be able to attach pre-built frameworks to its GitHub releases for Carthage to use. If the tvOS framework included there doesn't have a device slice, then I think things will work.

I don't think there's an easy way for Carthage to work around this. If anyone has a good idea for how to detect it generally—not special casing for Nimble.framework, but detecting that XCTest is a dependency or that a dependency doesn't have bitcode—then I'd be open to adding something to Carthage.

Ideally, Apple would include bitcode in XCTest so that this wouldn't be a problem.

I think Nimble should also be able to attach pre-built frameworks to its GitHub releases for Carthage to use. If the tvOS framework included there doesn't have a device slice, then I think things will work.

I don't think it's a good idea to make prebuilt frameworks until Swift 3.0 is released and is ABI-stable, Apple recommends against it.

I was able to use Nimble from Carthage by using submodules, and including Nimble xcodeproj in my xcodeproj, thus building from source.

So,

carthage update --use-submodules --no-use-binaries

command will fail, however it will successfully fetch all required dependencies. After initial install, I use

carthage checkout

Or update submodules to fetch latest source. It seems like an Apple stuff that needs to be fixed by including bitcode for tvOS.

mdiep commented

You can use --no-build instead of --no-use-binaries. Then the command will succeed and you can build Nimble by including the Xcode project.

Carthage 0.17 is out now and has a change to work around this issue.