XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Spec generation

Open ryohey opened this issue 5 years ago • 33 comments

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.

ryohey avatar Dec 04 '19 12:12 ryohey

just letting y'all know how rad this feature would be!

mqln avatar Dec 30 '19 09:12 mqln

Hi! did this feature make it to production after all ?

siempay avatar Apr 08 '20 11:04 siempay

do you need any support on this? imho this is a must have.

2075 avatar May 12 '20 17:05 2075

Yes I wanna know if I can use it on excisting project ?

siempay avatar May 17 '20 19:05 siempay

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

ryohey avatar May 18 '20 11:05 ryohey

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.

4brunu avatar Jun 08 '20 11:06 4brunu

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 config Adhoc to Project configs because any other targets already have Adhoc 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.

SShayashi avatar Jun 19 '20 02:06 SShayashi

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

sfdux avatar Jul 10 '20 01:07 sfdux

@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

ryohey avatar Jul 12 '20 08:07 ryohey

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 avatar Apr 07 '21 06:04 Satoru-PriChan

@Satoru-PriChan It seems that some localized files are missing on the disk. Can you build that project without error?

ryohey avatar Apr 08 '21 09:04 ryohey

@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.

スクリーンショット 2021-04-09 10 38 34

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.

Satoru-PriChan avatar Apr 09 '21 13:04 Satoru-PriChan

Hello, I'd like to know the progress of Spec generation? When will it be released...I've been waiting for this feature

sfdux avatar Apr 13 '21 02:04 sfdux

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.

4brunu avatar Apr 13 '21 08:04 4brunu

@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?

ryohey avatar Apr 14 '21 04:04 ryohey

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?

ryohey avatar Apr 14 '21 10:04 ryohey

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 avatar May 01 '21 05:05 yonaskolb

@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 avatar Jul 09 '21 09:07 taglia3

@taglia3 I think it's xcodegen migrate --project Project.xcodeproj --spec project.yml

user512 avatar Jul 13 '21 20:07 user512

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.

stackotter avatar Jan 03 '22 11:01 stackotter

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:

  1. If a folder has disappeared for historical reasons, but pbxproj still has records about it, it will crash because the folder does not exist
  2. 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
  3. 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

miku1958 avatar May 15 '22 07:05 miku1958

Could you explain how can I test this feature on my project?

ssup1 avatar Jul 18 '22 13:07 ssup1

You download the code from spec-generation branch and run make install.

4brunu avatar Jul 18 '22 15:07 4brunu

For anyone who is curious. The command has been changed to:

xcodegen migrate --spec project.yml Project.xcodeproj 

skofgar avatar Aug 18 '22 01:08 skofgar

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

khoogheem avatar Sep 27 '22 13:09 khoogheem

any progress ?

lemon-li avatar Oct 27 '22 02:10 lemon-li

You are best, everyone who working on this.

2jumper3 avatar Nov 11 '22 12:11 2jumper3

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?

victorwads avatar Apr 26 '23 23:04 victorwads

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 =)

2jumper3 avatar Apr 27 '23 02:04 2jumper3

@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

victorwads avatar Apr 27 '23 09:04 victorwads