Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFBundleShortVersionString & CFBundleVersion Sync while Build Generation for iOS #1956

Closed
tirth-multipl opened this issue Apr 22, 2024 · 30 comments
Labels
bug Something isn't working cli ios

Comments

@tirth-multipl
Copy link

Description

CFBundleShortVersionString & CFBundleVersion are not sync when generating iOS build with shorebird. These are soft-warnings. ⚠️

Steps To Reproduce

shorebird release ios --flavor prod  -- --dart-define=BASE_URL=<url>

Expected Behavior

CFBundleShortVersionString & CFBundleVersion should sync when generating iOS build with shorebird.

Warnings

CFBundleShortVersionString Mismatch. The CFBundleShortVersionString value '1.15.32' of extension 'Runner.app/PlugIns/NotificationService.appex' does not match the CFBundleShortVersionString value '1.15.67' of its containing iOS application 'Runner.app'.

CFBundleVersion Mismatch. The CFBundleVersion value '2142' of extension 'Runner.app/PlugIns/NotificationService.appex' does not match the CFBundleVersion value '250' of its containing iOS application 'Runner.app'.
@tirth-multipl tirth-multipl added the bug Something isn't working label Apr 22, 2024
@eseidel eseidel added this to 1.1 Apr 22, 2024
@eseidel eseidel moved this to Customers in 1.1 Apr 22, 2024
@bryanoltman
Copy link
Contributor

If I'm understanding correctly, the issue is that your app extension version and your app version are not the same. Shorebird does not manipulate your app version or the versions of your app extensions. Are you suggesting that it should, or am I misunderstanding the problem?

@tirth-multipl
Copy link
Author

yeah you're correct but when we do normal build generation w/o shorebird, this issue doesn't happen.

@bryanoltman
Copy link
Contributor

When you say "normal build generation", what do you mean exactly? How do you normally perform your builds?

@tirth-multipl
Copy link
Author

When you say "normal build generation", what do you mean exactly? How do you normally perform your builds?

Without Shorebird I meant.

flutter build ipa --flavor prod --dart-define=BASE_URL=<url>

@eseidel
Copy link
Contributor

eseidel commented May 30, 2024

I would be useful to understand which versions the Runner.app and Runner.appx end up with after a normal flutter build vs. a shorebird build. It's not clear to me which version is correct. I presume 1.15.67 is the "correct" version and the appx is just lagging behind for some reason? I also wonder if flutter also isn't updating the version of the appx but swallowing the log?

shorebird just uses flutter build to do the underlying build, so it shouldn't affect this aspect. Although it's possible that we're showing logs from flutter build that flutter build is hiding by default?

@bryanoltman
Copy link
Contributor

I don't think we have enough information to understand and fix this issue. Closing due to inactivity.

@github-project-automation github-project-automation bot moved this from Pending Customer Reply to Done in 1.1 Jun 24, 2024
@c0dezli
Copy link

c0dezli commented Aug 6, 2024

Having the same problem, unable to release the app because of this

@eseidel
Copy link
Contributor

eseidel commented Aug 9, 2024

Having the same problem, unable to release the app because of this

Would love to help. If you build with flutter build ipa does it work?

@tpkowastaken
Copy link

tpkowastaken commented Sep 6, 2024

@c0dezli @tirth-multipl
I got the same issue and found the solution.

So I use firebase messaging (fcm) for my push notifications. I need to also display small images inside of these notifications to better illustrate them. For that you need to add an extension to allow displaying images which is how the OP probably got here as well. Setup: https://firebase.google.com/docs/cloud-messaging/flutter/receive#step_3_-_use_the_extension_helper

Since this is a different target than Runner. It doesn't have marketing version and current project version set by flutter:

Screenshot 2024-09-06 at 23 51 44

For OP it would be 2142 for the current project version and 1.15.32 for the marketing version.

Now this usually isn't a problem because manageAppVersionAndBuildNumber exists. This automatically sets the Runner version for all the targets.

However shorebird sets this to false. It apparently requires it. When I tried to use export_options.plist with it enabled it failed.

There is a way to sync the flutter version tho:

1. Create a debug and release config file

create two new config files in xcode. Name them something like short extension name and debug/release

Screenshot 2024-09-06 at 23 59 25
Screenshot 2024-09-06 at 23 59 06
Screenshot 2024-09-07 at 0 00 50

2. Include the flutter generated config to those configs

debug config:

#include? "Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig"
#include "Flutter/Generated.xcconfig"

release config:

#include? "Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.release.xcconfig"
#include "Flutter/Generated.xcconfig"

replace the NotificationService with your target name

3. Apply this config in the project info

Screenshot 2024-09-07 at 0 08 11

(imgdebug in the image is the config file we just created for debug)

4. Set the variables to marketing version and current project version:

Current project version: $(FLUTTER_BUILD_NUMBER)
Marketing version: $(FLUTTER_BUILD_NAME)

Screenshot 2024-09-07 at 0 10 14

Screenshot 2024-09-07 at 0 10 21

If you managed to follow it correctly it should appear as the number.

5. Set it in the Notification target (or the one causing problems) info.plist as well:

	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>

That should fix it! Good luck

@AhmedLSayed9
Copy link

AhmedLSayed9 commented Oct 22, 2024

This issue occurs to us when building using shorebird with Notification Service Extension on iOS:
Screenshot 2024-10-22 at 7 24 09 AM

The solution from @tpkowastaken didn't help (we're using flavors).

@bryanoltman, Can we re-open this?

@eseidel
Copy link
Contributor

eseidel commented Oct 22, 2024

Happy to.

My current understanding is that Shorebird disables manageAppVersionAndBuildNumber. I'm not sure I remember why we do this.

Shorebird needs to be able to read the exact app version of your app so that we can look up patches for it when requests come in from your app. Your app will send requests to Shorebird's servers such as "{app_id: 1234-abcd, version: "1.0.0+1"}". When you build your app, we record the release number that it had at time of building. I'm not sure if manageAppVersionAndBuildNumber was delaying this number setting until submission time or what.

But it sounds like manageAppVersionAndBuildNumber does more than we understood it to. It doesn't just auto-manage the app version, it also manages the extension versions. Since Flutter doesn't set the extension versions itself, when you have manageAppVersionAndBuildNumber off and build with Flutter (which is what Shorebird does under the covers) an extension version won't get set.

@bryanoltman do you remember why we set manageAppVersionAndBuildNumber to false?

@eseidel eseidel reopened this Oct 22, 2024
@bryanoltman
Copy link
Contributor

manageAppVersionAndBuildNumber causes Xcode to change the build number of the app after it has been packaged, meaning the version reported to shorebird the release created will be different than what the app reports once it has been released.

@eseidel
Copy link
Contributor

eseidel commented Oct 22, 2024

Yeah, so I think our possible actions here are:

  1. Change shorebird to read the release information from the ipa/archive after the adjustments by XCode are made. It's unclear how to do that, however, since it's not clear when XCode makes the adjustments. We could make shorebird do the archive step which presumably includes the version bump, but that's more complexity we'd need to explain to the user.
  2. Remove Shorebird's use of the version code at all. This is also needed for something like fix: AAR should not use app release version samples#11 (which causes a bunch of problems for AAR users). The difficulty there is that we use the version code right now as a short-hand for the uniqueness of the apk/ipa when asking our servers for updates. The nice thing about the version code is that it's guaranteed unique by the stores. If we generated our own UUID per release (for example) we would then make the build otherwise non-deterministic (since if you built the same sources twice they would get to different UUIDs). One solution is that we could use the build UUID (that XCode generates) instead of the version-code on iOS? I suspect that could work. Hmm, but I think that's path-sensitive. I believe XCode generates them on build and then caches the generation on a per-path basis. So they're also non-deterministic, but cached per machine.

@eseidel
Copy link
Contributor

eseidel commented Oct 22, 2024

A 3rd option would be to teach flutter build ipa to update the extension version codes, like it already knows how to set the app version codes. I suspect that's actually the easiest option.

@alegos27
Copy link

Same issue here, are there any update o temporary solution?

@eseidel
Copy link
Contributor

eseidel commented Nov 13, 2024

@bryanoltman do you agree that "option 3" is the correct path forward here? e.g. that I should file a bug with flutter to have it set the version code of the extensions when it does for the app?

@bryanoltman
Copy link
Contributor

I have not been able to reproduce this issue, so I'm not totally sure.

@bryanoltman
Copy link
Contributor

Which isn't to say there's not an issue here, but I attempted to reproduce by adding a notification extension to the Flutter counter app example and going through the shorebird release+patch flow, and I did not see this happen, so I think there's more to this than simply "the app has an extension"

@AhmedLSayed9
Copy link

Which isn't to say there's not an issue here, but I attempted to reproduce by adding a notification extension to the Flutter counter app example and going through the shorebird release+patch flow, and I did not see this happen, so I think there's more to this than simply "the app has an extension"

Can you check if you get the warnings when uploading to transporter?

@bryanoltman
Copy link
Contributor

@AhmedLSayed9 happy to—I'm not sure I went that far before. Does everything work as intended up to that point? The original bug makes it seem like this should happen much earlier (when running shorebird release ios)

@AhmedLSayed9
Copy link

@AhmedLSayed9 happy to—I'm not sure I went that far before. Does everything work as intended up to that point? The original bug makes it seem like this should happen much earlier (when running shorebird release ios)

I'm not sure but I get an email from Apple and warnings at transporter. I guess I have to test this again.
Btw, the counter example should have a different build version rather than the default 1.0.0+1 to re-produce this.

@bryanoltman
Copy link
Contributor

Ok, I'm seeing the issue upon uploading using Transporter. Thanks! I'll look into it.

@eseidel
Copy link
Contributor

eseidel commented Nov 13, 2024

It's possible running local validation would also trigger this?
https://stackoverflow.com/questions/7568420/how-to-perform-ios-app-validation-from-the-command-line

xcrun -sdk iphoneos Validation /path/to/App.{app or ipa}

@bryanoltman
Copy link
Contributor

Error text, received via an email from Apple:

ITMS-90473: CFBundleShortVersionString Mismatch - The CFBundleShortVersionString value '1.0' of extension 'Runner.app/PlugIns/NotificationService.appex' does not match the CFBundleShortVersionString value '1.0.0' of its containing iOS application 'Runner.app'.

@AhmedLSayed9
Copy link

Error text, received via an email from Apple:

ITMS-90473: CFBundleShortVersionString Mismatch - The CFBundleShortVersionString value '1.0' of extension 'Runner.app/PlugIns/NotificationService.appex' does not match the CFBundleShortVersionString value '1.0.0' of its containing iOS application 'Runner.app'.

Exactly.
Also, You should receive another warning ITMS-90473: CFBundleVersion Mismatch if you update the CFBundleVersion value of the app.

@bryanoltman
Copy link
Contributor

bryanoltman commented Nov 13, 2024

Weirdly, this does not seem to be an issue when uploading a build created with flutter build ipa --release.

Edit: trying now with our ExportOptions.plist

@bryanoltman
Copy link
Contributor

Confirming that this happens with stock Flutter when passed an ExportOptions.plist generated by Shorebird.

@bryanoltman
Copy link
Contributor

Fixed by #2620

@bryanoltman
Copy link
Contributor

The fix for this was just released with Shorebird v1.4.12

@tpkowastaken
Copy link

Love your work. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli ios
Projects
Status: Done
Development

No branches or pull requests

7 participants