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

Add2App [Option A&B] with plugins failed to build because plugins was built without full bitcode #48092

Closed
nailgilaziev opened this issue Jan 2, 2020 · 27 comments · Fixed by #49102 or #73072
Assignees
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P2 Important issues not at the top of the work list platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@nailgilaziev
Copy link

This is a next step of an issue described here #47930 and all preparation steps is the same.
But now before building .xcframework just add to my_flutter module some plugin dependencies.
I added most popular shared_preferences plugin to pubspec.yaml and added example code to main.dart file.
Next

flutter build ios-framework --output=../host_ios/embed/ --xcframework --no-universal

produce

App.framework
Flutter.xcframework
FlutterPluginRegistrant.xcframework
shared_preferences.xcframework

Applying them to xcode pbxproj -> build -> error

ld: bitcode bundle could not be generated because '/Users/n/Library/Developer/Xcode/DerivedData/host_ios-bnbwehcmdjzqgydxspnsnfifvdyh/Build/Intermediates.noindex/ArchiveIntermediates/host_ios/BuildProductsPath/Release-iphoneos/shared_preferences.framework/shared_preferences' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/n/Library/Developer/Xcode/DerivedData/host_ios-bnbwehcmdjzqgydxspnsnfifvdyh/Build/Intermediates.noindex/ArchiveIntermediates/host_ios/BuildProductsPath/Release-iphoneos/shared_preferences.framework/shared_preferences' for architecture arm64

I checked this situation with another plugin - path_provider - result the same.

If I try to disable bitcode I get another error:
headerr
with this logs:
IDEDistribution.critical.log
IDEDistribution.standard.log
IDEDistribution.verbose.log

@nailgilaziev
Copy link
Author

nailgilaziev commented Jan 2, 2020

This issue was on
Flutter (Channel master, v1.13.6-pre.48, on Mac OS X 10.15.2 19C57, locale en-RU)
upgraded ~ 3 hour ago, but after (when I writing this issue) new version released, so...

additionally I upgraded to currently latest:

Flutter 1.13.7-pre.8 • channel master • https://github.com/flutter/flutter.git
Framework • revision dc99d61e5d (2 hours ago) • 2020-01-02 13:03:01 -0800
Engine • revision fa05d367ad
Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 b52d264f5b)

and repeat test:
Result the same - bitcode error
PS now building frameworks generate App.xcframework, not the App.framework as before.

@jmagman jmagman added a: existing-apps Integration with existing apps via the add-to-app flow tool Affects the "flutter" command-line tool. See also t: labels. platform-ios iOS applications specifically labels Jan 2, 2020
@nailgilaziev
Copy link
Author

You doesn’t apply severe label.
Any workaround exist for this problem? If yes - I will apply it for publishing my app to the TestFlight.

@jmagman jmagman added this to Engineer reviewed in Add-to-app - iOS tool review Jan 6, 2020
@jmagman jmagman removed this from Engineer reviewed in Add-to-app - iOS tool review Jan 6, 2020
@jmagman jmagman added this to Engineer reviewed in Add-to-app - iOS tool review Jan 6, 2020
@jmagman
Copy link
Member

jmagman commented Jan 7, 2020

I need to try this, I'm not sure what's going on and don't have a workaround at the moment.

@Magsumov2
Copy link

Hello! @jmagman , please tell me - When will it be fixed? I meet the same issue and I can not release application because of this error! thanks

@nailgilaziev
Copy link
Author

@jmagman , I tried to add flutter module to app via Option A - cocoapods script, recommended way
But when archive this error occurs:

bitcode bundle could not be generated because '/Users/n/pubios/my_flutter/.ios/Flutter/engine/Flutter.framework/Flutter' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/n/pubios/my_flutter/.ios/Flutter/engine/Flutter.framework/Flutter' for architecture armv7

@nailgilaziev
Copy link
Author

nailgilaziev commented Jan 9, 2020

to make sure I'm doing everything right and to provide more information for you I do everything from scratch with latest flutter version:

[✓] Flutter (Channel master, v1.13.8-pre.58, on Mac OS X 10.15.2 19C57, locale en-RU)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)

I create new flutter module
flutter create --template module my_flutter
create new xcode project and then configure pod file and reopen .xcworkspace

with simplest flutter module(no pub dependencies) everything compiles and successfully uploads to AppStore.
But when I add dependency to flutter module and try to build and upload again I meet the error on archive:

bitcode bundle could not be generated because ... was built without full bitcode....

2err

@jmagman jmagman moved this from Engineer reviewed to Reviewed in Add-to-app - iOS tool review Jan 9, 2020
@nailgilaziev nailgilaziev changed the title Add2App [Option B] with plugins failed to build because plugins was built without full bitcode Add2App [Option A&B] with plugins failed to build because plugins was built without full bitcode Jan 10, 2020
@jmagman jmagman moved this from Awaiting triage to Engineer reviewed in Tools - existing app integration review Jan 13, 2020
@jmagman
Copy link
Member

jmagman commented Jan 14, 2020

Need integration tests that not just build the host app, but archive and validate it, too.

  1. Found an unexpected Mach-O header code: 0x72613c21
2020-01-14 02:56:03 +0000  Failed to generate distribution items with error: Error Domain=DVTMachOErrorDomain Code=0 "Found an unexpected Mach-O header code: 0x72613c21" UserInfo={NSLocalizedDescription=Found an unexpected Mach-O header code: 0x72613c21, NSLocalizedRecoverySuggestion=}

Xcode project settings > Build Settings > Embed Frameworks and remove FlutterPluginRegistratant.framework (or xcframework). Keep it in Link Binary With Libraries.

This is a static framework, not a dynamic one...
I will update the docs. Hopefully this unblocks you.

  1. Plugin framework was built without full bitcode.
ld: bitcode bundle could not be generated because '/Users/n/Library/Developer/Xcode/DerivedData/host_ios-bnbwehcmdjzqgydxspnsnfifvdyh/Build/Intermediates.noindex/ArchiveIntermediates/host_ios/BuildProductsPath/Release-iphoneos/shared_preferences.framework/shared_preferences' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/n/Library/Developer/Xcode/DerivedData/host_ios-bnbwehcmdjzqgydxspnsnfifvdyh/Build/Intermediates.noindex/ArchiveIntermediates/host_ios/BuildProductsPath/Release-iphoneos/shared_preferences.framework/shared_preferences' for architecture arm64

I believe this one is because the plugins are being built instead of archived, and so aren't being created with bitcode. I'm about to put out a pull request to fix this one.

  1. Flutter was built without full bitcode
bitcode bundle could not be generated because '/Users/n/pubios/my_flutter/.ios/Flutter/engine/Flutter.framework/Flutter' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/n/pubios/my_flutter/.ios/Flutter/engine/Flutter.framework/Flutter' for architecture armv7

I believe this could happen if flutter build --debug was last run in the module and there's a debug version of Flutter at the vendored_framework path. The release version should be re-copied when the [CP-User] Run Flutter Build Script build phase runs in the host app, though. I need to look into this one more.
In the meantime, try running flutter build --release in your Flutter module, then re-try pod install from your host app.

@nailgilaziev
Copy link
Author

@jmagman, Does you(or team) need any tests or clarifications from me?
This issue is blocking and no other ways to workaround it.
Adding flutter module with some pub dependencies to host app currently not working at all.
Does not work in either the stable or master channel. neither option A nor B
Please help.

@jmagman
Copy link
Member

jmagman commented Jan 14, 2020

@nailgilaziev Did you try my suggestions above?

For option A (CocoaPods) try running flutter build ios --release in the Flutter module.

For option B (generating frameworks) disable bitcode in your host app, and remove FlutterPluginRegistratant.framework (or xcframework) from the Embed Frameworks build phase. It's a static framework and so should be linked on and not embedded. Depending on what plugins you have, you may also need to do the same for them. Run:

$ grep -riI "static_framework" .ios/Pods

to see which podspecs (CocoaPods metadata per plugin) should also be removed.

@nailgilaziev
Copy link
Author

@jmagman , sorry, I didn't saw you message when writing "help" :) my bad. I will try it now and get feedback today

@nailgilaziev
Copy link
Author

yeah, option B with excluded FlutterPluginRegistratant.framework (or xcframework) from Embed Frameworks phase is working!
Thanks! I already released long-awaited release!

@jmagman jmagman self-assigned this Jan 16, 2020
@jmagman jmagman added this to the February 2020 milestone Jan 16, 2020
@jmagman jmagman added this to To do in Add-to-app 2020Q1 via automation Jan 16, 2020
@jmagman jmagman moved this from To do to In progress in Add-to-app 2020Q1 Jan 16, 2020
@jmagman
Copy link
Member

jmagman commented Jan 17, 2020

@isacjunior
Copy link

isacjunior commented Feb 7, 2020

@jmagman I believe that is important to add in website(docs) to recommend run flutter build before pod install for these reasons above and for another reason that I'll explain below:

When I create a new flutter module, flutter script will create a .ios folder and after I run pod install, the script inside podhelper.rb will create an App.framework used in Pods only with arch x86_64.

To reproduce:

flutter create --template=module example
cd ios_app
pod install

Because app_framework_dylib doesn't exist will create App.framework.

`echo "static const int Moo = 88;" | xcrun clang -x c -dynamiclib -o "#{app_framework_dylib}" -`

When I use File to show more details, this is output:

App: Mach-O 64-bit dynamically linked shared library x86_64

For resolving this, run build with the mode that you need before, for example:

flutter build ios --release --no-codesign

When I use File now, these are output:

App: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm64]
App (for architecture armv7):	Mach-O dynamically linked shared library arm_v7
App (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64

Question:
For a particular reason, I need architecture x86_64 when I create the framework with Release mode, it possible? Some workaround?

Doctor:

[✓] Flutter (Channel unknown, v1.14.4, on Mac OS X 10.14.6 18G2022, locale en-BR)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (1 available)

@jmagman
Copy link
Member

jmagman commented Feb 7, 2020

For a particular reason, I need architecture x86_64 when I create the framework with Release mode, it possible? Some workaround?

Flutter is not supported in the simulator (x86_64) in release mode. See #11754.

@jmagman jmagman removed this from Awaiting triage in Mobile Platforms - iOS add-to-app review Feb 27, 2020
@Hixie Hixie modified the milestones: February 2020, Overdue Mar 3, 2020
@jmagman jmagman removed this from the Overdue milestone Mar 3, 2020
@l3ender
Copy link

l3ender commented Apr 11, 2020

Hello, just wanted to drop a quick note thanking you for the detail in this issue and the related PR. We are not flutter users, but came across similar iOS build errors in our app that links against frameworks from a different project. The frameworks are delivered after being built (not archived), so the fix to build with BITCODE_GENERATION_MODE=bitcode was very helpful for us. Thank you!

@Sauraus
Copy link

Sauraus commented Apr 17, 2020

Hello, just wanted to drop a quick note thanking you for the detail in this issue and the related PR. We are not flutter users, but came across similar iOS build errors in our app that links against frameworks from a different project. The frameworks are delivered after being built (not archived), so the fix to build with BITCODE_GENERATION_MODE=bitcode was very helpful for us. Thank you!

Where and how do you set this?

@RDyego
Copy link

RDyego commented Apr 20, 2020

Hello, just wanted to drop a quick note thanking you for the detail in this issue and the related PR. We are not flutter users, but came across similar iOS build errors in our app that links against frameworks from a different project. The frameworks are delivered after being built (not archived), so the fix to build with BITCODE_GENERATION_MODE=bitcode was very helpful for us. Thank you!

Where and how do you set this?
Look on xcode:
image
OR:
image

@Sumit-Ghosh
Copy link

Sumit-Ghosh commented Aug 23, 2020

Even I am facing this bitcode issue with webview_flutter plugin.
I am using option A that is added to the app via Cocoapods.

macOS: 10.15.3 (Catalina)
Xcode version: 11.0 (11A420a)
Flutter version: Channel stable, 1.20.2

@bawantha
Copy link

Even I am facing this bitcode issue with webview_flutter plugin.
I am using option A that is added to the app via Cocoapods.

macOS: 10.15.3 (Catalina)
Xcode version: 11.0 (11A420a)
Flutter version: Channel stable, 1.20.2

same

@jmagman
Copy link
Member

jmagman commented Feb 10, 2021

#73072 is available on 1.26.0-12.0.pre, which is currently available on the master, dev, and beta channels.

@uerceg
Copy link

uerceg commented Mar 19, 2021

Hi @jmagman

Sorry for ping on closed issue, but seems like I am still facing this even with latest stable build:

flutter doctor -v output
[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
    • Flutter version 2.0.2 at /Users/uerceg/Development/flutter
    • Framework revision 8962f6dc68 (7 days ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/uerceg/Development/android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/uerceg/Development/android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2020.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 53.1.5
    • Dart plugin version 203.6912

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[✓] Connected device (3 available)
    • Pixel 4a 5G (mobile)      • 0B061JECB12057            • android-arm64  • Android 11 (API 30)
    • Uglješa’s iPhone (mobile) • 00008030-0011104A228B802E • ios            • iOS 14.5
    • Chrome (web)              • chrome                    • web-javascript • Google Chrome 89.0.4389.90
    ! Error: Living Room is not connected. Xcode will continue when Living Room is connected. (code -13)

• No issues found!

We're developing the plugin which is added to the app where this is reproducible. You can find the app project in here in case you want to reproduce this.

As described in our repo issue, using Release build configuration does the trick as workaround to be able to run the app on iOS device. Is this still supposed to be like that?

Cheers

@jmagman
Copy link
Member

jmagman commented Mar 19, 2021

@uerceg adjust/flutter_sdk#42 sounds like it's a normal Flutter app trying to consume your plugin, not necessarily add-to-app related. I just ran your sample app on a phone against Flutter stable and it built and launched fine in debug mode, I don't see any bitcode related warnings.

It's running:

2021-03-18 18:38:55.220440-0700 Runner[1752:1764709] 	[Adjust]w: SANDBOX: Adjust is running in Sandbox mode. Use this setting for testing. Don't forget to set the environment to `production` before publishing
...

It doesn't even have bitcode enabled (which aligns with the default in a flutter created app):
Screen Shot 2021-03-18 at 6 42 06 PM

I recommend you file a new issue since it doesn't look related to add-to-app.

@uerceg
Copy link

uerceg commented Mar 19, 2021

Huh! Really interesting. Thank you for lightning speed check on this one. 🍺 I opened new issue for this.

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow P2 Important issues not at the top of the work list platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Add-to-app - iOS tool review
  
Engineer reviewed