Can't drag folder from one project to another in xcode4 - iphone

I am trying to use facebook connect and you sare supposed to be able to drag and drop folders but it doesn't work in XCode 4! any ideas?
Update 1/8/2017: This is still true in Xcode 8.2.1

Previously:
drag folder from project A to project B.
Now:
1. in project A, right click - show in finder
2. finder - go up a level
3. drag the folder into project B
4. delete unnecessary files inside the newly added folder
Good job, Apple.
PS: And it doesn't work for groups, as #zeeple mentioned in comments.

Dragging resources between projects in XCode is generally a bad idea in my opinion, even if it is supported. When you drag and drop something in XCode, it doesn't actually create a new copy of that thing, it just adds a new reference to its old location.
This can be very bad, because now changing the resource in one project will make the same changes appear in the other. The vast majority of the time this is not what you want. SCM further complicates things, because if you add a resource to Project B by dragging from Project A and then check in the changes and then some other developer checks out just Project B, they will be missing the resources that you "added" to Project B.
So instead of dragging and dropping in XCode, I suggest using the Finder or the command line to explicitly copy your resources into the destination project's source tree. Then in XCode just add the copied files to the project the same way you normally would.

Related

How to change location of iPhone app icon?

Okay, I am a noob. It must be simple but I stuck here.
I do rigth-click and choose 'select file'.
After I choose the file the dialogue appears:
I want to keep my icons not in the root directory. But I can't figure out how to do this. I tried different ways, even create project from scratch...
Please help.
When you bring image assets into Xcode they will all be in your application bundle's root directory at run time.
It appears that you've added a file named "icon#2x.png" to your project at one time already. Go to the project's summary page in Xcode click Build Phases and then expand the section titled Copy Bundle Resources. There you'll find the reference to the resources that will be copied to your bundle at run time.
More on bundle structures here:
https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
Anyway, the way I've done this in the past is to:
Remove the existing image duplicate from Xcode and from the folder structure in Finder.
Add a new folder in Finder call it "/AppIcons" (or whatever).
Copy all the app icons to that folder in Finder.
Drag the "/AppIcon" folder into your XCode project. I typically put images in an "/Images" subdirectory in the Xcode project. Again you can put it wherever you'd like.
In Xcode on the project summary panel, add your app icons from the folder "/AppIcons" by dragging / dropping or by right clicking and adding them as separate files.
Alternatively in the past when I've had problems with this sometimes Xcode will copy the app icons to the root project directory. If that happens, I make sure that I have the "/AppIcons" folder structure on disc (in Finder) and in my Xcode project. I add the app icons to the project, then move them to /AppIcons in Finder, and re-reference them all over again.
Your Copy Bundle Resources should then have the proper file reference. Note that my apps icons go in "/Images/AppIcons"
Good luck!
I would add the image files to your project with the name icon#2x.png. To do this right click where you want to add the files in xcode and click add file/s. Then search for your image and add them using the dialogue that pops up. - there is a check box so that you can either copy them to the projects destination folder which will copy them into you project folder or leave it unchecked (inadvisable) which would reference it's current location on your HDD. Make sure the file doesn't already exist in the project before doing this!
EDIT:
Sorry I forgot to mention then drag and drop the file from within xcode onto the image location box.
In XCode 4 (I'm using 4.6.2) you will get this confusing message if you've just moved the target's info.plist file, but not corrected the location at the top of the summary panel. Fix this and the icons will reappear, assuming they are added to the project, or if not you should now be able to drag them in without xcode insisting on making extra copies.
This tends to happen when you're starting a project and sorting out the mess of default file locations that xcode gives you. I like my project structure to be 99% the same as the file system structure.
This is an easy fix. If the image you want as your App Icon resides outside of the root of your project, when you get that dialog just click "Yes", and then click delete on the newly created file in the root, and "Move to Trash".
The reference is still there and works without a hitch, since the file will still be in the root at runtime

XCode - Indexing failed in one file

This issue is not a major issue but has certainly made the process consume more time. When I build my application, indexing fails in one and only one file (.m file if it matters).
There is not intelligence, no color on global variables and most of the code except for important keywords are black in color. Since there is no intelligence, whenever I need to make changes, I have to see other files for doing the changes.
this happend for me when the file was not included in the target.
Method 1:
- Go to your project (the very first item in the project list) (cmd-1)
- select your target
- open tab Build Phases
- add your .m file in Compile Sources
Method 2:
- select your .m file
- show Utilities Pane (the one on the right side)
- first tab: show the file inspector (cmd-option-1)
- check the target in Target Membership
Here are the steps I follow when I face such a situation :
Clean the project, in Xcode menu Product -> Clean
Close the project
Open Organizer and go to Projects tab, select the project
Remove all derived data (the buttons are on the main view : Derived data and Snapshots)
Remove the project from the list on the left (select it and press backspace)
Finally close Xcode, launch it again and reopen the project
These steps will make Xcode rebuild the index for the whole project.
If indexing fails, try cleaning the product (or entire build folder). If that doesn't help, close Xcode, remove the DerivedData folder (you can find the location in the preferences "Locations" tab), and start Xcode again.
The indexing process will then try to re-index your files.
Hmm. Considering the normal Clean or Delete Derived Data solutions haven't worked, my next steps would be:
Copy the contents of the .m to the clipboard.
Delete the .m from your project (including sending the physical file to Trash)
Delete Derived Data
Try to compile the project (I know it will generate errors most likely, but let it do this).
Create a new .m file and paste the code back in.
Compile and run the project.
Delete Derived Data again to force a reindex.
Close XCode, reopen it.
Now hopefully it should be indexed. If this still doesn't work, try renaming that class (the .h and .m), see if it indexes, then rename it back again.
Try Product > Clean (XCode 4).
This can happen sometimes, it's annoying. If you get desperate, try creating a new project in a different location and copying the source files over.
I found solution to my question. Actually a localized file of that file was being created in en.proj folder, where indexing failed. So, I just copied that file into project main folder and deleted it from en.proj folder. It works fine now. I can see everything indexed.
Search for "GCC_INCREASE_PRECOMPILED_HEADER_SHARING" in your project build settings
Change 'increase sharing for precompiled header' from NO to YES
Hope this helps.
Go to Editor -> Syntax coloring, and change it to objective c. It might do the trick.

Drag and drop XCodeProj into another XCodeProj not giving me the option to copy

I'm trying to "install" core plot 0.4.
The first instruction is to drag and drop the XCodeProj file into my own project. I do this. Normally when I drag and drop images or the such like it asks me if I want to copy the file into my own project. However for some reason its not asking me, its just creating a reference.
I'm not sure what the difference is, and whether it will still work or not with a reference, its just the first instruction (http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html) says to click the "copy into folder" checkbox.
However that whole dialogue doesn't come up. I drag and drop and it puts the xcodeproj into mine without anything happening!
confused lol
Thanks
Edit: My solution works, but the reason it works is in this answer: https://stackoverflow.com/a/5373575/264947
--
This is what I did to fix it:
Close Xcode.
Open Xcode and create a new workspace.
File > Add files to "Workspace".
Add the first project.
Build to make sure it builds correctly.
File > Add files to "Workspace".
Add the second project.
Build to make sure it builds correctly.
Drag one project into another.
Now, be careful with the next step:
Erase the second standalone project but choose **REMOVE REFERENCES. **
There. Now you should have one project as a dependent of another project.

How to add bundles and resources like images in that bundle in iPhone

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)

separate directory for iphone resources

iPhone resources by default show up in a "Resources" group that's visible in the main xcode project view. I want to be able to put them into an actual, physically separate directory at some arbitrary location on my machine decided by me. Interestingly enuf, the default "Classes" group is an actual, physical directory but the "Resources" group isn't.
How can someone tell me how to do that?
TIA,
Howard
Right click on Resources, add existing files, choose your directory
and select "Create Folder References for any added folders".
VoilĂ .
An alternate approach is to start with a directory in your project with some files, drag it into Xcode and have it create the folder references for you. Anything you add within that folder reference is automatically put in that subdirectory.
Both the abovementioned approaches are just how-tos. These operation will transform into build setting. Here is how you can change (or at least just view) the setting on XCode.
If you are using XCode 4+, check the project icon, then select your Target. In Build Phases tab, looking for "Copy Bundle Resources (x items)" category. In it, you should have your folder there. If no, click "+" button.