Flutter Http request not being executed on iOS - ios

This is the first request my app executes in order to log in the user. On android, every request works fine but, for some reason, on iOS they don't seem to be executed. I already have set up the developer options on the simulator to allow HTTP Services. I have also tested the code on a physical iPad, and it won't execute the request.
During testing i am not using any timeout for this and if I leave the code running for a while once I have triggered the request, i get this log (it might not be relevant for this, but since i don't know what it is, I will attach it too):
[C1.1 958047F2-81ED-4A34-AEDE-A23D2CD6B49F 172.20.129.134:51780<->216.58.211.42:443]
Connected Path: satisfied (Path is satisfied), interface: en0
Duration: 240.322s, DNS #0.002s took 0.008s, TCP #0.017s took 0.014s, TLS took 0.287s
bytes in/out: 4769/1077, packets in/out: 9/10, rtt: 0.016s, retransmitted packets: 1, out-of-order packets: 0
Here's the code:
Future<LoginResponse> login(String login, String password, AppLocalizations locale) async {
final response = await http.post(_url, body: {
"module": _moduleLogin,
"user": login,
"pass": password,
"lang": locale.localeName
});
try{
EventManager manager = EventManager.getInstance();
manager.clearAllEvents();
}catch(e){
print(e);
}
if (response.statusCode == 200) {
return LoginResponse.fromJson(jsonDecode(response.body));
} else {
throw Exception('Failed to connect to webservice');
}}
At this point I don't know what can be causing this problem. I am using the latest version of the http package.
Here's my flutter doctor output:
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.14 18A391, locale es-ES)
• Flutter version 0.9.4 at /Users/alex/Documents/Development/flutter
• Framework revision f37c235c32 (4 months ago), 2018-09-25 17:45:40 -0400
• Engine revision 74625aed32
• Dart version 2.1.0-dev.5.0.flutter-a2eb050044
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/alex/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 27.0.3
• ANDROID_HOME = /Users/alex/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.2
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 26.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 26.0.2
• Dart plugin version 181.4445.29
[✓] VS Code (version 1.30.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.21.1
[✓] Connected devices (1 available)
• iPhone XS • 5FB9A137-7AB3-46B5-94BC-9562B0E5E752 • ios • iOS 12.1 (simulator)
• No issues found!

Figured out a solution even though I don't know why does it work.
I replaced the http package with the dio package and it worked fine on both platforms.

Related

PhaseScriptExecution error but doesn't specify the problem

I know this problem already exists everywhere, but I tried most of the solutions of this and still none of them work. The log doesn't seem to specify what's the problem, only shows the said PhaseScriptExecution error.
What else can I do to solve this?
Tried running, re-running, deleting pods files, cleaning, rebuilding, etc.
I'm trying to run a flutter app in a physical device.
Also tried running in a clean project, but the same error persists.
XCode 13.4.1
MBPM1
flutter doctor -v :
Flutter (Channel master, 3.4.0-30.0.pre.19, on macOS 12.4 21F79 darwin-arm64, locale en-PT)
• Flutter version 3.4.0-30.0.pre.19 on channel master at /Users/henriqueguima/work/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f2c6033739 (4 months ago), 2022-09-26 03:50:27 -0400
• Engine revision 53a7659ea1
• Dart version 2.19.0 (build 2.19.0-240.0.dev)
• DevTools version 2.17.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/henriqueguima/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 13F100
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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.12+0-b1504.28-7817840)
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (3 available)
• iPhone (mobile) • 2c12eaae0fc97e504f295ea6cb964ab6904f42cd • ios • iOS 15.7.2 19H218
• macOS (desktop) • macos • darwin-arm64 • macOS 12.4 21F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
! Error: iPhone is busy: Making iPhone ready for development. Xcode will continue when iPhone is finished. (code -10)
[✓] HTTP Host Availability
• All required HTTP hosts are available
XCode log -- https://pastebin.com/r0RLjiAP
EDIT: downgrade didn't work either

I am getting this error "ld: framework not found Flutter" after upgrade xcode latest Version 13.4.1 (13F100). tried all solution but not succeed

This is the screenshot of error after running the app
Here is
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale en-IN)
• Flutter version 3.0.2 at /Users/magespider/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cd41fdd495 (9 days ago), 2022-06-08 09:52:13 -0700
• Engine revision f15f824b57
• Dart version 2.17.3
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/magespider/Library/Android/sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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.12+0-b1504.28-7817840)
[✓] VS Code (version 1.68.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.42.0
[✓] Connected device (2 available)
• macOS (desktop) • macOS • darwin-arm64 • macOS 12.4 21F79 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115
! Error: Bhavin’s iPod is not connected. Xcode will continue when Bhavin’s iPod is connected. (code -13)
! Error: iPhone is busy: Waiting to connect and unlock the device. Xcode will continue when iPhone is finished. (code -10)
! Error: iPhone is not connected. Xcode will continue when iPhone is connected. (code -13)
! Error: Bhavin’s iPhone is not connected. Xcode will continue when Bhavin’s iPhone is connected. (code -13)
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Please help to resolve this issue, Thanks in advance
I tried the following solution
Deleted ios folder and then recreated
pod deintegrate, install
delete podfile, podfile.lock the Pods folder, and install the pod again.
tried to change the Other Linker Flag in Runner -> Build settings,
Added arm64 in Excluded Architecture.

Invalid Binary issue in flutter IOS build

So, yesterday I build an app for ios, archive it and upload it to AppStore connect through xcode, everything seemed good but after few moments I received an email from apple saying:
Dear Developer,
We identified one or more issues with a recent delivery for your app, "APP-NAME" 1.0.1 (2). Please correct the following issues, then upload again.
ITMS-90755: Invalid Binary - The following binaries in your app contains prohibited instructions: /Volumes/data01/app_data/awf/SWImportWorker-mr47p00ce-swpr0068.cse.apple.com-300252/ff03-SoftwareImportWorker-MR_.0/NYH74E2GDJSTMWPVXUPB4IZWH4/umuagyjihbsjsrpn/wspvjpsuvltmmknh/Payload/Runner.app/Frameworks/App.framework/App. Remove the instructions from the binaries, rebuild and resubmit.
Best regards,
The App Store Team
I tried again with flutter clean and also increased the IOS deployment target but it didn't help.
My device's Flutter info:
Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale
en-PK)
• Flutter version 2.5.0 at /Users/niteshkongreja/Development/flutter
• Upstream repository https://github.com/niteshcongreja321/flutter.git
• Framework revision 4cc385b4b8 (10 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/niteshkongreja/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Users/niteshkongreja/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• 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.10.1
[✓] 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-7281165)
[✓] VS Code (version 1.60.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 11.5.2 20G95 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.82
• No issues found!
All I had to do was revoke my certificate, delete the mobileprovision file, then recreate both.
I also changed over to Air SDK 3.7.0.1530 and included the Default-568h#2x.png for the iphone splash screen, and well... it seems to have worked.

How do I listen to a cloud firestore stream in iOS (works fine on Android)?

I can successfully read and write to a cloud firestore database from within my app. However, when running on an iOS simulator (or real device) I cannot listen to a stream for realtime changes to a document through Riverpod or standard StreamBuilder. No errors or exceptions are thrown when listening to the stream. The stream exists, it just doesn't have data in it. This problem DOES NOT exist when running on an Android emulator.
StreamProvider
final athletePosStreamProvider = StreamProvider<GPSPoint>((ref) {
final _fsDB = FirebaseFirestore.instance;
print('Provider is active');
return _fsDB.collection('Athlete1').doc('currentPosition').snapshots().map((document) {
print('stream data found');
return GPSPoint.fromFSMap(document.data());
});
});
Stream listen:
final athletePos = Provider<GPSPoint>((ref) {
GPSPoint _curPos;
print('athletePos is active');
Stream _docStream = FirebaseFirestore.instance.collection('Athlete1').doc('currentPosition').snapshots();
if (_docStream.isBroadcast == true) {
print('Stream is broadcasting');
}
_docStream.listen((event) {
print('athletePos stream event received');
_curPos = GPSPoint.fromFSMap(event.data());
});
return _curPos;
});
In both scenarios the first print statement fires, but the second print statement never fires on iOS. It will work correctly on Android.
pubspec.yaml
cloud_firestore: ^0.14.3+1
flutter_riverpod: ^0.12.1
flutter doctor
[✓] Flutter (Channel beta, 1.24.0-10.2.pre, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-US)
• Flutter version 1.24.0-10.2.pre at /Users/sgalway/development/flutter
• Framework revision 022b333a08 (11 days ago), 2020-11-18 11:35:09 -0800
• Engine revision 07c1eed46b
• Dart version 2.12.0 (build 2.12.0-29.10.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/sgalway/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• 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-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.2, Build version 12B45b
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] IntelliJ IDEA Community Edition (version 2020.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 47.1.3
• Dart plugin version 201.7846.93
[✓] VS Code (version 1.51.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[✓] Connected device (3 available)
• iPhone 11 Pro (mobile) • 21B0C3BA-D8B9-4AF2-81A5-FC8176E49F24 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.198
• No issues found!

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

I've looked elsewhere and every site keeps telling me this is effectively an internet connectivity error... But I know that can't be correct.
I'm using Flutter (dart) to program this for iOS (on a Mac). I've tried this on both the iOS simulator and an actual iPhone, and I'm getting the same error. Other calls to the same server work fine.
Future<Map> createTrip() async {
http.Response response = await http.post(
url,
headers: <String, String>{'authorization': basicAuth},
body: {'user_phone': user_phone, 'locationId1': locationId1, 'locationId2': locationId2},
);
info = jsonDecode(response.body);
sessionID = info['session_id'];
print (info['session_id']);
return info;
}
Works fine. In the response body it contains the session_id, and print-screen proves this variable is not empty.
BUT this:
Future<Map> getServerData(sessionID) async {
url = url + sessionID; //. <--- adding sessionID to end of a url-address
http.Response response = await http.get(
url,
headers: <String, String>{'authorization': basicAuth},
);
Map data = jsonDecode(response.body);
return data;
}
Does NOT work. Not entirely sure why. I even tried allowing unsecured data-transmission to the server in the info.plist.
My understanding or expectation is that MAYBE this is because the url I'm requesting doesn't exist on the server? It's the only thing that makes sense to me. If not, then what COULD it be?
Flutter Doctor results:
[✓] Flutter (Channel master, v1.14.2-pre.54, on Mac OS X 10.15.2 19C57, locale
en-CA)
• Flutter version 1.14.2-pre.54 at /Users/iosdev/Developer/flutter
• Framework revision da0bfd1c93 (32 hours ago), 2020-01-21 05:59:07 -0500
• Engine revision c15efb9231
• Dart version 2.8.0 (build 2.8.0-dev.3.0 f910a7575f)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/iosdev/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.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• 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.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
[✓] Connected device (2 available)
• Phillip’s iPhone • 52a4fba45a6767b88e4dddd881201205138cac0e • ios • iOS
13.3
• iPhone 11 Pro Max • 2F6FBCBE-CC96-4044-84FA-0DE39E441830 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
Make sure you have internet on your emulator or device. Check by opening your internet browser on your emulator or device to see if google.com will display successfully

Resources