Using pyqtdeploy on MacOS to cross compile a PyQt app for iOS: part 1

This is part of a continuing series of blogs of my experience using pyqtdeploy.

You might want to start at the tutorial which I link at the bottom of the blog.  This blog really adds nothing except some discussion of why and how to get the required tools, and some context for pyqtdeploy.

Here, I have switched host development platform (now MacOS or OSX) and target (now iOS.)

I switched because I encountered difficulties porting to Android.  I decided to digress, in hopes that what I learn on a different target (iOS instead of Android) might teach me something.  Besides, MacOS has always been a highly regarded development platform, and many pyqtdeploy example screenshots seem to be from MacOS.  If you are using pyqtdeploy, then you probably want to port to all supported platforms, and you should choose the path of least resistance.  There is no use struggling with one platform (Android) especially if, like me, you are equally unfamiliar with all the mobile platforms or if one platform (iOS) might be better supported, more stable, etc.

The process has three parts:

  1. set up tools
  2. compile libraries statically
  3. compile your app

This is part one, setting up tools.

The goal is to get a Qt example app running on iOS.  Getting an example to run is not required to use pyqtdeploy.  It is just a milestone, that insures you have a proper build environment.  Hello world.

This blog assumes you want point-and-click.  You can use Xcode and Qt Creator tools from the command line, without using their GUI’s.  During the second part, you WILL be using the command line to build static libraries.  But you probably would not be reading this if you already know the commands.  And learning the GUI versions of the tools may guide you.

Required Tools

You need:

  • Xcode
  • Qt Creator

Pyqtdeploy uses qmake, which is packaged with Qt Creator.  (Again, later, you might be able to forego Qt Creator, and use the command line.)

Qt Creator and qmake invoke tools (compilers etc.) that are packaged with Xcode.

Which versions of tools

I used:

  • OSX 10.9.4 Mavericks
  • Qt5.3.0
  • Xcode 5.1.1
  • Qt Creator 3.1.1
I briefly tried to use OSX 10.7.5, Xcode 4.6.3, and Qt 5.2.  But it didn’t work and I decided there was no point not to use the latest tools. 
Everyone else is moving forward.  Qt on mobile platforms is bleeding edge.  In my experience, Qt 5.3 is much better than older versions.  Xcode 4.6.3 will actually be two major versions behind, now that Xcode 6 is imminently released.

Downloading the tools

The links are easy to find.

My advice is to download the entire Xcode (rather than say just the command line tools.)

My advice is to use the “online installer” to install Qt and its tools.  It is a small, smart installer that downloads and installs other components.  It will know your platform and offer you choices to download the proper kits for iOS.

Installing additional Qt components

I think I had installed Qt without using the online installer.  It did not include kits for iOS.  So I needed to install additional Qt components.

About Qt Creator kits

The Qt Creator documentation about Adding Kits tells you how to add kits in Qt Creator.  Restating….

Kits are groups of settings for building apps.  You usually don’t need to create or customize a kit, only use a kit that is distributed with Qt.

When you open a project, including the Qt examples, you are given the chance to configure the kit for the project.  But you must have previously downloaded the kit (which Qt Creator then detects.)

In this example, I wanted the kit for the ‘iOS Simulator.’

Downloading additional kits

You use the Qt ‘Maintenance Tool’  and choose ‘Package Manager’.  If you previously used the Qt ‘online installer’, then when you start the Maintenance Tool it remembers the repository used previously, and gives you choices of additional packages.

Otherwise, you might get an error ‘requires a valid repository’.  This is discussed in the Qt Forums.  To fix this:

and so forth.  After you do this, the Maintenance Tool should offer you the choice of downloading additional kits.

Building a Qt example

Follow this good, short video tutorial Qt5 Tutorial: Pushing Example App to iOS Simulator”.  The analog clock example (without menus) worked for me.

What’s next

The next part will build static libraries for Python, PyQt, and SIP, for the iOS platform.



One thought on “Using pyqtdeploy on MacOS to cross compile a PyQt app for iOS: part 1

  1. Pingback: Deploying PyQt Python Qt apps cross platform using pyqtdeploy | plashless

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s