Support Add2App for iOS even if the main Podfile already has post_install#32791
Support Add2App for iOS even if the main Podfile already has post_install#32791truongsinh wants to merge 4 commits intoflutter:masterfrom
Podfile already has post_install#32791Conversation
…install` flutter#24342 (comment) https://stackoverflow.com/questions/40508957/invalid-podfile-file-specifying-multiple-post-install-hooks-is-unsupported CocoaPods/CocoaPods#6172 In https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps, the instruction should be changed to: ``` flutter_application_path = 'path/to/my_flutter/' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding) # ... post_install do |installer| flutter_post_install(installer) end ```
|
Yes, this is great! 🚀 Since I have a deployment target of iOS 12 in my main app, my app doesn't build arm 32-bit code, but since some of the pods have a much lower deployment target they do. This leaves me with linking errors when I'm trying to archive the app, and the only fix I've found is to bump the deployment target to This leaves me in a state where I have to manually update the |
|
cc @jmagman |
jmagman
left a comment
There was a problem hiding this comment.
Doesn't this break CocoaPods in the module? Now they don't have a post_install step.
What if we keep this flutter_post_install method, and add this to the end of the file:
post_install do |installer|
flutter_post_install(installer)
end
And then we can update the documentation to either require the module podhelper and call that method in an existing post_install, or do what mostly works now for host apps without CoocaPods and eval?
So the host app becomes:
require 'flutterapp/.ios/Flutter/podhelper.rb
post_install do |installer|
... existing post_install...
flutter_post_install(installer)
end
Or stays:
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
jmagman
left a comment
There was a problem hiding this comment.
I think this is a good change.
- The Podfile template needs to call the correct new method, otherwise the module will never install the pods.
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/templates/module/ios/host_app_ephemeral_cocoapods/Podfile.copy.tmpl - I believe the framework_dir is the same directory as the podhelper
__dir__, so I don't think it needs to be global or even passed in.
engine_dir = File.join(__dir__, 'engine')
| @@ -3,6 +3,9 @@ platform :ios, '8.0' | |||
| target 'Runner' do | |||
| flutter_application_path = '../' | |||
There was a problem hiding this comment.
This doesn't seem like it does anything with the new global $flutter_application_path.
|
You had a good solution to adding a method to the podhelper so existing Podfiles don't get clobbered. I took a stab at a larger change that should hopefully solve things in a more complete, more CocoaPods-friendly way, and included the spirit of your change: There will no longer be any post_install hooks required by Flutter. |
|
@truongsinh I'm hoping your issue is fixed by #36793. You can migrate your Podfile as I suggested above, and try it on the master channel. https://github.com/flutter/flutter/wiki/Flutter-build-release-channels |
|
A quick try seems that the current master of Flutter assumes |
You need to remove the xcode_backend build script phase you previously added to the app. You no longer need it. I was going to write up migration instructions tomorrow but you were too fast! |
|
after removing |
|
@truongsinh What were the "other small changes"? I want to make sure I cover everything in the migration instructions. |
It might be specific to our app only, but anyway 2 things 1unrecognized selector our app delegate extends/implements FlutterAppDelegate, FlutterStreamHandler class AppDelegate: FlutterAppDelegate, FlutterStreamHandler {down there in this class, we used to override applicationDidBecomeActive and call override func applicationDidBecomeActive(_ application: UIApplication) {
// .. do own own stuff
// can no longer call supper (used to be able to call in previous Add2App version) because
// `reason: '-[myApp.AppDelegate applicationDidBecomeActive:]: unrecognized selector sent to instance 0x6000011faf00'`
// super.applicationDidBecomeActive(application)
}2
- eventChannel = FlutterEventChannel.init(name: eventChannelName, binaryMessenger: flutterEngine)
- methodChannel = FlutterMethodChannel.init(name: methodChannelName, binaryMessenger: flutterEngine)
+ eventChannel = FlutterEventChannel.init(name: eventChannelName, binaryMessenger: flutterEngine.binaryMessenger)
+ methodChannel = FlutterMethodChannel.init(name: methodChannelName, binaryMessenger: flutterEngine.binaryMessenger) |

Description
Right now, https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps breaks if iOS project already has
post_installsnippet, see #26212Related Issues
Podfilefile: [!] Specifying multiplepost_installhooks is unsupported CocoaPods/CocoaPods#6172Tests
There is no test at the moment.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?
In https://github.com/flutter/flutter/wiki/Add-Flutter-to-existing-apps, the instruction should be changed to: