Amplitude-Flutter icon indicating copy to clipboard operation
Amplitude-Flutter copied to clipboard

Build for iOS fails when Bitcode is enabled

Open Zazo032 opened this issue 4 years ago • 15 comments

After regenerating the Podfile file using rm ios/Podfile, and trying to build, the build fails. This was done because the tool itself suggested it (maybe some changes to that file in latest Flutter versions).

Running pod install...                                              5,3s
Warning: Podfile is out of date
  This can cause issues if your application depends on plugins that do not
  support iOS.
  See
  https://flutter.dev/docs/development/packages-and-plugins/developing-packages#
  plugin-platforms for details.
  If you have local Podfile edits you would like to keep, see
  https://github.com/flutter/flutter/issues/45197 for instructions.
To regenerate the Podfile, run:
  rm ios/Podfile



Running Xcode build...

This is the related error log:

ld:
    '/Users/cristianzazo/<elided>/build/ios/Release-iphoneos/Amplitude/Amplitu
    de.framework/Amplitude' 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. file
    '/Users/cristianzazo/<elided>/build/ios/Release-iphoneos/Amplitude/Amplitu
    de.framework/Amplitude' for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see
    invocation)
    ld:
    '/Users/cristianzazo/<elided>/build/ios/Release-iphoneos/Amplitude/Amplitu
    de.framework/Amplitude' 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. file
    '/Users/cristianzazo/<elided>/build/ios/Release-iphoneos/Amplitude/Amplitu
    de.framework/Amplitude' for architecture arm64
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
[✓] Flutter (Channel master, 1.20.0-1.0.pre.132, on Mac OS X 10.15.5 19F101,
    locale es-ES)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)

Zazo032 avatar Jun 22 '20 14:06 Zazo032

Hey, so previously it doesn't happen to you?

haoliu-amp avatar Jun 23 '20 16:06 haoliu-amp

No, only after migrating to new Podfile template

Zazo032 avatar Jun 23 '20 17:06 Zazo032

So you regenerate the Podfile for your project, right? What is your current Cocoapods and Flutter version? Knowing these will help me get it reproduced locally.

haoliu-amp avatar Jun 23 '20 17:06 haoliu-amp

The Flutter version is in the first post, CocoaPods version is 1.9.3

Zazo032 avatar Jun 23 '20 20:06 Zazo032

I tried it locally, but can't get it reproduced.

However, the versions for each tools I am using are cocoapods: 1.9.1 flutter: Flutter 1.18.0-11.0.pre

Would you like to try to switch same versions and give it a shot?

haoliu-amp avatar Jul 16 '20 02:07 haoliu-amp

This is still happening in latest 1.20 stable, did you enable bitcode in order to trigger the error?

Zazo032 avatar Aug 07 '20 10:08 Zazo032

I did enable it. Would you mind sending me an example app so I can try it out on my end if possible?

haoliu-amp avatar Aug 07 '20 17:08 haoliu-amp

I have the same problem. If I remove the Podfile in order to make the new one, I get this bitcode issue.

$ pod --version
1.9.1

$ flutter --version
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter
Framework • revision bbfbf1770c (4 days ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1

ThomasKliszowski avatar Aug 17 '20 08:08 ThomasKliszowski

Same problem here, I reverted flutter version to make it work. The error started after migrating to new stable version 1.20. I opened the issue #15

marcuslma avatar Aug 18 '20 18:08 marcuslma

I have the same problem. I wanted to reduce the app size, so I enabled the bitcode flag. Then the project failed to build:

    ld: '/Users/zahra/FlutterProjects/motiveex_fluttter/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude'
    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. file
    '/Users/zahra/FlutterProjects/motiveex_fluttter/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude' for
    architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ld: '/Users/zahra/FlutterProjects/motiveex_fluttter/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude'
    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. file
    '/Users/zahra/FlutterProjects/motiveex_fluttter/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude' for
    architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

zjamshidi avatar Aug 23 '20 12:08 zjamshidi

here is the output of flutter doctor:

[✓] Flutter (Channel stable, v1.17.0, on Mac OS X 10.15.5 19F101, locale en-LK)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)

I'm using amplitude_flutter: ^2.0.0 in my project

zjamshidi avatar Aug 23 '20 12:08 zjamshidi

I solved my issue. According to flutter documentation:

You should also remove config.build_settings['ENABLE_BITCODE'] = 'NO' from the Podfile

https://github.com/flutter/flutter/wiki/Creating-an-iOS-Bitcode-enabled-app

zjamshidi avatar Aug 23 '20 17:08 zjamshidi

@zjamshidi Thank you very much! I've put this into our documentation under FAQ section.

https://developers.amplitude.com/docs/flutter-setup#faq

haoliu-amp avatar Aug 27 '20 23:08 haoliu-amp

This will probably have to be updated too: https://github.com/amplitude/Amplitude-Flutter/search?q=ENABLE_BITCODE&unscoped_q=ENABLE_BITCODE

Example: https://github.com/flutter/flutter/pull/39851/files

Zazo032 avatar Aug 31 '20 08:08 Zazo032

As this plugin is now using the iOS pod natively, maybe bitcode should be enabled there?

ld: '/Users/cristianzazo/sample/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude' 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.
file '/Users/cristianzazo/sample/build/ios/Release-iphoneos/Amplitude/Amplitude.framework/Amplitude' for architecture arm64
clang: error: linker command failed with exit code 1

Zazo032 avatar Aug 31 '20 09:08 Zazo032