Installing Squish for Qt for iOS testing

Note: iPhone and iPad applications can only be tested on Apple hardware, either on the devices themselves or on simulators that run under macOS.

The Squish for Qt for iOS testing package is suitable for building the iOS application for testing. You still need to install a Squish package for actually recording, managing and running the tests, as instructed in Installing from Binary Packages.

To build your application instrumented for using with Squish on iOS, you have to unpack the package and build your application with Squish's wrapper included. To include it, modify your application's main.cpp and .pro as follows:

  1. Add
    #ifdef HAVE_SQUISH
    #  include <qtbuiltinhook.h>
    #endif

    to your includes in the file with your main function (typically main.cpp).

    In the same file add

    #ifdef HAVE_SQUISH
        Squish::allowAttaching(11233);
    #endif

    after the QApplication constructor but before you enter the event loop.

    So a typical main() function might look like:

    #include "mainwindow.h"
    #include <QApplication>
    #ifdef HAVE_SQUISH
    #  include <qtbuiltinhook.h>
    #endif
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    #ifdef HAVE_SQUISH
        Squish::allowAttaching(11233);
    #endif
        MainWindow w;
        w.show();
    
        return a.exec();
    }
  2. Add
    include(<path-to-squish>/qtbuiltinhook.pri)

    to your .pro file (replace <path-to-squish> with the full path to the location where you unpacked Squish for Qt on iOS).

  3. Now you can register an attachable application in Squish (with the IP address of the device and the port number 11233) and attach to it from a Squish running on the desktop. If you use a different port number in the Squish::allowAttaching() call, you need to register the app with a different port number. See also Attaching to a Running Application with the Built-in Hook for more details on attachable applications.

If you want to use Squish's Qt wrapper extensions, you have to set the SQUISH_WRAPPER_EXTENSIONS variable before you include the qtbuiltinhook.pri in your .pro file.

Examples:

  • If your application uses Qt Quick 1, you should add Squish's declarative extension like:
    SQUISH_WRAPPER_EXTENSIONS = squishdeclarative
    include(<path-to-squish>/qtbuiltinhook.pri)
  • If your application uses Qt Quick 2, you should add Squish's Qt Quick extension like:
    SQUISH_WRAPPER_EXTENSIONS = squishqtquick squishqtquicktypes
    include(<path-to-squish>/qtbuiltinhook.pri)