website icon indicating copy to clipboard operation
website copied to clipboard

Clarify Flavor docs about how to configure iOS Xcode project

Open fras2560 opened this issue 1 year ago • 11 comments

Steps to reproduce

Created an app with three different flavors Add firebase plugins using different pods Updated the app version and build number Create IPA or run the app with different flavor

Expected results

Able to run or build the IPA for iOS.

Actual results

Unable to use

flutter run --dart-define=IsStudentApp=true --flavor student
Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running Xcode build...                                                  
 └─Compiling, linking and signing...                        10.9s
Xcode build done.                                           37.6s
Unable to install
/Users/dallasfraser_local/Knowledgehook/MobileApps/mobileapp/build/ios/iphonesim
ulator/Knowledgehook Student Dev.app on 06F2DCCE-6E63-409B-8FB0-0DAA017D04D8.
This is sometimes caused by a malformed plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain,
code=22):
Failed to install the requested application
The application's Info.plist does not contain a valid CFBundleVersion.
Ensure your bundle contains a valid CFBundleVersion.
  Command: xcrun simctl install 06F2DCCE-6E63-409B-8FB0-0DAA017D04D8
  /Users/dallasfraser_local/Knowledgehook/MobileApps/mobileapp/build/ios/iphones
  imulator/Knowledgehook Student Dev.app
Error launching application on iPhone 14 Pro Max.

also this shows it not being set

flutter build ipa  --dart-define=IsStudentApp=true --flavor student
┌─ App Settings ─────────────────────────────────────────────────────────┐
│ Version Number: Missing                                                │
│ Build Number: Missing                                                  │
│ Display Name: Knowledgehook for Student                                │
│ Deployment Target: 12.0                                                │
│ Bundle Identifier: com.knowledgehook.mobileapp.student                 │
│                                                                        │
│ You must set up the missing settings.                                  │
│                                                                        │
│ Warning: App icon is set to the default placeholder icon. Replace with │
│ unique icons.                                                          │
│                                                                        │
│ To update the settings, please refer to                                │
│ https://docs.flutter.dev/deployment/ios                                │
└────────────────────────────────────────────────────────────────────────┘

Code sample

Code sample Snippet of Info.plist
	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>

Snippet Generated.xcconfig

FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs
┌─ App Settings ─────────────────────────────────────────────────────────┐
│ Version Number: Missing                                                │
│ Build Number: Missing                                                  │
│ Display Name: Knowledgehook for Student                                │
│ Deployment Target: 12.0                                                │
│ Bundle Identifier: com.knowledgehook.mobileapp.student                 │
│                                                                        │
│ You must set up the missing settings.                                  │
│                                                                        │
│ Warning: App icon is set to the default placeholder icon. Replace with │
│ unique icons.                                                          │
│                                                                        │
│ To update the settings, please refer to                                │
│ https://docs.flutter.dev/deployment/ios                                │
└────────────────────────────────────────────────────────────────────────┘

Flutter Doctor output

Doctor output
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.9, on macOS 13.3 22E252 darwin-x64, locale
    en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.77.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

fras2560 avatar Apr 12 '23 23:04 fras2560

The only thing I am not sure about is https://docs.flutter.dev/deployment/flavors#plugin-configurations

This documentation talks about making changes to podfile. However, it is not clear at all how to make this change with multiple flavors or why it is needed.

No online tutorials talk about this either.

fras2560 avatar Apr 12 '23 23:04 fras2560

I was able to resolve the issue with this:

https://stackoverflow.com/a/73572386

If anyone can document these changes in flavor documentation and explain the issue that would be appreciated. Should generated be in parent runner or child runner? https://i.stack.imgur.com/atgcJ.png

fras2560 avatar Apr 13 '23 00:04 fras2560

Thanks for the report @fras2560

I was able to resolve the issue with this:

https://stackoverflow.com/a/73572386

This link says to I was able to have it update again after setting it to the Generated.xcconfig file., ie, you need to make sure your flavor configuration is actually using that xcconfig. For it, see if this helps in your case or not.

darshankawar avatar Apr 13 '23 06:04 darshankawar

/cc @leighajarett for visibility. Since you are actively working on improving flavors documentation and use cases in Flutter :)

For your reference: https://github.com/flutter/website/issues/8743 and https://github.com/flutter/website/issues/8743

darshankawar avatar Apr 13 '23 12:04 darshankawar

Thanks for the report @fras2560

I was able to resolve the issue with this: https://stackoverflow.com/a/73572386

This link says to I was able to have it update again after setting it to the Generated.xcconfig file., ie, you need to make sure your flavor configuration is actually using that xcconfig. For it, see if this helps in your case or not.

What about cases where you have a pod file? What order should they be in? Or was the pod file missing something where it should already include the generated file? image

fras2560 avatar Apr 13 '23 15:04 fras2560

Thanks for the update. I'll keep this issue open for documentation to answer the queries raised here:

https://github.com/flutter/website/issues/8743 https://github.com/flutter/website/issues/8743 https://github.com/flutter/website/issues/8743

darshankawar avatar Apr 14 '23 05:04 darshankawar

What about cases where you have a pod file? What order should they be in? Or was the pod file missing something where it should already include the generated file? image

In that screenshot your prod and staging targets are using the Generated.xcconfig base configuration (it's overriding the Pods- one you set at the project-level). Technically it should be Release.xcconfig but all that's doing is #includeing the Generated.xcconfig. As the docs say:

 Note: Your configurations should be based on your Debug.xconfig or Release.xcconfig file, not the Pods-Runner.xcconfigs. You can check this by expanding the configuration names.

Ideally we would have a screenshot of that in step 3 similar to the one linked: https://github.com/flutter/flutter/issues/82183#issuecomment-839146353

jmagman avatar Apr 17 '23 21:04 jmagman

@jmagman """ As the docs say: """ As what docs say?

fras2560 avatar Apr 17 '23 21:04 fras2560

As what docs say?

Should have linked it: https://docs.flutter.dev/deployment/flavors#creating-flavors-in-ios. The blue box has the note.

jmagman avatar Apr 17 '23 22:04 jmagman

@jmagman Can you explain this part of the docs? In particular if there is multiple flavors? https://docs.flutter.dev/deployment/flavors#plugin-configurations

fras2560 avatar Apr 17 '23 23:04 fras2560

Example with paid and free flavors: https://github.com/flutter/flutter/blob/67a84e6c8722b262dea6fb50a4043543b7a4c199/dev/integration_tests/flavors/ios/Podfile#L7-L12

I'm going to move this to the website issue tracker since this is a request for improving that documentation.

jmagman avatar Apr 17 '23 23:04 jmagman