I am creating a new bundle in my application by this way:
File Menu => New => New File... => Resources = Settings bundle...
This is the folder structure I am getting:
Test.bundle
Root.plist
en.lproj
Now I wanted to put an "Images" folder inside it directly under Test.bundle but I am unable to do so. Though I can put Images folder inside "en.lproj" folder, is it good to do that?
A bundle is a special folder that Finder displays as a file. You can ask Finder to treat it as a folder by right clicking (or control clicking) on it and choosing Show Package Contents. Finder will open a new window inside the bundle, and you can add folders and files as much as you wish.
Related
After creating a new "Augment Reality App" project in Xcode, I want to move art.scnassets folder from its default location to /Resources/ folder that I created. So the folder path would be like Resources/art.scnassets. However, it fails to load a png file in it if I move the folder. See below:
Before (working):
// art.scnassets folder is in its default place
// below code loads image.png
print(UIImage(named: "art.scnassets/image.png")!)
After (not working):
// moved folder to "Resources/art.scnassets"
// Resources folder is a group.
// below returns `nil`
print(UIImage(named: "Resources/art.scnassets/image.png")!)
I cleaned up the builds, and checked Copy Bundle Resources menu as well, but there is nothing wrong. If I move art.scnassets folder back to the project root, it works, meaning code works fine.
What should I do to move art.scnassets to somewhere else? I am new to Swift.
Have you tried using the first code?
print(UIImage(named: "art.scnassets/image.png")!)
As far as I know it doesn't matter in which folder the scnassets are, you can refer to it the same way.
I've added dictionary dir to my Xcode app project.
But I don't see it in tree view on the left pane:
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
}
I have created a new folder using Xcode, called it www and I have added some html file.
The applicatios runs and works fine, but there are no any files or the new folder in the physical space.
what is the problem ?
If you just can not find the project dictionary: File -> Show in Finder.
If you want to add a folder in your project to make sure it grouped well, you need to: Create Dict in your project dictionary and then in your xCode: File -> Add Files to 'YourProjName'. The reason #Abizern has explained.
When you add a folder to Xcode, you are adding an internal group which does not necessarily mirror the way the files are arranged in Finder.
I created bundle using i-phone-OS->resources->setting but I am unable to add images to this bundle. I tried dragging images folder or by adding existing to folder but nothing works.
Thanks in advance
The Settings.bundle is added as a folder/bundle reference and not as a group.
Thus you won't be able to easily add some content to it right from the Groups & Files panel in Xcode unfortunately. Instead, go in the Finder, right-click (or ctrl-click) on this Settings.bundle and select "Show Package Contents" then drag & drop files in there. You will then find the added files back in Xcode.
I also find this kinda anoying in Xcode3 that we can't add files to '.bundle' folders/bundles directly from Xcode3 :( But AFAIK there is no other solution
One your file has been added to the '.bundle', you can edit them directly from Xcode. (Going thru the Finder is only necessary for adding new files to it)
For some reason, the representation in Xcode "Groups & Files" does not match the file hierarchy in the folder where all my real project files are. And for some reason, I can't copy a entire group or even single file and put that into another project. So I have a nice hierarchy of images within "Groups & Files", but all thos ordered images are unordered like a big mess in just one giant folder full of stuff on my file system. Really horrible ;)
So now I wanted to put all my icons into another project, but I cant just copy the Group "img > gui > icons". I have to pick every single icon image from my file system, where icons are mixed up with a few hundred other images and files.
Is there some hidden option I can activate so that Xcode will manage to reproduce the hierarchy of "Groups & Files" inside my project folder on the file system? Or how else could I copy those files?
It's not really possible to transplant a Groups hierarchy intact from one project to another. Some suggested approaches:
If the files you want to bring across are the vast majority of the project, just clone the project and delete everything that's not the files you want to copy.
If it's a lot of files in a small number of groups, then set up the groups in the new project, and drag-copy the files from the old project groups into the new project groups
Write an AppleScript to move the hierarchy across with a recursive-descent algorithm
◆◆ Open both project.pbxproj files as text files, and carefully copy the File References and Group References from one to another.
Steps:
1.Open up the group in Xcode
2.Select all the items you want to have in your other project
3. Right click and show in finder.
4. Copy those files to a new folder in Finder
5. Now drag and drop those files in the new folder in Finder to your newly created group folder in Xcode on the new project.
6. Accept the copy instructions on 'add file' action in Xcode
Copy icon files in a filtered-Finder window to an "icon-only" folder. Then import them into your new Xcode project. Repeat for any other categories.
See my previous question here.
Also, file a bug with Apple to let them know you'd like the option to have groups represent the folder structure on disk.
I am late, but this is a possibility:
Open the directory of your project using Finder. Copy whole directory (in Xcode its used as a group) into your new project. In Project navigator, right click and press "Add Files". In dialog box, select copied directory and its done.