简体   繁体   中英

xcode create group from physical folder based on file template

I'm currently trying to create a custom file template for xcode. As part of this any new 'file' from my template actually generates a number of files separated into folders better describing their functionality eg Foo/Presentation/FooViewController.swift, Foo/DataSource/FooDataSource.swift etc. where 'Foo' is the name of the file created.

Although this works and all the files and folders are added to my project, the folders are added as physical folder references. Is there anyway that in a 'file template' these can be converted to groups? Or is there a way to convert a folder to a group in xcode - I've seen lots of questions doing this the other way but not converting a folder to a group.

I could strip all the folders out, but then as this will be used across a team, everyone would have to create the groups themselves everytime, which isn't a very efficient workflow and a template would ensure a common structure.

I can't seem to find any good docs on template creation either and a lot of the sites online seem focussed on older versions of xcode and project templates rather than file templates.

If anyone has any ideas to help solve this it would be appreciated

To convert the folder structure to a group structure, use the following steps once the folders are created in Xcode:

  1. Delete the folder by selecting "Remove References", so not deleting the files and folders, just its reference inside Xcode.
  2. Select the parent folder and then select Files > Add files to "...".
  3. There, add the just removed folder and make sure you select the option "Create groups".

That will add the full structure of folders and subfolders as groups.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM