Skip to content

What should be the domainNetworkPolicy while using flutter in existing iOS App? #65580

Closed

Description

@vamsi452

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

  1. Add App transport security to iOS Native app in info.plist

  2. Set NSAllowsArbitraryLoads to YES

  3. 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

  1. changed the title [-]What should be the domainNetworkPolicy while using flutter in existing iOS App.[/-] [+]What should be the domainNetworkPolicy while using flutter in existing iOS App?[/+] on Sep 11, 2020
  2. TahaTesser commented on Sep 11, 2020

    @TahaTesser
    Contributor

    Hi @vamsi452
    Can you please provide a complete reproducible minimal code sample in a repository including a sample flutter module
    Thank you

  3. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 11, 2020
  4. mehmetf commented on Sep 11, 2020

    @mehmetf
    Contributor

    The problem (probably) is that you are using YES instead of true. XML format does not understand "YES".

    You would do something like this:

        <key>NSAppTransportSecurity</key>
        <dict>
          <key>NSAllowsArbitraryLoads</key>
          <true/>
          <key>NSExceptionDomains</key>
          <dict>
            <key>my.domain</key>
            <dict>
              <key>NSExceptionAllowsInsecureHTTPLoads</key>
              <true/>
            </dict>
            <key>my.other.domain</key>
            <dict>
              <key>NSExceptionAllowsInsecureHTTPLoads</key>
              <true/>
              <key>NSIncludesSubdomains</key>
              <true/>
            </dict>
          </dict>
        </dict>
  5. vamsi452 commented on Sep 11, 2020

    @vamsi452
    Author

    @mehmetf Its shows "YES" in info.plist but in xml it's "true"
    Screen Shot 2020-09-11 at 2 43 55 PM
    Screen Shot 2020-09-11 at 2 44 16 PM

  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 11, 2020
  7. mehmetf commented on Sep 11, 2020

    @mehmetf
    Contributor

    Please paste your full info.plist XML here and also let me know which version of iOS you are trying against. Thanks!

  8. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 11, 2020
  9. self-assigned this
    on Sep 11, 2020
  10. vamsi452 commented on Sep 17, 2020

    @vamsi452
    Author

    @mehmetf

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>CFBundleDevelopmentRegion</key>
    	<string>en_US</string>
    	<key>CFBundleDisplayName</key>
    	<string>$(PRODUCT_NAME)</string>
    	<key>CFBundleExecutable</key>
    	<string>$(EXECUTABLE_NAME)</string>
    	<key>CFBundleIdentifier</key>
    	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    	<key>CFBundleInfoDictionaryVersion</key>
    	<string>6.0</string>
    	<key>CFBundleName</key>
    	<string>$(PRODUCT_NAME)</string>
    	<key>CFBundlePackageType</key>
    	<string>APPL</string>
    	<key>CFBundleShortVersionString</key>
    	<string>$(MARKETING_VERSION)</string>
    	<key>CFBundleSignature</key>
    	<string>????</string>
    	<key>CFBundleVersion</key>
    	<string>$(CURRENT_PROJECT_VERSION)</string>
    	<key>LSRequiresIPhoneOS</key>
    	<true/>
    	<key>NSFaceIDUsageDescription</key>
    	<string>Sign In using Face ID</string>
    	<key>UIAppFonts</key>
    	<array>
    		<string>Roboto-Regular.ttf</string>
    		<string>Roboto-Thin.ttf</string>
    		<string>fa-solid-900.ttf</string>
    		<string>fa-regular-400.ttf</string>
    		<string>fa-light-300.ttf</string>
    		<string>fa-duotone-900.ttf</string>
    		<string>Segment7Standard.otf</string>
    	</array>
    	<key>UIBackgroundModes</key>
    	<array/>
    	<key>UILaunchStoryboardName</key>
    	<string>LaunchScreen</string>
    	<key>UIMainStoryboardFile</key>
    	<string>Signin_iPhone</string>
    	<key>UIMainStoryboardFile~ipad</key>
    	<string>Signin_iPad</string>
    	<key>UIRequiredDeviceCapabilities</key>
    	<array>
    		<string>armv7</string>
    	</array>
    	<key>UIStatusBarStyle</key>
    	<string>UIStatusBarStyleDefault</string>
    	<key>UISupportedInterfaceOrientations</key>
    	<array>
    		<string>UIInterfaceOrientationPortrait</string>
    		<string>UIInterfaceOrientationPortraitUpsideDown</string>
    		<string>UIInterfaceOrientationLandscapeLeft</string>
    		<string>UIInterfaceOrientationLandscapeRight</string>
    	</array>
    	<key>UISupportedInterfaceOrientations~ipad</key>
    	<array>
    		<string>UIInterfaceOrientationPortrait</string>
    		<string>UIInterfaceOrientationPortraitUpsideDown</string>
    		<string>UIInterfaceOrientationLandscapeLeft</string>
    		<string>UIInterfaceOrientationLandscapeRight</string>
    	</array>
    	<key>UIViewControllerBasedStatusBarAppearance</key>
    	<false/>
    	<key>NSAppTransportSecurity</key>
    	<dict>
    		<key>NSAllowsArbitraryLoads</key>
    		<true/>
    		<key>NSExceptionDomains</key>
    		<dict>
    			<key>NSTemporaryExceptionAllowInsecureHTTPLoads</key>
    			<true/>
    			<key>www.cloudflare.com</key>
    			<dict>
    				<key>NSExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    				<key>NSIncludesSubdomains</key>
    				<true/>
    				<key>NSTemporaryExceptionMinimumTLSVersion</key>
    				<string>TLSv1.1</string>
    				<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    			</dict>
    			<key>www.jquery.com</key>
    			<dict>
    				<key>NSExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    				<key>NSIncludesSubdomains</key>
    				<true/>
    				<key>NSTemporaryExceptionMinimumTLSVersion</key>
    				<string>TLSv1.1</string>
    				<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    			</dict>
    			<key>www.mathjax.org</key>
    			<dict>
    				<key>NSExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    				<key>NSIncludesSubdomains</key>
    				<true/>
    				<key>NSTemporaryExceptionMinimumTLSVersion</key>
    				<string>TLSv1.1</string>
    				<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    			</dict>
    			<key>www.uworld.com</key>
    			<dict>
    				<key>NSExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    				<key>NSIncludesSubdomains</key>
    				<true/>
    				<key>NSTemporaryExceptionMinimumTLSVersion</key>
    				<string>TLSv1.1</string>
    				<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    			</dict>
    		</dict>
    	</dict>
    </dict>
    </plist>
    

    iOS version 13

  11. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 17, 2020
  12. mehmetf commented on Sep 17, 2020

    @mehmetf
    Contributor

    I marked the problematic entry:

    ...
    	<key>NSAppTransportSecurity</key>
    	<dict>
    		<key>NSAllowsArbitraryLoads</key>
    		<true/>
    		<key>NSExceptionDomains</key>
    		<dict>
                              ///// PROBLEM ///////
    			<key>NSTemporaryExceptionAllowInsecureHTTPLoads</key>
    			<true/>
                              ///// PROBLEM ///////
    			<key>www.cloudflare.com</key>
    			<dict>
    				<key>NSExceptionAllowsInsecureHTTPLoads</key>
    				<true/>
    				<key>NSIncludesSubdomains</key>
    				<true/>
    ...
    

    According to Apple documentation NSExceptionDomains should 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?

  13. vamsi452 commented on Sep 18, 2020

    @vamsi452
    Author

    @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!

  14. vamsi452 commented on Sep 18, 2020

    @vamsi452
    Author

    @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.

  15. mehmetf commented on Sep 18, 2020

    @mehmetf
    Contributor

    Glad to see it working 👍

    (I have no idea about the modules)

  16. github-actions commented on Aug 12, 2021

    @github-actions

    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 -v and a minimal reproduction of the issue.

  17. locked as resolved and limited conversation to collaborators on Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in triagePresently being triaged by the triage team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions