Xcode workspace VS project built product issue

Hi everyone!

I currently moved my macOS/iOS app (mainly C++ / Objective-C++) to CMake. So far, so good!
I can properly generate each Xcode project, one targeting the macOS platform, and the other one for iOS.

Before moving to CMake, I would usually create an Xcode workspace that would include both projects (iOS+macOS), for ease of use and to be able to build and run the app without switching projects.

For that matter, I created a very simple Ruby script using a tool called “Xcodeproj” (from the CocoaPod team), to create a new Xcode workspace from the two Xcode projects created by CMake.

However, it seems Xcode workspace overrides the intermediate built product location, which makes all my third-party libraries being created in a custom Xcode folder (derived data). Because it overrides the product output directories that CMake initially set during the autogeneration of the projects, I am facing a link error since the static libs are not found.

Anybody faced a similar issue? Is there a way to fix this, and/or can CMake output a single mixed iOS/macOS Xcode project, as an alternative?

Thanks in advance!
Best.

I don’t know that such a use case has been considered before. The Ninja generator does have support for being embedded into other ninja builds, but we’d likely need to add it for Xcode, if it is possible.

Cc: @gjasny @brad.king

1 Like

Hi @ben.boeckel and thanks for your reply.

I think that would be an excellent addition to the Xcode generator, especially with Apple Silicon / Catalyst and mixed iOS/macOS apps becoming the standard.

Cheers

If you could file an issue with details about how this could be done and problems with what is being done now, that would be very helpful.

1 Like

Hi @ben.boeckel! Just before filling up the issue – are we looking to get mixed iOS/macOS targets implemented in a generated Xcode project or shall I describe the xcworkspace issue I’m having?

I think the latter isn’t really CMake related, as it seems it’s Xcode workspace behavior to supersede all built product locations when building a target! For that matter, maybe CMake could offer an option for the Xcode project generator to use the current derived data location libraries, binaries, etc., but it seems somewhat backward.

Thank you in advance!

I don’t think mixed targets in a single build will be supported, but getting CMake to be able to generate Xcode projects that can be included in an “owning” Xcode workspace would be the way to go.

1 Like

Hey @ben.boeckel, thanks for your prompt reply, I’ll fill the issue right now.

After performing an initial search on the issue tracker I found this ticket:

https://gitlab.kitware.com/cmake/cmake/-/issues/20160

I try to simply copy the provided WorkspaceSettings.xcsettings within my Xcode workspace and it did in fact fix the issue.

I think we could follow-up on this particular ticket instead of creating a new one?

What do you think @ben.boeckel ?

Thanks!

Reusing an (appropriate) issue is always better than splitting attention :slight_smile: .

1 Like