Skip to content

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented Dec 29, 2020

Background

There are currently two ways to embed plugins in an iOS app via CocoaPods.

  1. flutter created apps import a helper Ruby script into their ios/Podfile that lives in the flutter_tools package bin directory, and then helper methods like flutter_install_all_ios_pods are called.

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

  1. The second way is how add-to-app host apps embed plugins. Host apps also import a helper Ruby script into their Podfile and call helper methods like install_all_flutter_pods, but this helper script is generated in the Flutter module itself as a template file. This allows the host app to import the script as a relative path, and avoids absolute Flutter SDK paths from being checked anywhere into the host app project.
    load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
    target 'Host' do
    install_all_flutter_pods flutter_application_path
    end

The Flutter module (flutter create -t module) app generates an ephemeral fake-host app (recreated on every flutter clean) to allow fast flutter run prototyping of the Flutter bits. This "host" app currently uses the second plugin embedding method and uses the generated template podhelper.rb. This PR changes it to use the first method to more closely align it to a normal flutter create'd app. This will allow the module to leverage the new Flutter XCFramework logic, and avoid issues like #37850 which have been resolved in the first method.

Description

In the add-to-app module Podfile use the Flutter SDK podhelper helper methods to match the behavior of normal apps, instead of using the podhelper that's generated in the module, which will still be imported in the host app's Podfile.

  1. Update module plugin symlinks directory to match apps, .ios/Flutter/.symlinks/ -> .ios/.symlinks/plugins/
  2. Remove extraneous engine copy from build ios-frameworks since the plugins now link on the engine artifacts instead of the one copied into the module app.
  3. Change the module Podfile to pretty closely mimic a regular app Podfile, with the addition of the FlutterPluginRegistrant pod.
  4. Default to copying release framework that contains bitcode, instead of copying the debug framework.

Related Issues

Fixes flutter build ios --release --local-engine in modules since the plugins are linking directly against the engine artifacts. #51989
Fixes #48092

Tests

Added checks for the host app Podfile.lock in module_test_ios.
Thoroughly tested by build_ios_framework_module_test.

@flutter-dashboard flutter-dashboard bot added c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Dec 29, 2020
@google-cla google-cla bot added the cla: yes label Dec 29, 2020
@jmagman jmagman marked this pull request as ready for review January 5, 2021 19:59
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

pod 'FlutterPluginRegistrant', :path => File.join('Flutter', 'FlutterPluginRegistrant'), :inhibit_warnings => true
Copy link
Member Author

Choose a reason for hiding this comment

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

Except for the FlutterPluginRegistrant addition this file is almost the same as a normal app Podfile.

@jmagman
Copy link
Member Author

jmagman commented Jan 5, 2021

@xster Can you test flutter build ios --release --local-engine on this PR? I've been banging my head on #64849

@jmagman
Copy link
Member Author

jmagman commented Jan 12, 2021

Added a Background section to the description, the original description was too confusing.

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the n00b friendly description and background.

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. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants