Xcode 5 compiles wrong file if duplicated

Originator:michele.titolo
Number:rdar://14191229 Date Originated:18-Jun-2013 11:20 AM
Status:Open Resolved:
Product:Developer Tools Product Version:5.0 (5A11314m)
Classification:Other Bug Reproducible:Always
 
Summary:
If you have a duplicate class file in your project's folder in Finder, Xcode will always take the one in the root file of the project, even if the file reference in the .pbxproj is set to the correct file. This can cause mysterious build failures, since the file you edit is the correct one. Xcode should not crawl the file system, but instead should rely on the file references in the .pbxproj to build.

Steps to Reproduce:

1. Create a new Empty View application.
2. Create a custom NSObject class in a subfolder of your project, let's call this Foo.
3. Copy the empty Foo.h/.m to the root folder of your project (where the AppDelegate, main.m etc are located). Do not add the copied empty Foo files to the project. Make sure to remove the ' copy' added to the file name.
3. Open the original Foo class file in Xcode and add a method, -(void)bar
4. In the ViewController.m, #import "Foo.h", in viewDidLoad, alloc/init a Foo, then call -bar.
5. Try to build. It will fail. If you look in the preprocessor output, it's loading the empty Foo files located in the root folder of the project.

Expected Results:
Xcode should ignore the duplicated file in the root folder of the project and build using the one referenced in the .pbxproj

Actual Results:
Xcode will load the file in the root folder of the project instead of the one specified in the .pbxproj

Regression:
Yes. This is not a problem in Xcode 4.6.2 or 4.6.1

Notes:
Attached is a sample project that demonstrates this issue. The User class has a property and a single method on it, yet when the project is compiled the wrong file is used.

Comments

Related to: http://openradar.appspot.com/radar?id=3120409

By michele.titolo at June 18, 2013, 6:52 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!