zeromq-ios-py /

Filename Size Date modified Message
103 B
3.3 KB
2.3 KB
856 B

ZeroMQ between iOS and Python


This is a ZeroMQ example where an iOS app written in Objective-C talks to a server written in Python with gevent. It doesn't do anything very much: the Python server sends updates over a PUB/SUB socket, the iOS app listens to them and sends requests over a REQ/REP socket when a button is pressed. It has three purposes:

  • It was an excuse to play with ZeroMQ and gevent
  • It provides examples how to use ZeroMQ in iOS and with gevent
  • It contains an (at the moment) up to date script for building a fat iOS library for armv7 and i386


The system assumes the following platform which is a prerequisite for running it:

  • OS X 10.7.3
  • Xcode 4.3.2
  • iOS SDK 5.1
  • Python 2.7 (as shipped with OS X)
  • libevent 2.0.18 (I used the package from Homebrew)
  • pip 1.1
  • virtualenv

In addition to the bits listed above, the build system fetches the following during the build process:

That's a lot of external dependencies, but they should just automatically work (with one caveat, see the Build section below.) The infrastructure hosting them will sooner or later break, of course.

Because this is just a toy, I have made no effort to find out if it works on different versions of the tools. I also don't really expect that I'll be keeping it very up to date, so if you're running some newer versions of the above don't be surprised if things don't work anymore. If it breaks and you fix it, pull requests will be considered.

Running it


The script should set up the environment you need. It fetches the ZeroMQ sources and builds it for iOS, it fetches objc-zmq and creates the virtualenv sandbox with the required libraries for running the server.

I get an error when the script builds pyzmq-static. It seems to work anyway.

If you get an error at an earlier stage, a good point to start investigation is to make sure xcode-select points to the correct Xcode. The expected output in the most common configuration looks like this:

$ xcode-select -print-path

You can also inspect zeromq-2.2.0/build/build.log.


If the script finished successfully, you can run the server:

cd GeventServer
source gsenv/bin/activate

If you want to specify something other than *:5555 and *:5556 as the endpoints to bind, run with the flag --help to see command line options.


Open the ZeroMQTest/ZeroMQTest.xcodeproj in Xcode. You only need to care about the application delegate in the file ZTAppDelegate.m. If you run the app in the simulator and you didn't change the endpoints used by the server, you should be able to just run the application. If you changed the endpoints or are running on a device, you can adjust the constants kServerIP, kReqPort and kSubPort near the start of the file.