Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XIB compiling for non-Xcode projects #1499

Merged
merged 2 commits into from
Nov 14, 2023
Merged

Conversation

dpogue
Copy link
Member

@dpogue dpogue commented Oct 4, 2023

XIB (XML Interface Builder) files describe windows and user interface elements and their properties on macOS (and other Apple platforms), and are authored using Xcode's Interface Builder drag-and-drop tool. As part of compiling an app, those XIB files need to be compiled from XML to a proprietary NIB format and included in the .app bundle as resources.

Xcode projects will handle this automatically when there's an XIB file in the list of files to process, but if you generate Makefiles with CMake then these files don't get compiled properly, and the source XML files get bundled up as resources instead. This leads to errors when launching the application because it can't find the compiled interface definitions.

The Xcode compiler tools provide an ibtool command-line tool that can compile XIB files to NIB files, but we need to teach CMake to invoke it. That is what this PR accomplishes.

Aside: We'll eventually have similar issues with Metal shaders, which also need their own compilation process involving special tools, but we can deal with that when we get there.

@colincornaby
Copy link
Contributor

Glad someone is looking at this. Thanks!

cmake/XcodeHelpers.cmake Outdated Show resolved Hide resolved
if(APPLE)
plasma_executable(plClient CLIENT INSTALL_PDB SOURCES ${plClient_SOURCES} ${plClient_HEADERS} ${RESOURCES})
target_xib_resources(plClient SOURCES ${plClient_IBSOURCES})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you could process the XIBs in the plasma_executable command, which would be more ideal in terms of limiting the platform-specific branches in consuming code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean adding another keyword like plasma_exectuable(plClient CLIENT INSTALL_PDB SOURCES ... IBSOURCES ...)? Or trying to parse out .xib files from the list of provided sources?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking more of the latter.

cmake/XcodeHelpers.cmake Outdated Show resolved Hide resolved
@dpogue
Copy link
Member Author

dpogue commented Nov 8, 2023

FYI I took a stab at doing this as part of plasma_executable on another branch to try it, and it sorta works except now it's bundling both the xib and the nib files into the Resources folder, and we only want the nib compiled output.

I'm wondering if I can somehow set the MACOSX_PACKAGE_LOCATION source property on the xibs in a way that excludes them as resources even when they are listed as RESOURCES in the target properties...

@dpogue
Copy link
Member Author

dpogue commented Nov 14, 2023

This should be ready for re-review now. It appears to work both with Xcode (in CI) and with make (locally), as far as the XIB files are concerned.

Copy link
Member

@Hoikas Hoikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. @dpogue and @colincornaby - what order would we like to see these merged? This first, then Metal or the other way around? Either way, someone is going to have to rebase, I think.

@colincornaby
Copy link
Contributor

It looks like this avoids taking over for the Xcode generator. Has this been tested with the Xcode generator? If it's non disruptive to the Xcode generator, I'd feel better about having this merged in first.

@dpogue
Copy link
Member Author

dpogue commented Nov 14, 2023

It looks like this avoids taking over for the Xcode generator. Has this been tested with the Xcode generator?

In the Xcode case, this lets Xcode handle the XIB files the way it normally would. CI shows the nibs being put in the Resources folder as expected.

@colincornaby
Copy link
Contributor

I'd be fine with this being merged first then. I feel like there might still be some review left on Metal and I think getting this merged in wouldn't be too painful.

@Hoikas Hoikas merged commit b2a000a into H-uru:master Nov 14, 2023
17 checks passed
@dpogue dpogue deleted the niblets branch November 22, 2023 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants