Skip to content

Skip linking against Flutter for CocoaPods transitive dependencies #78592

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

Merged

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Mar 19, 2021

Background

Flutter plugins need to link against Flutter.framework or FlutterMacOS.framework. That work is done in the app's Podfile like:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

flutter_additional_ios_build_settings and flutter_additional_macos_build_settings sets up the search paths to point to the bin/cache version of Flutter.framework or FlutterMacOS.framework, and for iOS additionally links against Flutter.

build_configuration.build_settings['OTHER_LDFLAGS'] = '$(inherited) -framework Flutter'

ALL pods, even non-Flutter plugins transitive dependencies, were therefore linking against Flutter.
For example, Flutter plugin firebase_admob needs to link against Flutter. That plugin has a transitive dependency on Google-Mobile-Ads-SDK which being incorrectly also linked to Flutter.framework.

The problem

#72151 causes an issue where, if a transitive dependency contained bitcode, it fails when linking against the debug version of Flutter (which isn't necessary since the transitive dependencies don't need to know anything about Flutter) because debug Flutter only contains a bitcode marker, not full bitcode.

ld: bitcode bundle could not be generated because 'bin/cache/artifacts/engine/ios/Flutter.xcframework/ios-armv7_arm64/Flutter.framework/Flutter'
was built without full bitcode.

The fix

Change the podhelper logic to only set up all the Flutter build settings ONLY for Flutter plugins and not their transitive dependencies.

Add a a plugin with a transitive dependency to build_ios_framework_module_test and test that the dependency doesn't link against Flutter.
https://ci.chromium.org/p/flutter/builders/try/Mac%20build_ios_framework_module_test/4725
On master this test fails:

Task result:
{
  "success": false,
  "reason": "Transitive dependency /var/folders/bx/pyplw7v92lj58gm3_lztz5sc00mfq2/T/flutter_module_test.o1howC/hello_module/flutter-frameworks/Debug/Reachability.xcframework/ios-arm64_armv7/Reachability.framework/Reachability unexpectedly links on Flutter"
}

Fixes #78589

@jmagman jmagman added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. t: xcode "xcodebuild" on iOS and general Xcode project management labels Mar 19, 2021
@jmagman jmagman self-assigned this Mar 19, 2021
@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Mar 19, 2021
@google-cla google-cla bot added the cla: yes label Mar 19, 2021
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. (I'm assuming "links on" means the same thing as "links against"? I've not encountered that terminology.)

@jmagman
Copy link
Member Author

jmagman commented Mar 19, 2021

LGTM. (I'm assuming "links on" means the same thing as "links against"? I've not encountered that terminology.)

Yeah it was late. 😄

@jmagman jmagman changed the title Skip linking on Flutter for CocoaPods transitive dependencies Skip linking against Flutter for CocoaPods transitive dependencies Mar 19, 2021
@stuartmorgan-g
Copy link
Contributor

LGTM. (I'm assuming "links on" means the same thing as "links against"? I've not encountered that terminology.)

Yeah it was late. 😄

In that case: link on, and be excellent to your libraries 😁

@jmagman jmagman merged commit 6a4dd4c into flutter:master Mar 19, 2021
@jmagman jmagman deleted the skip-linking-transitive-dependencies branch March 19, 2021 22:33
christopherfujino added a commit that referenced this pull request Apr 1, 2021
* Skip linking on Flutter for CocoaPods transitive dependencies (#78592)
* Apply Engine cherrypicks for release 2.0.4

Co-authored-by: Jenn Magder <magder@google.com>
@resbeut resbeut mentioned this pull request Sep 14, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: contributor-productivity Team-specific productivity, code health, technical debt. platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'ld: bitcode bundle could not be generated' iOS app build error
2 participants