XcodeGen
XcodeGen copied to clipboard
Spec generation
moved from https://github.com/yonaskolb/XcodeGen/pull/682
Implementation status
- [x] Write Project to a yaml file
- [x] Generate Project from XcodeProj
- roughly done
- some project settings are not treated yet
- [x] Remove default values from yaml
- [x] Change to proper command names and CLI improvements
- [x] Add unit tests
- [ ] Add option to opt-out the default value removal
- [ ] Fix to find C header files appropriate way
- [ ] Test in real environments
About the last item. As far as I know, C header files are not added to the build phase on the application target, so we have to find them from the group. Currently I am adding all header files in the group as sources, but if the group doesn't match the target it will cause problems.
just letting y'all know how rad this feature would be!
Hi! did this feature make it to production after all ?
do you need any support on this? imho this is a must have.
Yes I wanna know if I can use it on excisting project ?
Hi, there
I've done a basic implementation. This can probably be used for simple project. Would anyone like to test it on some project?
usage
./XcodeGen migrate --project /path/to/ExistingProject.xcodeproj --spec generated.yaml
cc @2075 @siempay
Hey, I used this to try to simplify the migration to XcodeGen and it did 80% of the work! 😃 It still needed some manual work, but it's a great starting point! Maybe this could be introduced as an experimental functionality. Thanks, this PR is awesome.
Thank you for your awesome work, I also used on our project. It works well 80%. I report some issues that I was faced with!
- Only create “debug”, “release” build configuration. you’d get the following error:
Build settings has invalid build configuration “Adhoc”
(You can easily fix just adding configAdhoc
toProject
configs
because any other targets already haveAdhoc
settings.) - Doesn’t create
Build phases
dependencies properly - Doesn’t consider
Build phases
order. This should happen an issue, such as R.swift scripts. - Doesn’t create scheme settings
- Creates verbose compiler settings
- Contains Carthage, Cocoapods settings
-
sources
have each file
I hope this would be helpful.
I am looking forward to this feature. C header files are not added to the build phase on the application target, this is a problem...I report these issues below:
- Doesn’t create Build phases dependencies properly, such as embed
- delete scheme settings
@4brunu @SShayashi @sfdux Thank you for your feedback! I am working on issues you reported.
- [x] Only create “debug”, “release” build configuration
- [x] Doesn’t create Build phases dependencies properly
- [x] Doesn’t consider Build phases order. This should happen an issue, such as R.swift scripts.
- [x] Doesn’t create scheme settings
- [ ] Creates verbose compiler settings
- [x] Contains Carthage, Cocoapods settings
- [ ] sources have each file
Hello!
I tried hitting xcodegen migrate --project MyProject.xcodeproj --spec project.yml
but it showed an error message: "Error: The folder “en.lproj” doesn’t exist". Does anyone know the cause of the error? Thank you.
@Satoru-PriChan It seems that some localized files are missing on the disk. Can you build that project without error?
@ryohey Yeah, it compiles fine.
I found the cause of the error myself. I use a library named "ALCameraViewController", which has a .strings file. The file is localized into English and located in en.lproj folder. So compiles no problem.

But the folder is not located at the root of my project but at the root of ALCameraViewController:
MyProject root > ALCameraViewController > en.lproj > CameraView.strings.
I disabled the English localization of the file, then xcodegen migrate
started working fine. I guess that is because xcodegen migrate
can't find en.lproj folder that is not at the root of the whole project.
Hello, I'd like to know the progress of Spec generation? When will it be released...I've been waiting for this feature
I already mention this, but I think this feature should be introduce as experimental, because I think this will be hard to ever do 100% of the work. This is extremely useful, if wasn't for this feature, I think I wouldn't be using XcodeGen today, because I have a project with a framework and multiple targets, and without experience creating those project.yml files, would be hard. But this did all the hard work, I just tweaked a bit to work. @yonaskolb what do you think about adding this as an experimental feature, and marking it as experimental in the docs? This would also open this PR for external contributions, on the edge cases.
@Satoru-PriChan I cannot reproduce the error with .lproj directory located in a nested directory. Could you give me a minimum project to reproduce it?
There are still some issues such as redundant spec files being generated and, as already reported, errors in some situations, but after seeing it used in various places over the past year or so, I think we have created a feature that is somewhat useful, assuming the user fixes it manually.
I've also added unit tests, although they don't cover much, so I think other contributors will be able to continuously improve this feature.
As @4brunu suggested, I think it might help some people if it is merged as an experimental feature.
Then the only work left to do would be to modify the CLI, e.g. to make the argument a long name like experimental-migrate
, and to print a warning on stdout that the spec needs to be modified manually.
@yonaskolb What do you think?
Yeah I'm open to releasing this in an experimental state.
I've just added the generated specs for our fixtures to the tests, so we can check check progress more easily. At the moment those fail when parsing the generated files back into a Project.swift. I'd like to get at least that fixed. @ryohey seems there are a lot of null
values generated which I think is causing the issue, if we could resolve that
@yonaskolb I pulled the spec-generation branch, runned the xcodegen schema with launch argument "--migrate" but I encounter an error:
Usage: xcodegen [options]
Generate an Xcode project from a spec
Options:
--cache-path <value> Where the cache file will be loaded from and save to. Defaults to ~/.xcodegen/cache/{SPEC_PATH_HASH}
-h, --help Show help information
-n, --no-env Disable environment variable expansions
--only-plists Generate only plist files
-p, --project <value> The path to the directory where the project should be generated. Defaults to the directory the spec is in. The filename is defined in the project spec
-r, --project-root <value> The path to the project root directory. Defaults to the directory containing the project spec.
-q, --quiet Suppress all informational and success output
-s, --spec <value> The path to the project spec file. Defaults to project.yml
-c, --use-cache Use a cache for the xcodegen spec. This will prevent unnecessarily generating the project if nothing has changed
Error: unrecognized option '--migrate'
Program ended with exit code: 1
Where am I wrong?
@taglia3 I think it's xcodegen migrate --project Project.xcodeproj --spec project.yml
What still needs to be done to get this to a state where it could be included as an experimental feature? I would be happy to help out with some of the remaining todos depending on their nature.
Hi, when I tried to use migrate to convert a very old project of my company (20 years old, pbxproj has 3.8MB), I found some very unexpected bugs:
- If a folder has disappeared for historical reasons, but pbxproj still has records about it, it will crash because the folder does not exist
- Performance issues, after I fixed issue 1, it ran for half an hour and used 6GB of RAM but it wasn't finished, so I added cache, and the effect was that it took less than 5 minutes and about 100MB of RAM to run
- The conversion does not take into account the relative paths and absolute paths that are missing. My project has a large number of folders without correctly mapped paths for historical reasons, and the files in the folders are directly mapped relative to the root directory (which is the problem I want to solve with xcodegen), so using the converted yml to "xcodegen generate", the generated xcodeproj skips all the folders that are not mapped correctly, and shows all the folders that are mapped correctly in the root directory
Could you explain how can I test this feature on my project?
You download the code from spec-generation branch and run make install
.
For anyone who is curious. The command has been changed to:
xcodegen migrate --spec project.yml Project.xcodeproj
I am seeing the same issue with not being able to find the lproj
files..
They are nested:
App/
project.xcodeproj
AppCode/
Localization/
xx.lproj/
zz.lproj/
if move moved to same level as the project.xcodeproj
it works :
App/
project.xcodeproj
xx.lproj/
zz.lproj/
AppCode/
maybe an option to locate Localization would be nice
any progress ?
You are best, everyone who working on this.
Hey, what happens here? i really need this feature, i dont understand to much of xcode parms, like most ios/macos devs.
i'm tring to improve my project https://github.com/victorwads/UptimeLogger to use xcodegen, but don't even know how to start confgiuring my project.
Anyone?
Hey, what happens here? i really need this feature, i dont understand to much of xcode parms, like most ios/macos devs.
i'm tring to improve my project https://github.com/victorwads/UptimeLogger to use xcodegen, but don't even know how to start confgiuring my project.
Anyone?
Hi Victor. It works =) u can write me in telegram @okeygo, I'll try to help you =)
@okeygo
Telegram was blocked on my country by judicial decision TODAY!!!
I spend like 12hours nonstop converting my project. but there are some thing i did not solve. Can u help on another platform? =D