shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
2.34k stars 141 forks source link

fix: --dart-define modifier doesn't seem to work when creating IOS releases. #1744

Closed MonkeyDoDev closed 8 months ago

MonkeyDoDev commented 8 months ago

App ID: 130984c0-a89c-44a0-972b-f29f9725b216

Description

In my app, i pass an API key as part of the build instruction. However, after creating a release with shorebird, when i run shorebird preview on my IOS device i get an error indicating the API key isn't recognised.

This is not a problem for Android

shorebird release android '--' --dart-define=[apiKey]=[key] - WORKS shorebird release ios '--' --dart-define=[apiKey]=[key] - DOESN'T WORK

I tried creating a release 3 times just to be sure, and every time the api key wasn't working (btw i tried both '--' and -- with the same result).

Not this is NOT a problem when i create a regular build. It is only when i create a release with shorebird.

Steps To Reproduce

  1. I created an IOS release with shorebird release ios '--' --dart-define=[apiKey]=[key]
  2. i run 'shorebird preview ios'

Expected Behaviour

The fully functional app to run on account of the API key being correctly implemented

bryanoltman commented 8 months ago

I was unable to reproduce this. I created a test project – can you download it and try to reproduce? https://github.com/bryanoltman/dart_define_test

eseidel commented 8 months ago

There were changes in 3.19.0 relating to dart defines on iOS which could be related here: https://github.com/flutter/flutter/issues/138793. (The change the author is referencing isn't directly related to this reported issue, but suggests there were changes in the handling of dart defines which could result in other related issues.)

MonkeyDoDev commented 8 months ago

Hi Bryan,

I got the following error when creating the release

@.*** dart_define_test % shorebird release ios -- --dart-define=MY_VAR=HELLO ✓ Fetching apps (0.2s) ✗ Failed to build (71.6s) Failed Registering Bundle Identifier No profiles for 'dev.shorebird.ios-test' were found

Is this because I need to register the app bundle id with my apple developer account or something?

On 21 Feb 2024, at 15:29, Bryan Oltman @.***> wrote:

I was unable to reproduce this. I created a test project – can you download it and try to reproduce? https://github.com/bryanoltman/dart_define_test

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1956951441, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCWGH6VTUJG2RIYSF5DYUYHE3AVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJWHE2TCNBUGE. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

Yes, you'll need to update the project to be runnable on your device by choosing a bundle ID you control and an appropriate provisioning profile/cert in Xcode

bryanoltman commented 8 months ago

(I would change the bundle ID to one you already own rather than going through the trouble of setting up a new one)

MonkeyDoDev commented 8 months ago

Hi Bryan,

It worked fine from my computer so I tried again with my actual project

Firstly I tried...

flutter run --dart-define=tmdbKey={my api key}

This worked fine…

Then I tried...

shorebird release ios -- --dart-define={my api key}

This failed exactly as it did the other 3 times…

I don’t know if it helps but my exact error I get is attached. I thought I’d share it because it’s a dio exception and I know dio has been a naughty package recently.

. 

On 21 Feb 2024, at 16:00, Bryan Oltman @.***> wrote:

(I would change the bundle ID to one you already own rather than going through the trouble of setting up a new one)

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1957084215, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCUJZWCSAFPIFIYCOCTYUYK2DAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGA4DIMRRGU. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

I think the attachment might've failed?

MonkeyDoDev commented 8 months ago

Must be apple mails infuriating tendency to display images in the email body.

How about the attached zip?

On 21 Feb 2024, at 16:46, Bryan Oltman @.***> wrote:

I think the attachment might've failed?

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1957263227, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCW3XQQM5EWGARF2PF3YUYQGZAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGI3DGMRSG4. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

Nope :) Maybe try a Dropbox/Drive link?

MonkeyDoDev commented 8 months ago

I swear to god technology has regressed these past 20 years!

I’ve just tried sending to your GitHub email address from my actual IOS device so hopefully that works. Let me know if not and I’ll work out how to share something on google drive.

On 21 Feb 2024, at 16:53, Bryan Oltman @.***> wrote:

Nope :) Maybe try a Dropbox/Drive link?

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1957287695, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCQYSAPUAF6XSG5J5M3YUYRCBAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGI4DONRZGU. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

Alright, got it. It's tough to say what that error might be – I don't think it's shorebird-related, but it's surprising that you'd be getting a 401 with shorebird and not stock flutter. Can you print the actual request that's going out to the console and see if/how that differs between the two builds?

bryanoltman commented 8 months ago

For reference, the error:

IMG_0049

MonkeyDoDev commented 8 months ago

Hi Bryan,

Apologies for the late response. I had to pick my daughter up from nursery.

Im afraid I don't know how to print statements to the console when shorebird is previewing. However, I can confirm that the error screen is the exact screen I get in debug mode if I choose not to pass the API key when I run it.

I have just generated a normal IOS release build without shorebird and submit it to TestFlight and can confirm that the app opened fine and the apiKey was working properly so at this stage I can confirm that nothing is breaking in the vanilla build process.

The problem literally only occurs when I’m generating and then previewing a release with shorebird , and this happens on IOS only, so I can’t see how this can be anything other than shorebird-related. Or to put it another way… if it’s not shorebirds fault… it’s at the least shorebirds problem! ;)

Would it help if I added you as a collaborator again on my repo and gave you the apiKey to try yourself?

Kind regards Alex

On 21 Feb 2024, at 17:02, Bryan Oltman @.***> wrote:

Alright, got it. It's tough to say what that error might be – I don't think it's shorebird-related, but it's surprising that you'd be getting a 401 with shorebird and not stock flutter. Can you print the actual request that's going out to the console and see if/how that differs between the two builds?

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1957316280, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCQUPUQ5M5K63LN5HI3YUYSCDAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGMYTMMRYGA. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

Agreed that this is something we should investigate and fix. I'm happy to try your codebase by myself if I can get it configured and running in a reasonable time as well.

Re: printing to the console, any print statements will show up in the console output of shorebird preview.

MonkeyDoDev commented 8 months ago

Hi Bryan,

Ahh I was using Logger statements hence nothing in the console. I can see print statements do work.

To avoid wasting any more of your time than necessary I’ll do abit of investigation on my end with the print statements to see if I can get to the bottom of it. I’ll get back you when I either have an answer or am at a loss ;)

Kind regards Alex

On 22 Feb 2024, at 14:53, Bryan Oltman @.***> wrote:

Agreed that this is something we should investigate and fix. I'm happy to try your codebase by myself if I can get it configured and running in a reasonable time as well.

Re: printing to the console, any print statements will show up in the console output of shorebird preview.

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1959618787, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCRI2VXFWA46QSFYA5DYU5LW7AVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZGYYTQNZYG4. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

Let me know what you find. Happy to help in any way I can!

MonkeyDoDev commented 8 months ago

Hi Bryan,

Did you change anything that might have fixed this?

I was having issues updating my IOS release (for which I’ve logged another bug #1746) and so ended up updating my build number and creating a new release.

This time it WORKED!!!

I’m pretty sure I didn’t change anything in my build that would have fixed this so I’m wondering if you changes something on the back end? Either that or perhaps what I was doing uploading new releases with the same build number (see bug #1746) was part of the problem.

Anyway - Thats the good news… The bad news is that I experience random crashes when running IOS in preview.

I have attached a couple of .ips logs from 2 separate sessions where the app crashed…

Im starting to wonder if shorebird requires a certain minimum level of professionalism in the code to reliably work! Perhaps my app is just too riddled with weirdness!



On 22 Feb 2024, at 17:05, Bryan Oltman @.***> wrote:

Let me know what you find. Happy to help in any way I can!

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1959884037, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCVNAWUHF5S2XGLT5ODYU53FBAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZHA4DIMBTG4. You are receiving this because you authored the thread.

bryanoltman commented 8 months ago

It looks like the mail attachment didn't work again :(

bryanoltman commented 8 months ago

Im starting to wonder if shorebird requires a certain minimum level of professionalism in the code to reliably work!

It definitely should work anywhere Flutter works, and we're working to make sure that's the case. Bug reports like this are how we get there and are much appreciated 😄

bryanoltman commented 8 months ago

Thanks for sending those. Attached them below.

MonkeyDoDevIps.zip

bryanoltman commented 8 months ago

For reference, this is for release 1.1.56 (74) (release id 34216) of app 130984c0-a89c-44a0-972b-f29f9725b216

bryanoltman commented 8 months ago

@MonkeyDoDev it looks like this release was created with Flutter 3.16.9, where this crash is expected. If you upgrade to flutter 3.19.0, this should be resolved.

Edit for more detail:

If you're using the latest version of shorebird (0.26.0), it's possible that previous uses of shorebird flutter versions use have stuck you on an old version. You can check this by running git -C $HOME/.shorebird status (which should say flutter.version has been modified if this is the case) and repair by running git -C $HOME/.shorebird reset --hard.

MonkeyDoDev commented 8 months ago

Hi Bryan,

Thats odd. I created that build just a couple of hours ago and i'm definitely on Flutter 3.19.0 which ive just confirmed by running Flutter Upgrade and getting the below message. You can see the .ipa files are dated with todays date so I’ve not accidentally sent old crash files…

Anyhoo I’ve just updated to version 3.19.1 and will try another release tomorrow.

P.S - I often get that ‘your flutter checkout has local changes’ message and just use ‘—force’ to dismiss it. I have no idea what causes it but am certain ive done no intentional edits to the flutter source files. Whenever I get something weird like that my policy is to blame Xcode because I just have no idea what it’s doing all the time. ;0) - Anyway, im signing off for the evening so have a good day

***@***.*** buck_the_critics % flutter upgrade
Your flutter checkout has local changes that would be erased by upgrading. If you want to keep these changes, it is recommended that you stash them via "git stash" or else commit the
changes to a local branch. If it is okay to remove local changes, then re-run this command with "--force".
***@***.*** buck_the_critics % flutter upgrade --force
Upgrading Flutter to 3.19.1 from 3.19.0 in /Users/monkeydev/FlutterDev/flutter...
Building flutter tool...
Resolving dependencies...
Got dependencies.

Upgrading engine...

Flutter 3.19.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision abb292a07e (2 days ago) • 2024-02-20 14:35:05 -0800
Engine • revision 04817c99c9
Tools • Dart 3.3.0 • DevTools 2.31.1

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.3.1 23D60 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
***@***.*** buck_the_critics % 

On 22 Feb 2024, at 17:54, Bryan Oltman @.***> wrote:

@MonkeyDoDev https://github.com/MonkeyDoDev it looks like this release was created with Flutter 3.16.9, where this crash is expected. If you upgrade to flutter 3.19.0, this should be resolved.

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1959967819, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCRW7FHPA3ITT34WDYLYU6A4NAVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZHE3DOOBRHE. You are receiving this because you were mentioned.

bryanoltman commented 8 months ago

Shorebird uses a different Flutter checkout than what is on your path (we have modified the engine to make code push possible). You can see what version shorebird using with shorebird doctor. An up-to-date shorebird installation will print

Shorebird 0.26.0 • git@github.com:shorebirdtech/shorebird.git
Flutter 3.19.0 • revision 8679396700d040e779463461c7c79ba08d130209
Engine • revision 62fa4e8bb30f56eb658989d3e6a982cb787d79d6
bryanoltman commented 8 months ago

(To be clear, this confusion is absolutely our fault. The shorebird flutter versions use command was a bit of a footgun and is now deprecated because it was leading to this exact kind of situation (regardless of how the user's level of professionalism 😉))

MonkeyDoDev commented 8 months ago

Lolz!

Never mind. I’m happy to report all my problems are solved having updated shorebird and republished with a new build version so I’m a happy sausage

Thanks for your support

On 22 Feb 2024, at 18:40, Bryan Oltman @.***> wrote:

(To be clear, this confusion is absolutely our fault. The shorebird flutter versions use command was a bit of a footgun and is now deprecated because it was leading to this exact kind of situation (regardless of how the user's level of professionalism 😉))

— Reply to this email directly, view it on GitHub https://github.com/shorebirdtech/shorebird/issues/1744#issuecomment-1960040795, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6AHYCWMGBO6ZZER4O3V2E3YU6GI3AVCNFSM6AAAAABDTBV7UWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRQGA2DANZZGU. You are receiving this because you were mentioned.

bryanoltman commented 8 months ago

Great to hear! Don't hesitate to reach out if you run into any other issues, and thanks for your patience