Question

I have two images in different folders of NSBundle having the same name. It obviously emits a warning:

Warning: Multiple build commands for output file /Users/xxxxxXXXXXXXxxxxxxx.app/image.png

I know that NSBundle => In NSBundle all the folders are "groups", not actual directories and that files in these groups are still located in the bundle's root.

In my application, I need to have images with the same names in different "folders" to ease my task.

So my questions are:

  • Is there any way to keep two images in different folder of NSBundle without any warning? And also how can I fetch it?

  • If no then any problem with this warning when I upload my app to app store? I mean, my app will be rejected by Apple or not?

Was it helpful?

Solution

Here it is a very nice link for doing this task please check this Xcode Groups vs. Folder References that clearly describe about it

Groups

  • The size and complexity of the underlying project file (project.pbxproj) can grow significantly, especially with multiple targets. Each new target has to duplicate all of the references. You also have to remember to set the proper target membership for each file. Plus there is a greater likelihood of SCM merge conflicts due to the larger and more complex project file.

  • Groups may bear no resemblance at all to the folder hierarchy on disk. You can have project folders in the Finder that don’t even exist in the Xcode project, and vice versa. Because of the mismatch, locating files can get confusing

  • If you move a file or rename it outside of Xcode, the reference breaks and the file turns red. File management becomes a real pain.

Folder References

The benefits of folder references are:

  • Xcode only stores a reference to the folder. All of its files and subfolders are automatically added to the project. This keeps the project file smaller and simpler, with less chance of merge conflicts.

  • If you rename, delete, or move a file in the file system, Xcode automatically updates the folder reference to reflect the change. File management is thus far easier. Because the folder hierarchy in the project matches the hierarchy on disk, they will not diverge over time and cause confusion.

  • You don’t have to worry about name conflicts because the directory structure is preserved in the product bundle. Two files can share the same name as long as they live in different directories.

OTHER TIPS

You have folder : images. Change it to bundle by rename it to : images.bundle. Drag this to your project and:

You have :

images.bundle --- folder1 --- image1.png         
              --- folder2 --- image1.png
              --- folder3 --- image1.png

You get array of folders, after get folder you want, you can get image you want:

NSString *path = [[NSBundle mainBundle] bundlePath];
path = [path stringByAppendingString:@"/images.bundle"];
NSError *error;
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top