flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.39k stars 27.29k forks source link

[proposal] Provide way to generate platform files in flutter module with custom minimum sdk #78862

Open ravitripathi opened 3 years ago

ravitripathi commented 3 years ago

Steps to Reproduce

We are trying to embed a feature developed in flutter into an existing iOS app as described in "option B" of docs for integration.

For building frameworks, we run:

flutter build ios-framework --xcframework --no-universal --output=./build

Dependencies declared in pubspec.yaml:

  google_maps_flutter: ^1.2.0
  geolocator: ^6.2.0
  shimmer: ^1.1.2
  flutter_riverpod: ^0.12.4
  dio: ^3.0.10
  intl: ^0.16.1
  package_info: ^0.4.3+4
  firebase_core: ^0.7.0
  firebase_crashlytics: ^0.4.0+1

Expected results: The corresponding .xcframeworks for each dependency and an App.xcframework should be generated.

Actual results: The build fails with the following error:

Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "FlutterPluginRegistrant":
      In Podfile:
        FlutterPluginRegistrant (from `Flutter/FlutterPluginRegistrant`)

    Specs satisfying the `FlutterPluginRegistrant (from `Flutter/FlutterPluginRegistrant`)` dependency were found, but they required a higher
    minimum deployment target.

We did some analysis, and observed the following:

  1. We use the firebase_crashlytics dependency on version "0.4.0+1". According to their changelogs, the minimum supported version was bumped to iOS 10 in version "0.3.0".
  2. Our iOS host app (which we use for testing the feature), supports iOS 11+. Hence pod install succeeds and we can run it.
  3. When flutter build ios-framework is run, flutter ignores the host app, and creates a .ios folder within flutter module, as described in project setup ("Add custom iOS code to your own existing application’s project or to a plugin, not to the module’s .ios/ directory. Changes made in your module’s .ios/ directory do not appear in your existing iOS project using the module, and may be overwritten by Flutter.")
  4. This generated .ios directory has its own Podfile, and a FlutterPluginRegistrant.podspec where the supported version number is set to iOS 9.0, which is hardcoded over here in plugins.dart.
  5. Hence pod install fails with the above error ("requires higher minimum deployment target").
Logs ``` ``` ``` Analyzing flutter_module... No issues found! (ran in 2.4s) ``` ``` [✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.3 20D91 darwin-x64, locale en-GB) • Flutter version 1.22.6 at /Users/ravi/Library/Flutter/flutter • Framework revision 9b2d32b605 (9 weeks ago), 2021-01-22 14:36:39 -0800 • Engine revision 2f0af37152 • Dart version 2.10.5 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/ravi/Library/Android/sdk • Platform android-30, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.4, Build version 12D4e • CocoaPods version 1.10.1 [!] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [✓] VS Code (version 1.54.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.20.0 [!] Connected device ! Error: Ravi’s iPad is not connected. Xcode will continue when Ravi’s iPad is connected. (code -13) ! Doctor found issues in 2 categories. ```
ravitripathi commented 3 years ago

This could be fixed if there is a way to pass the required iOS deployment version for iOS as a parameter to flutter build ios-framework. Or maybe it would be even better if it can pick up the version declared in the iOS host app.

TahaTesser commented 3 years ago

Hi @ravitripathi Thanks for filing the issue, I came across this kinda issue before. What I did is, once the .ios folder is generated you can open its Runner.xcworkspace and change deployment target and then build framework, this won't delete the .ios folder so your changes are saved

let me this helps, let m know Thank you

ravitripathi commented 3 years ago

@TahaTesser thanks for reply. I tried your suggestion, but this also fails. The reason for this is that the error, as I mentioned in the description, occurs during pod install stage. So even when I change the deployment target, and run flutter build ios-framework..... again, it fails, as it runs pod install, which tries to resolve its dependencies with the target as 9.0.

ravitripathi commented 3 years ago

Output for flutter build ios-framework --xcframework --no-universal --output=./build after making the suggested change:

Building frameworks for com.gojek.android.flutterModule in debug mode...
 ├─Populating Flutter.framework...                                  0.1s
 ├─Creating Flutter.xcframework...                                  1.8s
 ├─Building App.framework...                                       10.4s
 ├─Creating App.xcframework...                                      1.1s
Running pod install...                                              1.2s
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter/engine`
    -> Fetching podspec for `FlutterPluginRegistrant` from `Flutter/FlutterPluginRegistrant`
    -> Fetching podspec for `firebase_core` from `Flutter/.symlinks/firebase_core/ios`
    firebase_core: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_crashlytics` from `Flutter/.symlinks/firebase_crashlytics/ios`
    firebase_crashlytics: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
    -> Fetching podspec for `geolocator` from `Flutter/.symlinks/geolocator/ios`
    -> Fetching podspec for `google_maps_flutter` from `Flutter/.symlinks/google_maps_flutter/ios`
    -> Fetching podspec for `package_info` from `Flutter/.symlinks/package_info/ios`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    [!] CocoaPods could not find compatible versions for pod "firebase_crashlytics":
      In Podfile:
        FlutterPluginRegistrant (from `Flutter/FlutterPluginRegistrant`) was resolved to 0.0.1, which depends on
          firebase_crashlytics

        firebase_crashlytics (from `Flutter/.symlinks/firebase_crashlytics/ios`)

    Specs satisfying the `firebase_crashlytics (from `Flutter/.symlinks/firebase_crashlytics/ios`), firebase_crashlytics` dependency were
    found, but they required a higher minimum deployment target.

    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in
    unwind_for_conflict'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in
    resolve_dependencies'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in
    `resolve_dependencies'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in
    resolve_dependencies'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
    /Users/ravi/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
    /Users/ravi/.rbenv/versions/2.6.6/bin/pod:23:in `load'
    /Users/ravi/.rbenv/versions/2.6.6/bin/pod:23:in `<main>'

Error running pod install
TahaTesser commented 3 years ago

Hi @ravitripathi I can see the same results like I mentioned you edit .ios, those changes remain

Below. is the same result as you

logs ```bash tahatesser@Tahas-MacBook-Pro flutter_module % flutters build ios-framework --xcframework --no-universal --output=./build Running "flutter pub get" in flutter_module... 820ms Building without sound null safety For more information see https://dart.dev/null-safety/unsound-null-safety Building frameworks for com.nevercode.flutterModule in debug mode... ├─Copying Flutter.xcframework... 221ms ├─Building App.xcframework... 20.9s Running pod install... 1,061ms CocoaPods' output: ↳ Preparing Analyzing dependencies Inspecting targets to integrate Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``) Fetching external sources -> Fetching podspec for `Flutter` from `Flutter` -> Fetching podspec for `FlutterPluginRegistrant` from `Flutter/FlutterPluginRegistrant` -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios` firebase_core: Using Firebase SDK version '7.3.0' defined in 'firebase_core' -> Fetching podspec for `firebase_crashlytics` from `.symlinks/plugins/firebase_crashlytics/ios` firebase_crashlytics: Using Firebase SDK version '7.3.0' defined in 'firebase_core' -> Fetching podspec for `geolocator` from `.symlinks/plugins/geolocator/ios` -> Fetching podspec for `google_maps_flutter` from `.symlinks/plugins/google_maps_flutter/ios` -> Fetching podspec for `package_info` from `.symlinks/plugins/package_info/ios` Resolving dependencies of `Podfile` CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update [!] CocoaPods could not find compatible versions for pod "firebase_core": In Podfile: firebase_core (from `.symlinks/plugins/firebase_core/ios`) Specs satisfying the `firebase_core (from `.symlinks/plugins/firebase_core/ios`)` dependency were found, but they required a higher minimum deployment target. /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve' /Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run' /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run' /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `' /usr/local/bin/pod:23:in `load' /usr/local/bin/pod:23:in `
' Error output from CocoaPods: ↳ [!] `` attempted to initialize an object with an unknown UUID. `7497404A213559E7008C567A` for attribute: `children`. This can be the result of a merge and the unknown UUID is being discarded. Error running pod install tahatesser@Tahas-MacBook-Pro flutter_module % ```

Now I changed flutter_module/.ios/Podfile in IDE and changed the platform target to platform :ios, '10.0' and then execute pod install

tahatesser@Tahas-MacBook-Pro .ios % pod install
Analyzing dependencies
firebase_core: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
firebase_crashlytics: Using Firebase SDK version '7.3.0' defined in 'firebase_core'
Downloading dependencies
Installing Firebase (7.3.0)
Installing FirebaseCore (7.3.0)
Installing FirebaseCoreDiagnostics (7.3.0)
Installing FirebaseCrashlytics (7.3.0)
Installing FirebaseInstallations (7.9.0)
Installing Flutter (1.0.0)
Installing FlutterPluginRegistrant (0.0.1)
Installing GoogleDataTransport (8.1.0)
Installing GoogleMaps (3.9.0)
Installing GoogleUtilities (7.3.1)
Installing PromisesObjC (1.2.12)
Installing firebase_core (0.7.0)
Installing firebase_crashlytics (0.4.0-1)
Installing geolocator (6.2.0)
Installing google_maps_flutter (0.0.1)
Installing nanopb (2.30906.0)
Installing package_info (0.0.1)
Generating Pods project
Integrating client project
Pod installation complete! There are 7 dependencies from the Podfile and 17 total pods installed.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Runner` to `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` or include the `Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig` in your build configuration (`Config/Release.xcconfig`).
tahatesser@Tahas-MacBook-Pro .ios % 

and then executed flutter build ios-framework --xcframework --no-universal --output=./build, it builds no error as before

tahatesser@Tahas-MacBook-Pro flutter_module % flutters build ios-framework --xcframework --no-universal --output=./build

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

Building frameworks for com.nevercode.flutterModule in debug mode...
 ├─Copying Flutter.xcframework...                                  308ms
 ├─Building App.xcframework...                                      3.2s
Running pod install...                                           2,957ms
 ├─Building plugins...                                            115.4s
 └─Moving to build/Debug                                           337ms
Building frameworks for com.nevercode.flutterModule in profile mode...
 ├─Copying Flutter.xcframework...                                  195ms
 ├─Building App.xcframework...                                     46.7s
 ├─Building plugins...                                            103.9s
 └─Moving to build/Profile                                         375ms
Building frameworks for com.nevercode.flutterModule in release mode...
 ├─Copying Flutter.xcframework...                                1,587ms
 ├─Building App.xcframework...                                     43.0s
 ├─Building plugins...                                             96.5s
 └─Moving to build/Release                                         364ms
Frameworks written to /Users/tahatesser/AndroidStudioProjects/triage-examples/add2app_examples/flutter_module/build.
tahatesser@Tahas-MacBook-Pro flutter_module % 
abhaysood commented 3 years ago

@TahaTesser The workaround here might not be suitable for a larger team. Given .ios directory is not checked in, we'll required everyone in the team to keep doing this. Also, it will need to be constantly updated as the Podfile is auto-generated. This also requires a hack on CI to build the framework correctly.

Is a permanent and more elegant fix possible for this?

TahaTesser commented 3 years ago

@abhaysood Firebase has bumped their min iOS requirement to 10, so author has to target 10 anyway and then build the app

abhaysood commented 3 years ago

Sorry, I might be misunderstanding your comment, the author in this case is flutter build command. The .ios folder in question here is auto-generated. We have no control over the iOS target in this folder which is being set by default to 9.

abhaysood commented 3 years ago

@TahaTesser I tried the workaround you mentioned in the comment above.

It worked for me but only after making one more change in the Podfile. I had to replace use_frameworks! with use_modular_headers!. Without this change I get the following error:

Unable to create FBLPromises.xcframework: error: the path does not point to a valid framework:
.../flutter-experiment/flutter_module/build/Debug/iphonesimulator/Debug-iphonesimulator/FBLPromises/FBLPromises.framework
no-response[bot] commented 3 years ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

ravitripathi commented 3 years ago

@TahaTesser there seems to be a misunderstanding regarding what we are trying to achieve here. We are trying to integrate flutter into an existing app via "option B" of docs for integration.. Our app is already on iOS 11+. Also, to reiterate what I said earlier, this is an actual issue as in option B, the .ios folder is autogenerated.

Hence, it is not at all possible to manually go and edit an autogenerated project every single time.

ravitripathi commented 3 years ago

As mentioned by @abhaysood , every time the .ios folder is generated via flutter build, your solution would require me to reset the version to iOS 11. Why? Our host app is already on iOS 11. Currently this means it necessary to modify a generated project every time.

TahaTesser commented 3 years ago

@ravitripath @abhaysood I understand the issue for generated .ios and I mentioned and confirmed it https://github.com/flutter/flutter/issues/78862#issuecomment-805658383

But you're proposing the generated .ios be generated for a higher iOS version? Flutter currently targets iOS 9, in a regular project or module

ravitripathi commented 3 years ago

@TahaTesser exactly my point. Flutter target iOS 9+. Which is fine. But what happens when we try to add a dependency which is iOS 10+? Flutter would:

  1. Generate a project, with a hardcoded version number (which is 9)
  2. The dependency added to it as a pod would require iOS 10+
  3. The build subsequently fails.

To mitigate this issue, what I propose that either flutter build sets the deployment target based on its host app, or we have an option to pass the needed version via a command line parameter.

TahaTesser commented 3 years ago

CC @jmagman

abhaysood commented 3 years ago

I would also like to point out that this is an issue for only Add-to-app. In a Flutter only app there is no .ios directory needed and the author is in full control of the deployment target.

Additionally, this might also affect Android at some point in time. Given .android assumes a min-sdk, build types, etc in the generated build.gradle file.

jmagman commented 3 years ago

The platform module .ios app is supposed to be just a little bootstrap app to get you started. There's nothing particularly special about it, it's mostly an empty iOS/Android project. If you don't want to test your module in your full host app, I suggest making a very simple version of the host app that is mostly an empty iOS/Android project that does nothing except start the Flutter view. You can then edit this all you want and control the minimum target version.

Essentially, the point of the .ios directory being uneditable/ephemeral is to remind you that nothing you change in that .ios directory matters when you embed the module in your host app. If you set up a bunch of entitlements or change your minimum target version there, but not in your host app, it may work in your module app but it won't work in your host app unless you make the same changes there. There's more conversation in flutter/flutter#32989 and flutter/website#7774.

Also: if you're just working on an iOS app, you can actually run flutter build ios-framework from a normal non-module Flutter app. That may be more appropriate for you if you don't want to create your own host bootstrap project as suggested above. You just need to follow the instructions the command gives to copy in the plugin registrant file that is generated for you in the module project template.

abhaysood commented 3 years ago

Thanks @jmagman. Sorry, I'm confused with the solution you have mentioned. First of all, we are using Option - B of add-to-app. We have a Flutter module which we integrate with the host app using the framework generated by flutter build ios-framework and with fluter build aar for the Android host app. We even have an empty host bootstrap project.

Secondly, based on what I understand this is not accurate and is the source of the problem we are facing:

Essentially, the point of the .ios directory being uneditable/ephemeral is to remind you that nothing you change in that .ios directory matters when you embed the module in your host app

When we run the flutter build ios-framework --xcframework --no-universal command to generate the framework, it uses the .ios directory which ends up dictating the minimum target version. So the .ios folder does matter. And as discussed in the issue above the only workaround is to modify the .ios directory which is not feasible to do all the time.

ravitripathi commented 3 years ago

@jmagman We understand that the .ios folder is not supposed to be editable. Let me once again try to explain what we are trying to do. As mentioned by @abhaysood, we are using Option B for integrating flutter in an existing app:

Alternatively, you can generate the necessary frameworks and embed them in your application by manually editing your existing Xcode project. You may do this if members of your team can’t locally install Flutter SDK and CocoaPods, or if you don’t want to use CocoaPods as a dependency manager in your existing applications. You must run flutter build ios-framework every time you make code changes in your Flutter module.

So we get built .frameworks which can be embedded in an existing app. Now flutter build ios-framework generates these frameworks, by creating an ephemeral project in .ios. Which is completely okay, and we do not intend to change this folder at all.

The problem is that this generated project assumes iOS 9 as the deployment target. Hence flutter build ios-framework fails, because one of the dependencies (firebase in this case) requires a minimum target of iOS 10. Let me re-iterate this is not a problem in our project, as it is already at iOS 11. Hence we need a way to override this version number being set by generated project

jmagman commented 3 years ago

Ah, I understand now, thanks for the clarification. It's exactly the problem discussed in https://github.com/flutter/flutter/issues/32989#issuecomment-577904096.

I think this could be mitigated by flutter/flutter#49378 since you should be able to override whatever Xcode build settings you want via environment variables, like IPHONEOS_DEPLOYMENT_TARGET (though it doesn't work for this particular command).

TahaTesser commented 3 years ago

Adding android too from https://github.com/flutter/flutter/issues/83713

neiljaywarner commented 2 years ago

This is pretty bad on android if the min sdk version is 16. 16 is VERY VERY old, and 19 and 20 and 21 are still plenty plenty plnety old enough to get 99% of users and lots of important functionality.

arthurpiccoli commented 2 years ago

This is extremely inconvenient during development when using packages that require further modifications on the default Podfile and build.gradle files, like mobile_scanner. Having to manually edit those files whenever a flutter pub get command is run is really unproductive. There should be a better way to define these changes permanently.

CaoGiaHieu-dev commented 2 years ago

hi . im try to import with option B and C but it getting this error https://github.com/flutter/flutter/issues/110562 . it work fine when do on option A . Can some one help me ?

jmagman commented 2 years ago

hi . im try to import with option B and C but it getting this error flutter/flutter#110562 . it work fine when do on option A . Can some one help me ?

Let's discuss in https://github.com/flutter/flutter/issues/110562 then.

federicopolesello commented 1 year ago

Hi guys, are there any news regarding this? I'm blocked due to this and I'm trying to run it in our pipeline CI/CD. I can't edit manually the Podfile every time. I can do it locally (boring) but of course not in the pipeline. It's very urgent for me. In this case I have the same issue above with the Intercom plugin that is iOS 13+ and the autogenerated Podfile in the .ios folder contains iOS 11.

sajadmaster commented 1 year ago

Hello guys, We have this issue too. Please make an update or guide us on how to fix this issue permanently. Thanks

fertwo commented 1 year ago

any update on this guys?

mibcoder commented 1 year ago

Please anyone get any solution, on how we can set a minimum iOS version, without changing in .ios folder, as it is auto generated

raphaaugustosilva commented 1 year ago

Any news about this? Changing directly at .android/app/buid.gradle works, but, with cicd, it fails, since build.gradle it`s an auto-generated file.

sanidhya09 commented 1 year ago

Any update on this?

lutzer commented 1 year ago

For android i solved the issue the following way:

I created an .sh in the flutter root directory that i manually run after every dependency install:

#!/bin/sh
flutter clean
flutter pub get

# changes compileSdkVersion Version in gradle file
sed -i.bak "s/compileSdkVersion [0-9]*/compileSdkVersion 33/g" .android/app/build.gradle

# change minSdkVersion
sed -i '' -e "s/minSdkVersion [0-9]*/minSdkVersion 21/g" .android/app/build.gradle

Could the execution of this script be somehow automated?

levinx7512 commented 7 months ago

For android i solved the issue the following way:

I created an .sh in the flutter root directory that i manually run after every dependency install:

#!/bin/sh
flutter clean
flutter pub get

# changes compileSdkVersion Version in gradle file
sed -i.bak "s/compileSdkVersion [0-9]*/compileSdkVersion 33/g" .android/app/build.gradle

# change minSdkVersion
sed -i '' -e "s/minSdkVersion [0-9]*/minSdkVersion 21/g" .android/app/build.gradle

Could the execution of this script be somehow automated?

use shell script for workaround, looking forward to a simpler solution:)

christopherfujino commented 6 months ago

@jmagman If I am understanding correctly, https://github.com/flutter/flutter/issues/49378 (Allow users to pass in Xcode build settings as env variables to "flutter build ios-framework" FLUTTERXCODE) would be one way to solve this issue, is that correct?

jmagman commented 6 months ago

@jmagman If I am understanding correctly, #49378 (Allow users to pass in Xcode build settings as env variables to "flutter build ios-framework" FLUTTERXCODE) would be one way to solve this issue, is that correct?

https://github.com/flutter/flutter/issues/49378 is a good thing to do, and would help with some cases on iOS that are strictly about iOS min versioning (which I guess is the original report).

However, in other cases it wouldn't help because some of the changes people are making are to the ios/Podfile

It worked for me but only after making one more change in the Podfile. I had to replace use_frameworks! with use_modular_headers!.

Longer term fix: for iOS I think we should get rid of the whole concept of modules, generate a normal iOS project platform directory, which can contain the extra things a module needs: the podhelper and the FlutterPluginRegistrant bits to help integrating with CocoaPods (or skip CocoaPods support, and only support Swift Package Manager or manually embedding the frameworks)