Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Skip linking against Flutter for CocoaPods transitive dependencies#78592

Merged
jmagman merged 1 commit into
flutter:masterfrom
jmagman:skip-linking-transitive-dependencies
Mar 19, 2021
Merged

Skip linking against Flutter for CocoaPods transitive dependencies#78592
jmagman merged 1 commit into
flutter:masterfrom
jmagman:skip-linking-transitive-dependencies

Conversation

@jmagman

@jmagman jmagman commented Mar 19, 2021

Copy link
Copy Markdown
Member

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

@stuartmorgan-g stuartmorgan-g left a comment

Copy link
Copy Markdown
Contributor

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

jmagman commented Mar 19, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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 😁

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