Flutter: After enabling web support... iOS simulators disappeared - ios

I have followed below url and enabled web for my flutter application.
https://flutter.dev/docs/get-started/web
flutter channel master
flutter config --enable-web
flutter create .
flutter run -d chrome
flutter build web
Everything went well and I am able to launch my application on Web. However, after enabling web my ios simulators not appearing in devices list.
flutter devices
2 connected devices:
Chrome • chrome • web-javascript • Google Chrome 80.0.3955.4 dev
Web Server • web-server • web-javascript • Flutter Tools
Could someone help me to resolve this issue?
Here's my environment:
flutter --version
Flutter 1.10.15-pre.424 • channel master •
https://github.com/flutter/flutter.git
Framework • revision 289b458 (21 hours ago) • 2019-11-06 02:51:17 -0500
Engine • revision 9726b4cb99
Tools • Dart 2.7.0
dart --version
Dart VM version: 2.6.0 (Thu Oct 24 17:52:22 2019 +0200) on "macos_x64"

As discussed here https://github.com/flutter/flutter/issues/44326 I have updated my xcode from 9.4.1 to 11.2. Now the issue is fixed and I am able to see all devices.

Related

Flutter Firebase app runs fine in simulator but crashes when tested in testflight

Recently I've joined a project of a flutter app using firebase, and everything was fine until it comes to make the production builds. For Android it works fine. But for ios I'm facing a problem that in the simulator it runs without a problem but when I uploaded it to Testflight for my coworkers to test it immediately crashes when opened.
That's my flutter doctor -v:
[✓] Flutter (Channel unknown, 2.2.2, on macOS 11.2.3 20D91 darwin-x64, locale
pt-BR)
• Flutter version 2.2.2 at /Users/leonardofelix/flutter
• Framework revision d79295af24 (4 months ago), 2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/leonardofelix/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.61.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.27.0
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • 94BE45CC-ED04-4892-B3A6-3F43D0A147AD • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 94.0.4606.81
And the crash report that a tester of testflight sent to me:
crashlog.crash
I've already tested some things that I found googling, like add the Google-Services.plist again using xcode and verified if the schemas to the archive were pointing to release mode. But none of them worked.
If any additional data is needed, I'll be glad to provide. So thanks in advance for any help.
Well, I found the error. I had changed the Flutter version using git (thus, the Flutter folder is a git repository). When I changed the version, it left the cache from the other Flutter version, and that cache was causing the problem.
One thing that helped me to find this out was running the release build in a physical device using Xcode; there it prompt me the following error:
Error while initializing the Dart VM: Wrong full snapshot version, expected '9cf77f4405212c45daf608e1cd646852' found 'e4a09dbf2bb120fe4674e0576617a0dc'
And for that, I found a solution on the web. What I did was to remove the folder cache inside <yourFlutterDir>/bin and run the following commands in the Flutter directory:
git reset --hard
git clean -xffd
flutter doctor
And then, I went to my Flutter project folder, ran flutter clean, and finally flutter build ios.
So the project built successfully, and the app worked in iOS.

How to upgrade your flutter project (app) to the latest flutter version after null safety?

I want to upgrade my project which is on Flutter 2.0 to the latest version of flutter (2.5).
I have already seen this question which is most relevant.
How do I upgrade an existing Flutter app?
In my Mac, I have Flutter upgraded to 2.5. You can see the output of flutter doctor -v below:
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-arm, locale
en-PK)
• Flutter version 2.5.0 at /Users/ahmad/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4cc385b4b8 (9 days ago), 2021-09-07 23:01:49 -0700
• Engine revision f0826da7ef
• Dart version 2.14.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/ahmad/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.11.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • 57868E1C-4871-4185-A797-383121736AB8 • ios
• com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
• Chrome (web) • chrome •
web-javascript • Google Chrome 93.0.4577.82
• No issues found!
I have searched over the internet about it. Mostly, I see two things, either how to upgrade to null-safety (which means from earlier versions to 2.0) or how to upgrade Flutter sdk in your system.
I have tried running flutter upgrade command which says I'm up-to-date.
I have also tried running flutter pub upgrade.
Both do not change the version of flutter in the pubspec.lock file inside my project which says at the end of file:
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.0.0"
Please guide me how can I upgrade my project to the latest version.
Thanks in advance :)
The Flutter project will have the same version as your system does. If you have the latest Flutter version on your system, then the app built from that system will have the latest version.
For example, if your system has Flutter 2.8 (latest while answering) and you build an app through it, your app is based on 2.8.
You're using flutter: >=2.0.0 which basically tells your app to use 2.0.0. Usually using the flutter sdk constraint is only used in plugins. It's okay to leave this out, if you remove flutter: >=2.0.0 it will automatically use your SDK version

iOS flutter app not running after updating device to iOS 14.7.1

After updating my iPhone 11 to iOS version 14.7.1, my flutter app is not launching anymore.
Steps already performed:
flutter clean
flutter pub get
flutter run
Also,
uninstalled and reinstalled the app
restarted the phone
output:
(base) Henrys-MacBook-Air:flutter henrycorreia$ flutter run
Running "flutter pub get" in flutter... 3.2s
Launching lib/main.dart on Henry’s iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: XXXXXXXXXX
Running pod install... 25.0s
Running Xcode build...
Xcode build done. 208.8s
Installing and launching... 58.4s
Error launching application on Henry’s iPhone.
==>> flutter doctor -v:
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale en-GB)
• Flutter version 2.2.3 at /Users/henrycorreia/fvm/versions/2.2.3
• Framework revision f4abaa0735 (6 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/henr/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.59.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.25.0
[✓] Connected device (3 available)
• Moto E 4 Plus (mobile) • xxxxxxxxx • android-arm • Android 7.1.1 (API 25)
• Henry’s iPhone (mobile) • xxxxxxxxxxxxxx • ios • iOS 14.7.1
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
! Doctor found issues in 1 category.
Is anybody facing the same issue? Any idea how to fix this?
Thank you
You have runtime error just before your first screen renders, try putting breakpoint in the first line of the main and debug line by line.
I was able to fix the issue. It seems to be a random issue that happens time to time when updating either the flutter version or iOS...
Here's how I fixed the issue:
==>> you can also get inspired by this thread: https://github.com/flutter/flutter/issues/72161
However, what worked for me was very simple as I am using vs code:
uninstalled the app
restarted the phone
open the app using Xcode
Product -> Clean Build Folder
Product -> Run
The app will launch correctly, then quit Xcode
After that, I run the app using vs code, and now it works as before.

SocketException: Failed host lookup: 'www.xyz.com' (OS Error: nodename nor servname provided, or not known errno = 8)

I wrote a Flutter app which connects to a web server running on a separate machine using the dart http package. On my local machine (Mac) I added the hostname 'www.xyz.com' to /etc/hosts and everything works fine when using the IOS Simulator. I would like to test the app on a real device (iPhone SE) but don't want to jailbreak the device. Because it's not possible to edit the hosts file on the phone without jailbreaking it, I installed Weblock which allows to setup redirect rules. I am able to start the app on my phone, however, when making a request to the web server on the separate machine (in my local network) I get the following error:
SocketException: Failed host lookup: 'www.xyz.com' (OS Error: nodename nor servname provided, or not known errno = 8)
From outside the app I can access the web server via 'www.xyz.com' in my browser.
To summarize:
App running in IOS simulator on machine A and connecting to web server on machine B -> works fine
App running on real device and connecting to web server on machine B -> error
Connecting to web server on machine B via browser on Phone -> works fine
Output flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13, on Mac OS X 10.15.4 19E287, locale en-DE)
• Flutter version 1.12.13 at /Users/Jonas/Documents/Programming/flutter
• Framework revision cf37c2cd07 (5 months ago), 2019-11-25 12:04:30 -0800
• Engine revision b6b54fd606
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/Jonas/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-R, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.4)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 45.0.2
• Dart plugin version 193.6911.31
[!] IntelliJ IDEA Community Edition (version 2019.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• Jonass iPhone • 5ea0e7db176aeb6f278f88f410fb9d0fd4256658 • ios • iOS 13.4.1
! Doctor found issues in 1 category.
Thanks!

iOS Flutter not getting push notifications

I'm having issues setting up push notifications for iOS on Flutter.
Another dev tried adding too - had the same problem.
TL;DR: Can anyone get pushes running on iOS Flutter with clean new build from stable channel?
I followed setup steps described here:
https://pub.dev/packages/firebase_messaging
Specifically:
Generated app ID and push Key in https://developer.apple.com/account/resources/certificates/
Added info.plist to ios/Runner folder
Turned on Push capabilities
Uploaded APNS certificate to Firebase console
Made sure bundle ID is the same in App / Runner, info.plist and GoogleService-Info.plist
Added lines in AppDelegate.swift
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
Pushes aren't coming. Neither when app in background, not at all.
I also tried another step - sending individual push. Send code in CURL looks like this:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:key=AIza_legacy_key" \
-d \
'{
"to": "my_push_token",
"notification":
{"body": "test_body",
"title": "test_title"
},
"priority": "high",
}
' \
'https://fcm.googleapis.com/fcm/send'
And the response is always this type:
- First request is InvalidRegistration
- Second and next same calls is NotRegistered
Another person found similar problem this summer and posted on GitHub, but thread was closed:
https://github.com/flutter/flutter/issues/30486
My Flutter doctor:
[✓] Flutter (Channel unknown, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale ru-UA)
• Flutter version 1.12.13+hotfix.7 at /Users/reiven/flutter
• Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/reiven/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio 3.6 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.7.5
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio 3.6 Preview.app/Contents
• Flutter plugin version 43.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (4 available)
• iPhone • 96c120610d684dbab7f5e4d036a7f48041755f96 • ios • iOS 12.3.1
• iPhone 11 Pro Max • 8ABC99D3-6C46-4A3D-968B-F5719AA92C97 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• Chrome • chrome • web-javascript • Google Chrome 79.0.3945.130
• Web Server • web-server • web-javascript • Flutter Tools
p.s. Some things I've tried:
Used another developer account (100% confirmed pushes are working on another project)
Used another Firebase account
Recreated certificates, projects
Gave to try another developer to setup pushes his own (he also confirmed to be successfull in the past).
Magically things just started working yesterday evening.
So first - just try now. If not working - recreate certificates and redo initialization steps. If still not working - pray and retry another day.

Resources