Compiling XIBs with CMake without Xcode

I’ve been enjoying using the JetBrains IDE CLion to do some refactoring and improvements to the Auctions code base. However, when I tried to build the Mac app bundle with it, the app failed to launch:

2022-07-30 19:54:15.117 Auctions[80371:16543044] Unable to load nib file: Auctions, exiting

The XIB files were definitely part of the CMake project. I later learned that CMake does not automatically add XIB compilation targets to a project. It relies on the Xcode generator to do that.

I found a long-archived documentation page from CMake on the Kitware GitLab that described a method to build NIB files from XIBs, and have modified it to make it simpler for Auctions.

You can see the change in the commit diff, but I’ll include the snippet here for posterity.

First, you define an array with the XIB file names with no suffix. For instance, I’ve done set(COCOA_UI_XIBS AXAccountsWindow AXSignInWindow Auctions) for the three XIB files presently in the codebase.

Then we have the loop to build them:

find_program(IBTOOL ibtool REQUIRED)
foreach(XIBFILE ${COCOA_UI_XIBS})
add_custom_command(TARGET Auctions POST_BUILD
COMMAND ${IBTOOL} --compile ${CMAKE_CURRENT_BINARY_DIR}/Auctions.app/Contents/Resources/${XIBFILE}.nib ${CMAKE_CURRENT_SOURCE_DIR}/${XIBFILE}.xib
COMMENT "Compiling NIB file ${XIBFILE}.nib")
endforeach()

Now it starts correctly and works properly when built from within CLion. This was surprisingly difficult to debug and fix, so I hope this post can help others avoid the hours of dead ends that I endured.

Until next time, Happy Hacking!

Wherefore art thou, USB-C hubs?

I’ve been looking for weeks at various stores around Tulsa, and online, for USB-C hubs. I already have a USB-C hub that has ports like Ethernet, HDMI, and USB-A. What I am looking for is a hub that has many USB-C ports.

As my Lightning cables age out, and I replace more equipment with devices that have only USB-C, more of my devices are connected this way.

My M1 MacBook Pro has two USB-C ports, but I have:

  • A USB-C SSD with my photo library.
  • My iPhone 12 with a Lightning to USB-C cable (all of my Lightning to USB-As are finally worn out).
  • My iPad mini which is USB-C to USB-C.
  • The aforementioned hub for connecting an external display.
  • Sometimes an optical drive, which yes, also uses USB-C.
  • The charging cable, because all of these devices pull a lot of power.

So, as a ballpark estimate, I need about six USB-C ports here. I really do not want to have to use a bunch of C-to-A adaptors, especially since some of my devices seem to slow down when using them. Has anyone seen anything like that out there? I drastically prefer to shop local, but at this point I would even consider buying from Amazon.

Or to put it in the words of one of my favourite bloggers: Dear lazyweb, where can I buy USB-C hubs?