简体   繁体   中英

Folder structure of xCode project is not appearing in git repository

I'm developing an iOS app with some other students of my class. One of them created our Xcode project and set up all the folders (groups) we need. These folders also appear in his finder. When pushing everything the folders are not visible in our repo . When I pull it, everything in Xcode is fine, all the folders are there (which also says the pbxproj-file). BUT in my finder none of these folders are there .

This is how it looks like

How can we also put the folders in Git, so that they are visible in our repo and the files are in them?

Edit: The below is the question I thought you were asking, but the image you added suggests a different problem. I would first make sure you're actually looking at the same directory. Cmd-rightclick the project in the navigation bar and make sure it's the folder you think it is. This is a surprisingly common mistake.

在此处输入图像描述

I would then make sure you haven't referenced external folders or put things in a strange place. Select a folder and open the right-hand sidebar (Cmd-Opt-1), and check the path. It is very common when you drag things into a project, or rearrange a project by dragging, to accidentally create absolute path references to locations outside your project.

在此处输入图像描述


Xcode has traditionally used groups rather than folders to organize files. Groups are a virtual structure, purely in Xcode. Most of the files are put into a single physical directory.

(Whether this is good or bad is a matter of taste. I've long preferred having most files in one directory to make reorganizing the structure easier, and to make it easier to write scripts that search or process all the source code. But over the years, and particularly moving to Git from Perforce and SVN, and especially with the rise of GitHub, I've grown to prefer the folders, and that seems to be the direction Apple is moving towards as well.)

In recent versions, Xcode has moved towards supporting folders directly.

You can see the difference in Xcode. This is a group without a folder:

Xcode 中的组图标

This is a group with a folder:

Xcode 中的文件夹图标

Note the lower-left corner of the icon.

You can make folders from the local menu, either by right-clicking an existing folder/group, or by selecting files you would like to move into a folder and right-clicking:

用文件夹分组

I don't believe there's any shortcut to convert all existing groups into folders. You'll have to restructure. But as you create new things, make sure to create folders if you want those.

It's better to maintain relevant folder structure as mentioned by @Rob Napier so that when you modularise/move files in xcode the files are moved to the corresponding folder structure and they are in sync with the file system.

Right click on any one of the file(under view/vm) and -> click show in finder to check the absolute path of the file.

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