Native XCode project generator plugin
Is your feature request related to a problem? Please describe.
The current version of xmake (2.8.8) does not support XCode project generation directly, it generates XCode project files by translating xmake scripts to CMake scripts, then uses CMake genrator to generate XCode project files. In practice, I found at least two problems caused by this translation process:
- All custom building functions used in xmake scripts (like
before_build,after_build,before_install,after_install, etc) will not be called when performing building actions in XCode, since they are lua functions and cannot be processed by CMake building system. - For some reasons, if we need to change the building options (options added by
target:add_options) in xmake, we don't get these option changes applied in XCode projects until we delete all CMake/XCode files and regenerate them from scrach (simply regenerating XCode project files byxmake project -k xcodewon't take effect if we don't delete all existing CMake and XCode files).
These problems can be solved by implementing a native XCode project generator, just like we have already done for Visual Studio (vsxmake2019). As the documentation says:
After we have time, we will re-implement each more complete xcode output plugin by ourselves, and welcome everyone to contribute.
I wonder if we currently have any plan on implementing a native XCode project generator, and if not, this issue can be used to track this feature if somebody has time to development such generator later.
Describe the solution you'd like
We want a native XCode project generator that generates XCode project files directly from xmake.lua project scripts. When performing building, installing and cleaning actions in XCode, this project file will call xmake to perform real building tasks, so that all custom building functions can be used, and changes to xmake options will take effect immediately in XCode projects.
Describe alternatives you've considered
No response
Additional context
No response
Hi, just to notify that I'm starting working on this issue. The following features will be included in the first release of this new generator (Milestone 1):
- Generate Xcode projects from xmake.lua directly, without the need of CMake installation.
- Map files, builds rules and targets to corresponding Xcode concepts (files, groups, configurations, targets, etc).
- Triggering
buildin Xcode invokes xmake to build targets by using custom building phases of Xcode. xmake callbacks likebefore_build,after_build,before_install,after_install, etc will be called as expected. - Redirect xmake build directory to Xcode
BUILD_DIR, so that invokingClean build folderin Xcode will remove all xmake intermediate and output files as expected. - Running & debugging in Xcode is supported, with additional graphics debugging support if the application uses Metal.
The following known features may be deferred to Milestone 2 or later:
- Currently only MacOS targets are supported. iOS, watchOS, tvOS, visionOS targets are not tested and may require additional refinement of the generator. I plan to test and support iOS targets on Milestone 2, other platforms may require community contributions to be supported (since I don't have corresponding test devices).
- Custom options specified in
xmake.luais currently ignored in Xcodebuildactions. I plan to support this in Milestone 2. - Currently only Xcode
buildandrunactions are supported.test,profileanddeployactions are currently not supported, and may require community contributions to support.
The first release of the new Xcode project generator plugin will be published in the mid of 2025. Stay tuned while I'm working on this.
Initial version of new native Xcode generator has been uploaded to https://github.com/JX-Master/xmake/tree/xcode-generator
Use xmake project -k xcode2 (temporary generator name) to generate new Xcode project file.
Thanks, but I don’t have much time recently, you can submit a PR first, and I will review it when I have time later.
Initial version of new native Xcode generator has been uploaded to https://github.com/JX-Master/xmake/tree/xcode-generator
Use
xmake project -k xcode2(temporary generator name) to generate new Xcode project file.
Can you open a pr?
Initial version of new native Xcode generator has been uploaded to https://github.com/JX-Master/xmake/tree/xcode-generator Use
xmake project -k xcode2(temporary generator name) to generate new Xcode project file.Can you open a pr?
I will open a PR as soon as I finish xcode.application rule integration, so that if we add this rule to one target, the product file will be set to .app bundle file instead of binary file.
It works now, thanks.
But I think we can further improve the current native xcode generator.
- [ ] Display and organize the source tree by directory hierarchy, similar to vsxmake plugin.
- [ ] Support source and target grouping.
- [ ] Support ios and other apple platforms