Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild from Bitcode fails on watchOS #999

Open
daltonclaybrook opened this issue Oct 16, 2020 · 11 comments
Open

Rebuild from Bitcode fails on watchOS #999

daltonclaybrook opened this issue Oct 16, 2020 · 11 comments
Labels
kind/bug Feature doesn't work as expected.

Comments

@daltonclaybrook
Copy link
Contributor

daltonclaybrook commented Oct 16, 2020

Describe the bug

Xcode version: 12.0.1 (12A7300)
grpc-swift version: 1.0.0-alpha.20

When linking a watchOS app with grpc-swift, the app compiles and runs successfully. But attempting to distribute the app and rebuild from Bitcode (required for App Store release) results in a failure:

ipatool failed with an exception: #<CmdSpec::NonZeroExitException

(more output in attached log below)

To reproduce

  1. Create a new watchOS project in Xcode. This can be a standalone Watch app or iOS companion. It doesn't matter.
  2. Add grpc-swift as a dependency of the Watch extension with File -> Swift Packages -> Add Package Dependency... Important: When selecting the "GRPC" library, you will need to change the target on the righthand side from the iOS app to the WatchKit extension. The Watch extension is not selected by default.
  3. Archive the app with Product -> Archive
  4. After the archive is finished, the Xcode Organizer window will appear. Select "Distribute App"
  5. Select "Ad Hoc" as the method of distribution
  6. Important: On the next screen, make sure "Rebuild from Bitcode" is checked. The other fields don't matter. Select "Next"
  7. Proceed through the next screen until the app starts rebuilding from Bitcode.
  8. Observe the error

Expected behavior

Xcode should be able to rebuild the app successfully from Bitcode, and you should be able to export the Ad Hoc IPA file afterward.

Actional behavior

The Rebuild from Xcode step fails and the IPA file cannot be exported. I've attached the build log file that contains additional output from the build tool.

bitcode.log

@daltonclaybrook daltonclaybrook added the kind/bug Feature doesn't work as expected. label Oct 16, 2020
@daltonclaybrook
Copy link
Contributor Author

As a test, I excluded the armv7k architecture from the build and am still seeing the same error, but now referencing the arm64_32 slice.

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 16, 2020

I cannot reproduce this locally: I am able to package grpc-swift for watchOS with "Rebuild from bitcode" enabled. I recommend filing a feedback request with Apple using feedbackassistant.apple.com, as this sounds like it may be an Xcode issue. Please leave the feedback number here if you do so.

@daltonclaybrook
Copy link
Contributor Author

daltonclaybrook commented Oct 16, 2020

Do you mind sharing what version of Xcode you used for your test? I have tried on Xcode 11.6, 12.0.1, and 12.1 GM, and each one fails. Here is my test project where the failure occurs. Would you be willing to try again with this project? Thank you for your patience with this.
BitcodeTest.zip

FYI, I updated the report above to include additional details in step 2 that are easy to miss, namely:

When selecting the "GRPC" library, you will need to change the target on the righthand side from the iOS app to the WatchKit extension. The Watch extension is not selected by default.

@daltonclaybrook
Copy link
Contributor Author

I have created a new project following the steps above, but linking a different Swift package (Alamofire), and this issue does not occur on the new project. Here it is in case you are interested:
AlamofireBitcode.zip

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 16, 2020

I was using 12.1 GM.

Can you provide full details of your configuration? macOS version (including build number) and Xcode version (including build number)? I'll try to put together that environment and see if I can reproduce it. I recommend filing an issue with Feedback Assistant anyway, as my success indicates that the issue isn't with Xcode per se.

@daltonclaybrook
Copy link
Contributor Author

macOS 10.15.7 (19H2)
Xcode 12.1 GM (12A7403) (or Xcode 12.0.1 (12A7300))

I'm happy to provide any other details you need. I will also file the feedback report very soon and reply with the issue number. One other important detail I can share: I started to discover this issue when I uploaded a build to App Store Connect. The upload succeeded, but a few minutes later, I received an email from Apple with this message:

ITMS-90562: Invalid Bundle - Bitcode failed to compile for your watchOS binary because it includes assembly source code or inline assembly. To resolve this issue, rewrite the corresponding code in a higher-level language such as Objective-C or Swift and redeliver your app.

@daltonclaybrook
Copy link
Contributor Author

I have created the feedback report with Apple and the number is FB8806154. As a test, I followed these repro steps again, but this time using just the Swift NIO package instead of grpc-swift, and the app was able to rebuild from Bitcode without error. This strengthens my suspicion that this is an issue with grpc-swift and not with Xcode. I will attempt to reproduce this on another computer today, and I've asked a few colleagues to try to reproduce as well. I will comment again when I have more information. As you might have inferred, this issue is hugely important for myself and my organization as we are not able to distribute through the App Store without a fix.

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 16, 2020

It may be worth trying with swift-nio-ssl. This is an unusual project in that it contains assembly files, which may be relevant.

@daltonclaybrook
Copy link
Contributor Author

@Lukasa Just tried and swift-nio-ssl fails in the same way! Thanks for the great tip! I will try each of the other dependencies of grpc-swift and create issues on relevant repos. Thanks!

@Lukasa
Copy link
Collaborator

Lukasa commented Oct 16, 2020

This will likely be just a watchOS problem. It seems that watchOS won’t allow submitting direct assembly code, so we probably just need to update that repo to remove the assembly on watchOS.

@dweekly
Copy link

dweekly commented Nov 19, 2021

Note that the Swift-NIO-SSL issue itself depends on a Swift issue: https://bugs.swift.org/browse/SR-14109

If this is impacting you, you may want to consider voting for the bug on the Swift board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Feature doesn't work as expected.
Projects
None yet
Development

No branches or pull requests

3 participants