Skip to content

network_info_plus: 'net/route.h' file not found when building for iOS emulator #431

@jamiemm

Description

@jamiemm

System info

Issue occurs on: iOS
Plugin name: Network Info Plus
Plugin version: 1.1.0
Flutter doctor output:

[✓] Flutter (Channel stable, 2.2.1, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.59.0)
[✓] Connected device (4 available)

Steps to Reproduce

  1. flutter pub add network_info_plus
  2. import 'package:network_info_plus/network_info_plus.dart'; in one of the project .dart files
  3. attempt to build and run the app on an iOS emulator (iPhone 11 iOS 14.2)
  4. The build fails with the following error:
/Users/jamie/.pub-cache/hosted/pub.dartlang.org/network_info_plus-1.1.0/ios/Classes/getgateway.c:18:14: fatal error: 'net/route.h' file not found
        #include <net/route.h>
  1. If I change the following lines in ios/Classes/getgateway.c:
#if TARGET_IPHONE_SIMULATOR
    #include <net/route.h>
    #define TypeEN    "en1"
#else
    #include "route.h"
    #define TypeEN    "en0"
#endif

To the following:

    #include "route.h"
    #define TypeEN    "en0"

The build is successful, and the package works correctly.

Logs

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/network_info_plus-generated-files.hmap

-I/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/
                   Debug-iphonesimulator/network_info_plus.build/network_info_plus-own-target-headers.hmap

-I/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/
                   Debug-iphonesimulator/network_info_plus.build/network_info_plus-all-non-framework-target-headers.hmap -ivfsoverlay

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/all-product-headers.yaml -iquote

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/network_info_plus-project-headers.hmap
                   -I/Users/jamie/Projects/cha-flutter-demo-app/build/ios/Debug-iphonesimulator/network_info_plus/include

-I/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/
                   Debug-iphonesimulator/network_info_plus.build/DerivedSources-normal/x86_64

-I/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/
                   Debug-iphonesimulator/network_info_plus.build/DerivedSources/x86_64

-I/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/
                   Debug-iphonesimulator/network_info_plus.build/DerivedSources
                   -F/Users/jamie/Projects/cha-flutter-demo-app/build/ios/Debug-iphonesimulator/network_info_plus
                   -F/Users/jamie/Projects/flutter/bin/cache/artifacts/engine/ios/Flutter.xcframework/ios-x86_64-simulator -include
                   /Users/jamie/Projects/cha-flutter-demo-app/ios/Pods/Target\ Support\
Files/network_info_plus/network_info_plus-prefix.pch -MMD
                   -MT dependencies -MF

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/Objects-normal/x86_64/getgateway.d --serialize-diagnostics

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/Objects-normal/x86_64/getgateway.dia -c
                   /Users/jamie/.pub-cache/hosted/pub.dartlang.org/network_info_plus-1.1.0/ios/Classes/getgateway.c -o

/Users/jamie/Library/Developer/Xcode/DerivedData/Runner-eyfbnzqbhwnsewftqpwgcggqcxky/Build/Intermediates.noindex/Pods.build/De
                   bug-iphonesimulator/network_info_plus.build/Objects-normal/x86_64/getgateway.o
               /Users/jamie/.pub-cache/hosted/pub.dartlang.org/network_info_plus-1.1.0/ios/Classes/getgateway.c:18:14: fatal error:
'net/route.h'
               file not found
                   #include <net/route.h>
                            ^~~~~~~~~~~~~
               1 error generated.

There are no errors from flutter analyze

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.2.3 20D91 darwin-x64, locale en-GB)
    • Flutter version 2.2.1 at /Users/jamie/Projects/flutter
    • Framework revision 02c026b03c (3 months ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/jamie/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)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.10.2

[✓] 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 (4 available)
    • Android SDK built for x86 (mobile) • emulator-5554                        • android-x86    • Android 8.1.0 (API 27) (emulator)
    • Jamie’s iPhone (mobile)            • 00008030-000405620242402E            • ios            • iOS 14.3
    • iPhone 11 (mobile)                 • A233A171-EC08-4389-9032-51BC35D2083B • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)
    • Chrome (web)                       • chrome                               • web-javascript • Google Chrome 92.0.4515.159

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions