Search This Blog

Thursday, February 23, 2012

XCode 4.2 #import FAIL!

(I've probably covered this in another post but I have gotten more details about the FAIL so I am posting again.)

Imagine a project with two folders A and B.  Folder "A" represents one version of some source code and contains files m1.[m/h] and m2.[m/h].  Folder "B" a version that's an update from "A" - same files but they will be modified.

Now create an XCode 4.2 project based on "A."

Build it and make sure it works.

Now add something that the compiler doesn't like to the m1.h file - a duplicate #define or similar.

Next remove the m1.[m/h] files (from the "A" folder) from the project - don't delete them - just remove the "references." 

Now drag the files from "B" with the same name into the project.

What you will find is that XCode 4.2 continues to look at the files from "A" until you physically rename them in the finder. 

After you rename them in the finder it forgets about them - so clearly its keeping some kind of "hard" reference to the original files even after you've asked it to forget the file.

This is a fundamental flaw as far as I can see - no documentation or much on the internet about it.

I suppose it could be an LVM compiler problem - its hard to tell.

Yet it continues to be a problem for me and its frustrating because this is Project UI 101 as far as I am concerned.

XCode should only include/import files explicitly in the project - even if duplicates are present in other include folders.

Saturday, February 4, 2012

Yes, XCode 4.2 Just Destroyed Your Source...

No, I am not insane.

I had two projects.  One points to a set of files in directory A.  The files are D.h and D.m.

I had a second, new project open in XCode 4.2.  It points to directory B.  The files are also D.h and D.m.

These files are similar but not the same as I am refactoring the code and upgrading the code from A to B.  So I am moving code from the old files in A to the new files in B.

Simple enough from a developer perspective.

Well good old XCode 4.2 apparently thinks these are (somehow) the same while both projects are open.  (XCode 3.2.6 knew the difference.)  Magically and incorrectly the file hash project mumbo-jumbo apparently tells XCode 4.2 that somehow the files are not different and the content is interchangeable.

So I spent an hour updating the new files in B - flipping between the two projects.  Stupidly believing that saving files in the B-based project were actually updating the file system.

Suddenly, without warning, in the project referencing B all the changes magically revert back to the original files in A.

All the code changes vanished.

Not a single warning.

Nothing.

I guess the idiots at Apple working on XCode 4.2 never have to do something like this and hence this aspect of XCode never got tested.

XCode should never, ever overwrite files without a warning.

Worse, I am running Lion.  So when I do searches for these files, e.g., D.h, good old Lion only shows "Last Opened" dates.  So if I touch the file by opening it I can no longer tell which D.* was created when.

I have to go back to the regular finder and look to see "Created Date."

I have written before how you cannot copy XCode 4 projects - apparently no one at Apple even imagines one has to do work like this.

Come on, Apple...

Stop your slow death spiral into becoming Microsoft circa 1998.