Apple supported way to create xcodeproject without using XCode IDE or with minimal use of XCode IDE

We need help to structure our project to start using apple standard way to create Xcode project.

let me first express how currently we are creating Xcode project.

As of today, we are using CMake to generate our xcode project which we can open in XCODE IDE and build/debug/run/etc. XCode IDE can open those project but we notice that some build setting does not seem to have correct value while looking into XCODE IDE but it somehow builds. There are some other issues also. Along with those issues, we also could not share this xcodeproject generated via CMake to AppleDTS support team as Apple does not support project created via some third party tool (like CMake or others).

Let me also express why we decided to use CMake at first place to generate Xcode projects. Our project is layered architecture project where in upper layers uses lower layer artifacts. Each layer has its own set of build targets . And each layer can have both C++ and Swift files. And each layer would have most of the compiler flag common, but we could also have compiler flag specific to each layer also. To achieve all these, we have developed our own tool, which basically creates CMakeLists.txt (for project model- all targets, dependency, etc) and CMakePresets.json (for all compiler and linker flags). Now this tool scans through repos/source folders on each layer and then creates these files (CMakeLists.txt and CMakePresets.json). This tool uses inputs to decide compiler/linker/other properties from one centralized location. Which means every developer would use these same input files and thus they all can have same compiler/linker/other properties set consistent. This makes generated build system consistent on all developer machine and it allows confidence of saying if build works on one developer's machine would also work on other developer’s machine and if build does NOT work on one developer's machine, it would NOT work on other developer’s machine also. So, it’s consistent. That was the main reason to use CMake to generate xcode project. So, our internal tools creates meta data for CMake (which is CMakeLists and CMakePresets) and then CMake generates Xcode build system using XCode generator.

Now we want to move to xcode native way to create projects but at the same time we also want this consistency that each of my developer would use exact same compiler/linker/other properties. If we ask developer to use XCode IDE to create xcode project, we cannot guarantee that they all will use same compiler/linker/etc flags and thus we would end up having inconsistent behaviour on different developer machines. We need your help to figure out how we can achive this ? We read some ways that we can create some template project and then we can create some .xcconfig files and use them to set target properties but honestly, we are able to stich them together. So please help us directionally on this , how should we proceed ?

Basically we need to know how can we have all my developer use same xcodeproject.

I was also thinking how would I be setting my CI for apple builds if I have to use XCode IDE to create xcode project and since CI environments are non interactive and it can happen n number of times in day (if I have setup to run sanity for all Pull Requests).

Any help/direction on this is highly appreciated.

Thanks @B347 . I went through this and yes it would solve one of the problem, that now I can maintain these .xcconfig files as one source for all developers . And a developer who creates a project on xcode IDE can use these configuration . But can I create a xcode project without using xcode IDE?

Basically I need to fulfil in nightly build.

  1. Get latest source code. -- This can be done easily via pulling all latest code from server to this machine.

** 2) Create a xcode project without using xcode IDE as its non-interactive env -- This I dont know how to do it :( OR even its possible to do so . **

  1. build different projects. -- This can be done by using xcodebuild on command line.

I recommend you just create the project in Xcode itself and stop using CMake altogether.

I have a similar project I've been working on for a while. Getting rid of 3rd party build tools solves so many problems.

One trick that I used was to try Xcode cloud. Your project has to be absolutely perfect for Xcode cloud to work. So once I could get the build running there, I could run it anywhere. And then I stopped using Xcode cloud because it's so, so slow.

ok.
one possible way to go is like that: [https://luxmentis.org/blog/ios-and-mac-apps-in-zed/)

or [https://github.com/xtool-org/xtool)

Thanks for the post and the ideas developer provided, really interesting.

May I also provide the idea of cloning an existing package and use Swift Package Manager to do this task?

Instead of generating an .xcodeproj, you define your layered architecture, targets, C++/Swift files, and compiler flags in a Package.swift file. You can write a Package.swift file in any text editor. Xcode opens Package.swift files natively. On your non-interactive CI server, you just run `xcodebuild -build -scheme MyScheme -destination

Just an idea that worked for me many times.

Thanks

Albert  WWDR

Apple supported way to create xcodeproject without using XCode IDE or with minimal use of XCode IDE
 
 
Q