Flutter/iOS: How can I use pubspec.yaml's App version in my NotificationServiceExtension Info.plist file?
550
Flutter generates an xcconfig
file with variables like FLUTTER_BUILD_NAME
and FLUTTER_BUILD_NUMBER
To use these variables in an extension we need to do the following:
- Go to your extension
Info.plist
and add those variables.
Bundle version string -- $(FLUTTER_BUILD_NAME)
Bundle version -- $(FLUTTER_BUILD_NUMBER)
- Go to your Project settings and select a
Generated
config file for your extension for each configuration.
Author by
pa2Codes
Updated on December 27, 2022Comments
-
pa2Codes over 1 year
The Flutter App version from pubspec.yaml can be used in the regular iOS Info.plist file by changing entries to
<key>CFBundleShortVersionString</key> <string>$(FLUTTER_BUILD_NAME)</string> <key>CFBundleVersion</key> <string>$(FLUTTER_BUILD_NUMBER)</string>
However I have created a Notification Service Extension to enable FCM Rich Text Push Notifications which is working fine. But when I change the Info.plist values of this extension to the same like above, the App fails with the following build error:
Unable to install /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app on <ID>. This is sometimes caused by a malformed plist file: ProcessException: Process exited abnormally: An error was encountered processing the command (domain=IXErrorDomain, code=2): Failed to create plugin placeholder for /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app/PlugIns/NotificationService.appex Failed to create promise. Underlying error (domain=IXErrorDomain, code=2): Failed to set placeholder attributes com.mycompany.appid.NotificationService Failed to create promise. Command: xcrun simctl install <ID> /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app Error launching application on iPhone 11 Pro.
How can I use the same variables also in the Extensions Info.plist file? I think it's just some config but I can't figure it out.
Thanks!!
-
Selast Lambou almost 3 yearsHey! Did you find a solution to this problem? I'm having the same
-
pa2Codes almost 3 years@SelastLambou Sadly not. What I do now is I have a script in my build pipeline that changes the value. But this is not a solid solution.
-