Reputation: 1553
I am running Xcode 4.4.1 and this is a pretty noobish question. I can start new simple C++ command line projects and compile fine. However, when I delete the source files from the left pane and drag/drop new .cpp/.h files and hit compile the "old" previous code still compiles and displays in the prompt. I am transferring from VS 2010 and I know this must be a stupid linking oversight on my behalf. How do I simply add source files from elsewhere and compile by just adding to the project?
I know this is a noob question, but I looked around and lost a bit of patience.
Thanks all.
Upvotes: 1
Views: 556
Reputation: 12719
Xcode behaves a lot strangely, and the files displayed on the left may not reflect real file hierarchy, and if something is present it doesn't mean it will be compiled.
You have to check manually each file using the inspector in the right panel to see if it is added to the build, or more conveniently check "Project.xcodeproject/project.pbxproj" or something like that. It's an XML file which maintains informations about all files, folders, and items you add to your project, including what to do with such files.
The file is generated to be human-readable and Xcode gently add a lot of comments :) I think you have to check the first part, where it declares all resources, there's an attribute saying what you want to do with each file.
I hope this will help you :)
EDIT :
You can check a file is included for the current target by selecting it and showing the "File inspector" (alt + cmd + 1
). The info is located in "Target Membership" part, make sure at least one project is checked.
Concerning project.pbxproj, the relevant section is PBXBuildFile, it must be the first one.
Each entry is a reference to a build step, and indicates what has to be done using the isa
field (PBXBuildFile) with what objects (fileRef
).
The fileRef
matches your file in the groups hierarchy below, and in the PBXFileReference section. It's the PBXFileReference section which indicates what kind of file it is (using the lastKnownFileType
attribute).
Upvotes: 2