Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

configuration - How do I get Xcode to replicate project group structure in the folder structure on disk?

I have an Xcode project with the following group structure:

ProjectName/
    Classes/
        class1.h
        class1.m
        class2.h
        class2.m
        ...
    XMLDocs/
        doc1.xml
        doc2.xml
        ...
    Resources/
        Info.plist
        MainMenu.xib
        ...

and so on and so forth.

I'd like this to be represented in the folder structure on the disk as well:

ProjectFolder/
    Project.xcodeproj
    Classes/
        class1.h
        class1.m
        class2.h
        class2.m
        ...
    XMLDocs/
        doc1.xml
        doc2.xml
        ...
    Resources/
        Info.plist
        MainMenu.xib
        ...

as opposed to the usual everything in the root project folder methodology.

Is there any way to do this without manually creating the folder structure on the disk and then having to repoint all the reference in Xcode to the new location?

Bonus points if you can tell me how to do this automatically any time I create a new group or add files to an existing group in Xcode.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do this to some extent! There's just one extra step to do every time you create a new group (and this first time you'll have a lot of catching up to do!):

Xcode location setting

Whenever you create a group in Xcode, immediately select it and open the righthand sidebar. Notice the "Location:" setting just below its name. Click the folder icon next to "None" and set it to a new folder with the same name.

Now, whenever you add files to the group, they'll head to the corresponding folder on disk. Woo!

Unfortunately, this initial time, you'll have a lot of file-moving to do. (As you change the group paths, your files will all turn red, as Xcode will begin looking for them in the new folder. You'll have to manually move them from the Finder to fix it.) There is, however, a command-line tool to perform this initial migration for you: https://github.com/venmo/synx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...