Important: Please read the Qt Code of Conduct -

QNetworkConfigurationManager onlineState && iOS 10.3.2 problems (OBJECTIVE_SOURCES)

  • Qt Champions 2016

    there are known problems to always get the correct online state from iOS
    my current workaround was this:
    see also and

    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

    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/ \
        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

    added include:

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

    changed class definition:

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

    added statusChanged method

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

    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 ?

  • Lifetime Qt Champion


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

    Hope it helps

  • Qt Champions 2016

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

  • Lifetime Qt Champion

    Great !

    Apple's developer site is working well for that.

  • Qt Champions 2016

    and then in the description the framework was mentioned

    edit: this is helpful to understand iOS Reachability:

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

  • Lifetime Qt Champion

    Great !

    You're welcome !

    Happy coding :)

Log in to reply