Shipping GTK+ apps for macOS with Xcode

My setup:

  • macOS Mojave
  • Xcode 10.3

I'm looking into the possibility of shipping apps on macOS using GTK+.

Unfortunately, the whole process seems daunting to me according to GTK+'s macOS build/bundle/integration guide:

This guide showed various pitfalls of the gigantic script and its environment tweaks, which could mess up the entire OS. The suggested approach of opening a new user account seems not very practical, either.

This all-in-one script approach, excluding any talks about Xcode, is quite scary as it makes me wonder how fast it could keep up with Apple's movement, as Xcode with its toolchain upgrades every few months. Xcode is the only environment that I feel comfortable when it comes to project organization and app bundling.

For one, would it be possible to use Apple's more mature dynamic linking system, i.e., Frameworks, instead of the .dylib approach? I couldn't find any resources or discussions about linking GTK+ through Frameworks, or even using Xcode build system for the job.

Any tips would be appreciated.


My first attempt of bootstrapping the macOS build system for GTK+ just failed at a cmake dependency step, and the script does not even offer an "abort" option. I had to Ctrl-C it: Another negative experience.


Progress: I managed to create a Hello-World command-line program in Xcode 10.3 and make it run. Basically I steered clear of the jhbuild route that GNOME recommends.

Things I did:

  1. Install gtk+3 and its Python binding from homebrew: brew install pygobject3 gtk+3
  2. In Xcode, create a C++ command-line project.
  3. Find out header search paths: pkg-config --cflags gtk+-3.0, and add the result to Other C Flags of Xcode target's Build Settings.
  4. Find out about libs: pkg-config --libs gtk+-3.0, and add the result to Other Linker Flags.
  5. Build and Run.

This is so much easier than the GNOME recommendation. Mind you that its latest edits were done in 2019, so they likely still recommend it.

I'm going to try bundling today.