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

Move logic from user project's Podfile to a Ruby script in Flutter tools #45197

Closed
xster opened this issue Nov 19, 2019 · 6 comments · Fixed by #59044
Closed

Move logic from user project's Podfile to a Ruby script in Flutter tools #45197

xster opened this issue Nov 19, 2019 · 6 comments · Fixed by #59044
Labels
platform-ios iOS applications specifically platform-mac Building on or for macOS specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@xster
Copy link
Member

xster commented Nov 19, 2019

Writing out the logic into the user project's source controlled Podfile means we're locking the interpretation of .flutter-plugins which is ephemeral with the Flutter tools in time and it's no longer upgradable.

Since we know we're moving the .flutter-plugins content to support federated plugins (@amirh) we should make sure the users with existing projects can handle changes in the way .flutter-plugins is written to.

cc @zanderso @jmagman

@xster xster added tool Affects the "flutter" command-line tool. See also t: labels. platform-mac Building on or for macOS specifically labels Nov 19, 2019
@jmagman jmagman added the platform-ios iOS applications specifically label Nov 19, 2019
@zanderso
Copy link
Member

To what extent do we know whether users have manually edit the file?

@xster
Copy link
Member Author

xster commented Nov 21, 2019

Hard to say. Though it is an issue users brought up #12754

@jmagman jmagman added this to Awaiting triage in Tools - iOS review Jan 10, 2020
@jmagman jmagman added this to Awaiting triage in Tools - macOS review Jan 10, 2020
@jmagman jmagman moved this from Awaiting triage to Engineer reviewed in Tools - iOS review Jan 16, 2020
@christopherfujino christopherfujino removed this from Awaiting triage in Tools - macOS review Jan 16, 2020
@jmagman
Copy link
Member

jmagman commented Jan 16, 2020

\cc @franciscojma86

@jmagman
Copy link
Member

jmagman commented Jun 10, 2020

New prompt from flutter:

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

If you have custom Podfile edits you would like to keep, the easiest thing to do is to re-create your changes on top of the new generated one. If you are unable to do that, here is the generated Podfile that copies the correct version of the Flutter engine to the expected locations.
You can interleave that Ruby code into yours as needed:
Objective-C app:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/cocoapods/Podfile-ios-objc
Swift:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/cocoapods/Podfile-ios-swift

@lock
Copy link

lock bot commented Jun 24, 2020

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.

@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
@jmagman
Copy link
Member

jmagman commented Aug 7, 2020

The Podfile format has changed in 1.20 with #59044. This change was made to support plugins that do not support the iOS platform and was developed to hopefully prevent painful developer migrations like this to be necessary in the future by simplifying it, and moving more logic into the Flutter SDK.

The new Podfile looks different, but the key sections are the same.

target 'Runner'

There's a target 'Runner' section where you can add your custom pods to be embedded in your app. It calls a Ruby method flutter_install_all_ios_pods that now lives in the Flutter SDK and will take care of embedding your Flutter plugins and the Flutter.framework.

target 'Runner' do
  use_frameworks!
  use_modular_headers!

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

# ADD YOUR CUSTOM PODS HERE!
end

For example, if you needed to include a pod like KeychainSwift:

target 'Runner' do
  use_frameworks!
  use_modular_headers!

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

  pod 'KeychainSwift', '~> 19.0'
end

project 'Runner'

project 'Runner is still at the top and is unchanged. If you have flavors set up with custom build configurations, copy it from your old Podfile exactly.

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

for example, if you had a Staging build configuration:

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Staging' => :release,
  'Release' => :release,
}

post_install

There's also a post_install section if you have custom build settings or other changes you want to make to your Pod targets. It calls a Ruby method flutter_additional_ios_build_settings that now lives in the Flutter SDK and will take care of setting ENABLE_BITCODE=NO and other build settings.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # YOUR CUSTOM TARGET CODE HERE.
  end
end

for example, if your old Podfile set your plugins' SWIFT_VERSION:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'
    end
  end
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-ios iOS applications specifically platform-mac Building on or for macOS specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Tools - iOS review
  
Engineer reviewed
Development

Successfully merging a pull request may close this issue.

3 participants