xx.bundle directory inside some xcode projects - iphone

I noticed that some XCode projects contain a directory under resources folder named (for ex.) project1.bundle, this directory contains images and .nib files (which are not readable like .xib files). the .bundle directory does not accept any drag-drop for any file from outside of it:
my questions are:
1) why they use such directory ? why didn't just they place their images and other stuff directly inside the resources folder and use them the usual way ?
2) why did they use .nib files inside this directory ? why not to use the corresponding .xib files instead ?
3) how to create .bundle directories inside Xcode ?
p.s. - every .nib file in the xx.bundle directory has its corresponding .xib file somewhere else in the project, so if there is a file named view1.nib inside project1.bundle directory, there is somewhere in the project another file named view.xib

The .bundle folders are directories of external libraries you link your application with. They contain code you can use in your own application in some way. To answer all your questions:
1) The .bundle project is created by someone else. As such, you sometimes are not allowed to incorporate all the code in your own project. You have to add it as a library of code.
2) Nib files are in binary format to protect its contents. As such, you can't open them in Xcode to view the contents of the files (which are probably protected by copyright). It is normal for developers to compile their code before they distribute it, this prevents copycats from stealing their work.
3) To add another .bundle to your application, you can drag and drop the .xcodeproj of that project on your project root in Xcode. Then you can add the project as a dependency of your project under the 'Build phases' tab. The project will then be compiled when you compile your project. Lastly, link your application with the compiled library of the other project by adding it to the 'Link Binary with Libraries' list.
To have others add your project as a dependency, just send them the complete folder of your project. They can use the method above to add your project to theirs.
Hope this helps.

Related

XCode - copying localy all external files linked into the project

When I made my project, I've added many files just by link, without copying them into the project folder. But now, I'd like to have a pack that include all the necessary files into the project folder.
How can I make all those external files being copied into the project folder without having to check them one by one ?
Simply
Delete all the files from your project.
Geather all the files you want to copy.
Drag them all together to your project again, and now check the "Copy item to the destination folder"
I believe this is the fastest way to do this.

Adding flurry to iOS app

In the finder, drag FlurryAnalytics/ into project's file folder. (NOTE: If you are upgrading the Flurry iOS SDK, be sure to remove any existing Flurry library folders from your project's file folder before proceeding.)
Now add it to your project:
File > Add Files to “Your Project” ... > FlurryAnalytics
Destination: select Copy items into destination group’s folder (if needed)

Folders: Choose 'Create groups for any added folders'
- Add to targets: select all targets that the lib will be used for
In your Application Delegate:
Import FlurryAnalytics and inside "applicationDidFinishLaunching:" add: [FlurryAnalytics
startSession:#"YOUR_API_KEY"];
What exactly do you have to do for the bolded step above? I'm using xcode 4.3.3
Where do you do that step?
Thanks!
That means drag the FlurryAnalytics library into Xcode project view on the left, and when it comes up asking if you want to copy it or reference it, you should...
Copy it
Make sure all build targets have a check mark next to their name.
Edit: Here is a technical, no-fun definition of build targets http://developer.apple.com/library/mac/#featuredarticles/XcodeConcepts/Concept-Targets.html. Sometimes it is useful to create multiple targets. If you don't know what they are, you likely only have one target and don't have to worry about it.

How to rename the folder name in xcode project with out corrupting the files

In my xcode project i have created a folder manually named "MyClasses" to place the newly added files/classes to this folder.
Now i have nearly 30 classes in this folder.
when i renamed this folder , all the files in this folder are gets Erased.
Now i need to rename the folder to "ViewControllerClasses".
But i lost 30 .h, .m, xib files. [lucky i have a copy & and zip file]
How to rename the folder with out corrupting the files.
Renamed it to myviewcontrollerclasswes
When i renamed
Two Solutions
Method_1. Try Manual editing:
« Drag your MedChart.xcodeproj to TextWrangler (or any text editor)
« Use find button to find "FolderName" (Your folder name)
« Replace all with new name.
« In some project you may notice header search path problem...goto header search path and replace with new name.
Method_2. Use Xcode to choose base folder:
Rename folder in finder then use Xcode to choose same folder.
NOTE as of 2017:
Now Xcode 9 synchronises the folder and the project hierarchy automatically.
NOTE as of 2013:
Duplicate and rename Xcode project & associated folders
The "folders" what you see in XCode under your project file are not real folders in the file system, only virtual folders administered in the .xcodeproj file. You can organize your files in the project folder independently from their location in the file system. Some prefers to map the file system folder structure inside the project folder structure, some others store all source files in one big folder in the file system and organize them only in the project folders: it's rather a question of preference.
However if you rename/move physically the files in the file system, you will have to delete and re-add them to your project since XCode will not know where to find them. Pay attention not to delete them physically only remove them from XCode project, then re-add them and reorganize as you want.
One more thing to note: if you are using version control system you will have to inform also its client (svn or git most likely) that you have renamed/moved your files. If you want to keep file revision history it will be a good idea to issue the copy/move command explicitly to the version control otherwise it will treat your files as deleted from the old location and added as new in the new location.
In case anyone is still having trouble with this:
Select the folder or file in the left-side bar of XCode corresponding to the folder you want to rename (for me I renamed the folder containing all my files so I selected the topmost folder)
On the right-side bar, below where it says 'Location', click the folder icon.
In the file explorer that opens up rename the existing folder to whatever name you'd like it to be, then afterwards select it and press 'Ok'.
XCode should update the file locations accordingly.
Keep in mind that if you rename something which contains a file that is hard-coded as a certain path in your build settings, XCode will throw an error. You'll have to manually change those paths in your build settings.
This worked for me, hope it works for you too.
You should just run a search and replace on the project file (if you are working with version control and with other developers you will have seen this file a lot without a doubt), it's the project.pbxproj file located inside the xxxxxxxx.xcodeproj file.
Just right click (Control + Click) on the file and select "Show Package Contents" to find the xcodeproj file.
I still find it easier than all these methods to simply create a new folder in your file navigator and then drag your files from the other folder into it. Sometimes the simplest way is the best way. It literally takes me 10 seconds and I don't need to leave Xcode.

xcode4 file not found when is already in project

I'm using touch JSON, I imported and copied the files inside my folder,
then #import "CJSONDeserializer.h" which is recognized by the autocompleter, but when building, it appears that CJSONDeserializer file not found
So what am I doing wrong while importing, or how to make it recognize the files?
My best guess is that you have not added the header files to your target. To do so go to your project navigator top level, select it, select target, and go to the "search paths" sections, then in the header search path add the path to the CJSONDeserializer.h relative to where your .xcodeproject is.
Where did you place the imported files? make sure you copy the files to the project and not just reference them. Also, go to Build Settings in xcode when clicking the main project, try to edit the option Header Search Paths with the path of the imported files
While copying file have checked the box asking for copy to this folder. If yes then delete and try again. This issue has encountered several times while importing file or copying.

how to get generated *.m/*.h files to be recognized in XCode4 for compilation etc?

I've got some autogenerated *.m and *.h files (from mogenerator) that I have put into a directory "mogen" in my project. What I did was add this directory into my project using "Add Files..." and the referencing approach.
They now appear in the project, however classes trying to IMPORT the header files are getting "no such file or directory"
How do I get, in XCode 4, the classes/header files to be compiled such that they're available to the rest of the project. For example:
do I need to manually add them to TARGET/BuildPhases/CompiledSources
other approach?
ideally the approach would automatically work when more auto-generated classes & header files appear
It seems all that was required was to manually add each of the new *.m files (not *.h files) to the TARGET/BuildPhases/CompiledSources area.
(i.e. not the directory - pity it wasn't possible to just add the directory and have XCode4 pickup automatically any new changes/additions of classes to the directory)