Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QNetworkConfigurationManager onlineState && iOS 10.3.2 problems (OBJECTIVE_SOURCES)
Qt 6.11 is out! See what's new in the release blog

QNetworkConfigurationManager onlineState && iOS 10.3.2 problems (OBJECTIVE_SOURCES)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 2 Posters 2.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #1

    there are known problems to always get the correct online state from iOS
    my current workaround was this:
    see https://bugreports.qt.io/browse/QTBUG-49751?focusedCommentId=354170&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-354170
    see also https://bugreports.qt.io/browse/QTBUG-56151 and https://bugreports.qt.io/browse/QTBUG-58946

    my workaround was working up to iOS 10.2.x
    just updated

    • OSX from 10.11.6 to macOS 10.12.5
    • Xcode from 8.2 to 8.3.3
    • my iOS test devices from 10.2.1 to 10.3.2
    • all projects from Qt 5.8 to 5.9

    then I recognized that my workaround didn't work as before and always reports iOS device as online - even while airplane mode is set
    noticed that now there are 2 network adapters always active:

    • utun0 (as before)
    • en2 (new)

    en2 normaly means an ethernet adapter. curious that iOS 10.3.2 reports en2 as active on my iPhone 6 ;-)

    I changed my workaround and now if only utun0 and/or en2 are reported as active from QNCM I detect this as offline

    there should be a better and more robust way
    fortunately QTBUG-56151 contains a workaround you can download
    https://bugreports.qt.io/secure/attachment/59615/NetworkConfTestWA.tar.gz

    from this download I wanted to test the 2nd way using Reachability by adding some Objective sources.
    But I cannot make this run

    This is the very first time I'm trying to add OBJECTIVE_SOURCES and I never did any iOS native development.
    probably I did something wrong.
    Here are my steps to integrate this into my QTQuickControls2 APP:

    I copied the objective sources into ios/src

    changed .pro:

    ios {
        OBJECTIVE_SOURCES += ios/src/Reachability.mm \
        ios/src/ReachabilityListener.mm
    
        QMAKE_INFO_PLIST = ios/Info.plist
        ios_icon.files = $$files($$PWD/ios/Icon*.png)
        QMAKE_BUNDLE_DATA += ios_icon
        ios_artwork.files = $$files($$PWD/ios/iTunesArtwork*.png)
        QMAKE_BUNDLE_DATA += ios_artwork
        app_launch_screen.files = $$files($$PWD/ios/MyLaunchScreen.xib)
        QMAKE_BUNDLE_DATA += app_launch_screen
    
        QMAKE_IOS_DEPLOYMENT_TARGET = 8.2
    
        include(ios_signature.pri)
    
        QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2
    }
    

    added include:

    #if defined (Q_OS_IOS)
    #include "ios/src/ReachabilityListener.h"
    #endif
    

    changed class definition:

    class DataServer : public QObject
    #if defined (Q_OS_IOS)
        , private utility::ReachabilityDelegate
    #endif
    

    added statusChanged method

    #if defined (Q_OS_IOS)
    void DataServer::statusChanged(utility::NetworkStatus newStatus)
    {
        if (newStatus == utility::NotReachable) {
            // offline
        } else {
            // online
        }
    }
    #endif
    

    but getting error from build:

    Undefined symbols for architecture arm64:
      "_SCNetworkReachabilityGetFlags", referenced from:
          -[Reachability connectionRequired] in Reachability.o
          -[Reachability currentReachabilityStatus] in Reachability.o
      "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
          -[Reachability startNotifier] in Reachability.o
      "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
          -[Reachability stopNotifier] in Reachability.o
      "_SCNetworkReachabilitySetCallback", referenced from:
          -[Reachability startNotifier] in Reachability.o
      "_SCNetworkReachabilityCreateWithAddress", referenced from:
          +[Reachability reachabilityWithAddress:] in Reachability.o
      "_SCNetworkReachabilityCreateWithName", referenced from:
          +[Reachability reachabilityWithHostName:] in Reachability.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1
    

    any idea what I did wrong ?

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From a quick search, you may need to add LIBS += -framework SystemConfiguration to your .pro file.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      ekkescornerE 1 Reply Last reply
      4
      • SGaistS SGaist

        Hi,

        From a quick search, you may need to add LIBS += -framework SystemConfiguration to your .pro file.

        Hope it helps

        ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #3

        @SGaist cool - now it compiles :)
        Where do I find out which framework is needed ?

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          Great !

          Apple's developer site is working well for that.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          ekkescornerE 1 Reply Last reply
          1
          • SGaistS SGaist

            Great !

            Apple's developer site is working well for that.

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by ekkescorner
            #5

            @SGaist
            found https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html
            and then in the description the framework was mentioned

            edit: this is helpful to understand iOS Reachability: https://symbiotics.co.za/checking-network-status-in-ios-apps/

            thx again. without your help I never would have found this ;-)

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Great !

              You're welcome !

              Happy coding :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved