salivan salivan - 7 months ago 57
Swift Question

Xcode adding custom dir, doesn't show in tree view

I've added

dir to my Xcode app project.

enter image description here

But I don't see it in tree view on the left pane:

enter image description here

Actually I don't need to see it per se, I just need its path to copy it to ~/library/spelling

But I'm just curious if its the right way to tackle this problem. Will I be able to get its path if it doesn't show in left pane?


The standard tree view in Xcode is not a direct mapping of the underlying directory structure. Xcode uses "groups" which are the yellow folders in the project navigator that can be directories in the file system but don't have to be.

If you'd like to add your new files to the project, simply open a Finder window and drag them from Finder into the project navigator. You'll be presented with a dialog when you drop them in, make sure the files are added to your fish target. This is what makes the actually get copied into the built app.

If you'd like to have Xcode show a direct translation of the directory structure, you can drag the fish/dictionary folder into the project navigator, and select "Create Folder References" rather than create groups. This will be represented with a blue folder icon and will stay in sync with the directory.

Also, just so you know, the files won't be in library or anywhere like that. You'll load them by asking your main bundle for the url for that resource like so:

if let url = NSBundle.mainBundle().URLForResource("ka_GE", withExtension: "aff") {

    // found url for resource

Note that if you dragged in the dictionary folder as a folder reference in you'll project, you'll have to call it like this:

if let url = NSBundle.mainBundle().URLForResource("ka_GE", withExtension: "aff", subdirectory: "dictionary") {

    // found url for resource