Why does dragging an objective-C header or code file from one folder to another make it turn red in Xcode 4.6? - objective-c

I have an Xcode 4 objective-C project which contains about 150 .m and .h files in it.
The code underlying the project does not always correspond in underlying disk structure to the folders shown in the Xcode project. I get that part.
What I don't get is why Xcode won't tell me anything about why I can create new project groups and move items to them, with no problems, but certain existing project folders will cause the project to become broken, and the code will no longer build once I move certain .m files or .h files into a different group. When its broken it just shows the file in red. This is frustrating and confusing.
In the screenshot below, the left side of image before shows state before, when all is good, right side shows red (missing) file after moving into a group. Given that groups don't represent a folder on disk, I would not expect moving from one group to another to break things. Sometimes it does, and sometimes it does not. This particular XCode issue upsets me a lot.
In the good old days of Friendly Mac User-Interfaces, you could hit ⌘+I and get some information about the properties of objects, or right click and get to the properties of something via its context menu. Groups (folder icons) in XCode projects have no properties item in their context (right click menu) and yet these groups all clearly NOT all alike. What's up with these identical looking groups?
Secondly, how does a person learn how to reorganize both the on-disk-folder-organization and the visual group organization, in a way that does not leave you bloodied and beaten? (XCode 4 is the most difficult IDE version I have ever used, for this, I'm sure I've missed some important documentation on dealing with folders and files and so on.)
Update: The File Inspector (Identity Inspector in Utilities menu) is the key to this mystery, but exactly how a new user is to discover this (other than by painful experience) is still unknown to me. I also don't really understand what all this is about, with various choices available in the Path drop-down, and the blank or non blank value that has no description or help, just a cryptic icon and either a name of some real on-disk-folder or else a gray text field saying None:

This sort of thing doesn't just happen out of the blue. In this case, what has happened is that a user has opened an .xcodeproj and is unaware of the difference between the various relative or absolute Path options that a Group can be a part of. A Group in XCode is always shown with exactly the same manilla color folder-icon inside your XCode project, no matter what modes or properties it has defined inside of it.
By default the simplest case is that you create a new folder Group object in XCode and it's purely a cosmetic organizational tool that has no disk location information stored in it.
This is not the ONLY thing that these groups do, and not the only "mode" that these groups can be used in. These groups can also be used to point at some folder and say "things that are in this virtual folder are really somewhere else, either underneath this project's main folder in a subdirectory, or even up somewhere else on your hard-drive, either stored in relative path, or absolute path format". When used like this, these things remind me of a Windows "Shortcut" object on the desktop, or a Mac "Alias" object in the finder.
Dragging a file from one group to another does not move it to a different folder on the disk. It simply moves a reference to a file with a certain name, to another group, which might mean that after you drag a file, you haven't really moved it, or copied, or relocated it in any way, you've just moved an alias from a place where it could resolve properly to a real file, to a place where it can't. Thus XCode helpfully turns it red for you, without any helpful error message about what happened.
How do you fix it? In this case, go to the Identity inspector pane in the Utilities menu, and either decide to clear out the bogus value in the place where I have shown in the picture in the original question where I had "Classes". Clearing out a value that is invalid is not exactly easy to do because XCode requires that you basically find the root folder of your project and select that, and that will 'clear" the relative or absolute path property on your folder-group.
Alternatively, you can leave the folder alone, and just don't drag files from group A to group B without first checking what relative or absolute path they reference.
What still seems horrible to me is that XCode tutorials tell you to "use XCode to manage your project's contents, don't just drag files around in the finder inside an XCode project directory", and that's good advice, but it leads me to assume that XCode provides full and intuitive physical (and virtual) group-folder organization tools. It does not. As an example, imagine you inherit a project that has .m and .h files scattered through four physical folders underneath the main XCode project folder and you want to move those files around. You have to do a combination of tricky things inside XCode, and either in Terminal or in the Finder, in order to reorganize your folder. With the complications involved in moving items around in your version control tool of choice added upon the top of that, and XCode's very limited support for only Git and Subversion, you have a really tricky mess.

Related

MvcBuildViews and locating views

I have enabled MvcBuildViews task in my project file and I have found it finds and tries to build views that aren't in the project.
These views were totally out of date but not knowing whether to delete them or not from source I opted to relocate them (until I can find out) to a new folder called 'Obsolete'.
After relocating the view I try and build the project and it still somehow finds these views in the 'Obsolete' folder now.
How can I instruct the MvcBuildViews task to only compile views found in their usual search location and not everywhere in the project directory?
So after doing some more hunting I find that the MvcBuildViews uses the aspnet_compiler.exe under the hood. It appears the only solution if I want to hand pick the locations is to point it at the specific folders themselves. My other option is to move the views outside of the project.
http://msdn.microsoft.com/en-US/library/ms229863(v=vs.100).aspx

Make MonoDevelop respect smcs.rsp

It's possible to create global defines, by placing them in smcs.rsp, and when you hit play - you'll notice those parts of the code are hit and everything is acting as if it should.
However when editing the source in MonoDevelop, it does not recognize the constants that are set in that file.
Leaving you with text that looks like this:
This makes it hard to keep track of what the current constant values are and requires mentally tracking what is turned on and off despite the editor constantly telling you otherwise.
Is it possible to get monodevelop to respect that file?
The method of using smcs.rsp is pretty old and is not needed after unity3d 4.x. Before 4.0 there is not way of doing it without smcs.rsp file but things have changed, the constants can be added from game itslef.
Go to Edit->Project Settings->Player and in the inspector, choose other settings and u will see configuration title, in the box below specify your symbols one by one followed by ;

Thought I successfully added Cocos2D to my Cocoa Touch project, but autocomplete shows no CC classes

Following several online tutorials, I managed to get Cocos2D added to my Cocoa Touch (UIKit) project. Problem is, I'm able to #import "cocos2d.h" at the top of any one of my files and my game compiles and runs fine, working just as it did before, but I don't have access to any of the cocos classes, like CCNode, CCLayer, etc.
To give you an idea of what the app does, currently, the main menu UITableView comes up, scrolls as it should, buttons that lead to various view controllers (facebook, twitter, new game creation, store, settings, etc.) all work fine. Back buttons in each view return the user to the main menu table view. This is pretty much all it does, as of now. The idea at this point would be to pass the baton to a Cocos2D scene--where the gameplay would be--when the user taps on one of the UITableViewCell's that represents a current match.
The process I used to add Cocos2D to my project was this:
Drag and drop the cocos2d-ios.xcodeproj into my "supporting files" folder
Under "Link Binary with Libraries" heading under "Build Settings" for my project, I added libcocos2d.a (which continues to show up red, even after "successfully" adding Cocos2D), libz.dylib, OpenGLES.framework, and QuartzCore.framework. They all read "required."
Under "Build Settings" for my target, set "User Header Search Paths" to "/Users/Home/Downloads/cocos2d-iphone-master-v2/**" (recursive), which is where my Cocos2D library folder is.
Under "Build Settings" for my target, set "Always Search User Paths" to YES.
Did the same two steps identically for my project's "Build Settings"
Went through and selected all the Cocos2D .h and .m files and set -fno-objc-arc compiler flags for all Cocos2D files, which enables the pre-ARC calls to retain, release, dealloc, etc. in the old Cocos2D files to play nice with all the post-ARC files in my project.
Also worth noting, perhaps, is that when I create a new file in my existing project "cmd + n", the only options available to me under Cocos2D templates is the CCNode class.
Am I missing something, here? Again, to be clear, I can import the cocos2d.h file and it looks as though everything will work fine. But, when I try to define anything that starts with a "CC", autocomplete shows nothing. Any help would be appreciated. Beating my head against the wall, here. TIA
The autocomplete issue is most likely because of the recursive search path. Xcode has problems indexing recursive header search paths (especially if you just drop in a .xcodeproj). Change it to an absolute path, add multiple paths if the source files are spread across multiple folders.
With Xcode 4 you shouldn't drop in a xcodeproj to another project anymore. Use a workspace to combine multiple projects side-by-side in a single workspace. See Kobold2D for an example (or just use it if you continue to have problems, because these things are already solved in Kobold2D).

How do I implement a static library from libPusher in Objective-C (Xcode 4.2)?

Please show me how I can add and implement the libPusher library to my Objective-C iOS project
This is my first post on StackOverflow
I've just started working in Objective-C iOS app development for a company that I co-founded with a couple of colleagues. Our first app needs to have the libPusher library implemented in its porject. Right now, I'm at a crossroads completing the following task of adding and implementing it on Xcode 4.2:
Simply copy libPusher-combined.a and the contents of the headers directory into your Xcode project..
Source: http://github.com/lukeredpath/libPusher/wiki/Adding-libPusher-to-your-project
What does it mean by "copy"ing those files, and where should it be copied to? Can anybody who has experience with libPusher give me specific details as a list and source code on how to execute this so I can understand it better? I would truly appreciated any help, it will get our company up and running for us getting our app functioning and ready for reviewing submission to Apple Developer staff. The link I've provided will tell you more on what I'm talking about, if I need to specify anything I'll create a new post. Thanks!
What "copy" means in this context is that you want to drag and drop the .a (library) file and the header files (all the .h files) into your new Xcode project (to be precise: the file inspector is the list of files along the left side of the workspace window).
To copy anything to an Xcode project, find it in the finder, highlight all of the files you want to copy over (or just take the folder it comes in), then drag everything over the Xcode icon in the dock.
If Xcode is full screen (lion), the icon will kind of blink, then enter Mission Control mode, you then hold the files over the correct project and drop them into the Xcode file tree.
Make sure that your application is checked as a target for those files!!
If Xcode is not full screen, just drag the files or folder into the Xcode file tree and they will be added.
To link to a static library, just navigate to the name of your project>Info>Framworks. Click the plus, then select your framework if it isn't already there.

How do I stop Xcode from letting me edit old projects in new projects

I am new to Xcode and have been trying to make various projects to get acquainted with it. So I have this one project called calc and it is a calculator. Now I'm trying to make another calculator app that is different but when I'm making the code in viewcontroller.h I will type similar lines of code and when I do it indicates with a little grey dot with a circle around it that I'm connected to my older project. When i click it it gives me links to other objects that are in different projects.
The dot:
That dot indicates that your IBOutlet is connected up to a xib file.
When you created your new project. Did you drag some old files into your new project? Then when you did that did you leave the
Copy items into destination group's folder (if needed)
check box unchecked? Because then you would have files that are from other projects. If you wanted a copy of the files you should check the previously mentioned check box when copying files across.