flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.83k stars 3.23k forks source link

Add example for non-free version in `Creating flavors in iOS and macOS` section on `Create flavors of a Flutter app` page #10164

Open scopendo opened 9 months ago

scopendo commented 9 months ago

Page URL

https://docs.flutter.dev/deployment/flavors/

Page source

https://github.com/flutter/website/tree/main/src/deployment/flavors.md

Describe the problem

The guide could be clearer for creating flavors of an iOS app. The guide shows updating a project to have a "free" flavor but doesn't make it clear how the non-free version of the example app would be built. For example, the Runner section of the Podfile ends up only the "free" build configurations being present.

Expected fix

No response

Additional context

No response

I would like to fix this problem.

huycozy commented 9 months ago

Hi @scopendo Does that mean the page should add the guideline for paid flavor as well? You can do the same steps as free flavor for paid. Does it not work or do you encounter any difficulties if you do that?

scopendo commented 9 months ago

Hi @huycozy – focusing on iOS, suppose I create a new app flutter create demo, which is given the default app bundle id of com.example.demo. Let's assume that's the fully-featured version of my app.

Now, I want to add a flavor for a free version alongside the fully-featured app. So I follow this documentation, adding the free scheme and build configurations and com.example.demo.free bundle id per the documentation.

At this point, it's not clear how I would build the fully-featured version of the app. Was I meant to keep or delete the default Debug, Profile and Release build configurations? What about the default Runner scheme? Should I have changed the build configurations in my Podfile (per the docs) or should I have added entries for the free flavor and kept the existing entries there for when building the fully-featured app?

Through experimenting I'm fairly sure I know the answers but I think it could be clearer in the docs.

Cheers, Scott

huycozy commented 9 months ago

I think it will be something like this (source: https://github.com/flutter/flutter/blob/74e054f04ae59cd9e721710f183f53897b3c9ded/dev/integration_tests/flavors/ios/Podfile#L7-L12) :

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

And we can this as an example there in the docs.

Through experimenting I'm fairly sure I know the answers but I think it could be clearer in the docs.

You may share your sample configuration as well. Thanks!

theshivamlko commented 9 months ago

I have created multiple env. in flutter on android and iOS

  1. Follow the free version steps to create
  2. No need to duplicate runner , if u need different icons or more flexibility in iOS env
  3. You can create free and paid version by maintaining different main.dart file at launch and build.
  4. use command flutter build ios --target=lib/main_paid.dart` --flavor PaidVersion
  5. Here PaidVersion is the Scheme created in Xcode in iOS