问题
I tried putting all xib files together in a folder in my project. And then I add this folder into the Xcode project, Hoping that Xcode may recognized them and put them in the directory I want in target package.
But when I ran the target, the console(NSLog) told me that the nib file could not be found.
I looked into the directory, there are xib files there instead of nib file.
Here comes the question mentioned in the title. Can I achieve that?
Here is the scene:
I built the project. Then Xcode convert xib files into nib ones then put them in the "Resources" directory. As all resource files (including these nib files) are put together under this folder, it looks messy.
What I wanted to do is put all these resource in different folder automatically after the building was done. What should I do?
回答1:
I don't think there is a way this is possible, except in localization (see auto-created folder structure): https://developer.apple.com/library/mac/documentation/corefoundation/conceptual/cfbundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW7
回答2:
Try doing this:
- select all of the XIB files
- change the file type to something else
- then set the file type BACK to the default type (IB CocoaTouch XIB)
- de-select all of the files
- clean the project, delete the previous version(s) from the simulator(s)
- build the project
now it should contain contain only NIBs, no XIBs.
来源:https://stackoverflow.com/questions/20533227/can-i-put-all-nib-files-together-in-another-folder-in-target-application-package