Deploying PyQt5 to iPhone simulator

pyqtdeploy is a fantastic build tool for PyQt apps. It crams all the code and libs needed to run the app into a single binary, securing the source and simplifying compatibility and deployment. Thank you, Phil.

Unsurprisingly, pyqtdeploy requires that you build static libs of python, sip, qt, pyqt, and qscintilla, and it helps you build them by configuring the source for each tool for you. This works quiet well, except as of pyqtdeploy-1.3.1 it doesn’t configure the necessary i386 and x86_64 platforms into the iOS libs build. Here’s how I got it to work.

So you have to create a separate SYSROOT for the ios-simulator. Following the pqytdeploy instructions to building static libs here, stop just after the pqytdeploycli step for each lib and then follow these instructions before running “make” and “make install” and you should be good to go. FWIW, all of this is current on macOS Sierra, iOS-10.2, pyqtdeploy-1.3.1, Qt-5.7.1, python-3.5.2, sip-4.19, and pyqt5-5.7.1.

After a lot of hacking, I figured out that you can make an iPhone simulator sys root by configuring using the ios-64 target in pyqtdeploycli, and then before the “make” step in each project, just go and edit all the qmake-generated Makefiles to change the following line:

####### Custom Variables 
EXPORT_VALID_ARCHS = armv7 arm64


####### Custom Variables
EXPORT_VALID_ARCHS = i386 x86_64

Then also change the SDK path from iPhoneOS to iPhoneSimulator in CFLAGS and CXXFLAGS at the top of each Makefile. So change both instances of:




Take notice that there is a separate Makefile for each PyQt5 package. The easiest way to search and replace in all of them is to use Xcode, create a workspace in the PyQt src root dir, then drag all of the dir contents into the workspace pane on the left of the Xcode window selecting ‘make references to folders’ (or something similar), and then choose search and replace in workspace from the Edit menu.

After that you should be all set to make and make install in each source package as described in the pyqtdeploy documentation:

I’ve been out of touch with PyQt5 for a while, but man it’s great to be able to deploy it to iOS! Thanks Phil!

Good luck!

By | 2017-02-05T06:00:17+00:00 February 5th, 2017|Programming|0 Comments

Leave A Comment

97 − 88 =