Repository navigation
What should be the domainNetworkPolicy while using flutter in existing iOS App? #65580
Description
I have NSAppTransportSecurity already added with NSAllowsArbitraryLoads as "YES" and some "NSExceptionDomains"
App is crashing while initializing flutter engine:
+[FlutterDartProject domainNetworkPolicy:] + 352
Steps to Reproduce
-
Add App transport security to iOS Native app in info.plist
-
Set NSAllowsArbitraryLoads to YES
-
Add NSExceptionDomains dictionary
NSExceptionDomains
NSTemporaryExceptionAllowInsecureHTTPLoads
www.cloudflare.com
NSExceptionAllowsInsecureHTTPLoads
NSIncludesSubdomains
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
NSThirdPartyExceptionAllowsInsecureHTTPLoads
Logs
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean objectForKey:]: unrecognized selector sent to instance 0x7fff80634458'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512539b2 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23e5eb94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff23e4286c ___forwarding___ + 1436
4 CoreFoundation 0x00007fff23e44b58 _CF_forwarding_prep_0 + 120
5 Flutter 0x000000010a949967 +[FlutterDartProject domainNetworkPolicy:] + 352
6 Flutter 0x000000010a948db5 -[FlutterDartProject initWithPrecompiledDartBundle:] + 1371
7 Flutter 0x000000010a94b169 -[FlutterEngine initWithName:project:allowHeadlessExecution:] + 218
8 USMLE 0x0000000106ef4bbf -[AppDelegate application:didFinishLaunchingWithOptions:] + 111
The output of running flutter doctor -v
DevOps-MBP1:ios_fc vkallepalli$ flutter doctor -v
[✓] Flutter (Channel master, 1.22.0-10.0.pre.72, on Mac OS X 10.15.5 19F101, locale en-US)
• Flutter version 1.22.0-10.0.pre.72 at /Users/vkallepalli/flutter
• Framework revision bd3eee75f3 (7 days ago), 2020-09-03 11:55:55 -0700
• Engine revision 165abef0a2
• Dart version 2.10.0 (build 2.10.0-77.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/vkallepalli/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_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.9.3
[✓] 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.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)
[✓] VS Code (version 1.48.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.14.0
Please help!
Activity
[-]What should be the domainNetworkPolicy while using flutter in existing iOS App.[/-][+]What should be the domainNetworkPolicy while using flutter in existing iOS App?[/+]TahaTesser commentedon Sep 11, 2020
Hi @vamsi452
Can you please provide a complete reproducible minimal code sample in a repository including a sample flutter module
Thank you
mehmetf commentedon Sep 11, 2020
The problem (probably) is that you are using
YESinstead oftrue. XML format does not understand "YES".You would do something like this:
vamsi452 commentedon Sep 11, 2020
@mehmetf Its shows "YES" in info.plist but in xml it's "true"


mehmetf commentedon Sep 11, 2020
Please paste your full info.plist XML here and also let me know which version of iOS you are trying against. Thanks!
vamsi452 commentedon Sep 17, 2020
@mehmetf
iOS version 13
mehmetf commentedon Sep 17, 2020
I marked the problematic entry:
According to Apple documentation
NSExceptionDomainsshould just contain a map where each key is a domain. In your configuration, it contains a key-value pair that is not a domain. This makes the configuration malformed so we are unable to parse it.Can you somehow remove that and try again?
vamsi452 commentedon Sep 18, 2020
@mehmetf
It worked, I don't exactly remember in what situation I added that "NSExceptionAllowsInsecureHTTPLoads", but everything seems to be working fine now.
Thanks a ton!
vamsi452 commentedon Sep 18, 2020
@mehmetf
Can you suggest me how to include flutter module in the existing ios native project APK?
I have done the setup for integrating flutter module in existing iOS app.
I'm working on how to make this flutter module a park of APK which we archive to upload to app store.
mehmetf commentedon Sep 18, 2020
Glad to see it working 👍
(I have no idea about the modules)
github-actions commentedon Aug 12, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.