On Mar 12, 2009, at 3:45 AM, Justin Li wrote: Hi all,
I use Mac os and Xcode now. I am using C++ not Objective-c.
Here is my step:
- New Project -> Command Line Utility -> C++ Tool -> Save as avs
- Delete the original main.c (because I already have a MS project which include source files and header files)
- Ctrl+Click on Source in the Group & Files window. Add the exist source files (.c files in my original MS project) into Source directory.
- Next, if I want to add the header files, where should I put these .h files in new Xcode project?
Besides, if the header files are added correctly, do I need to add make file (for Linux compile) or solution file(for MS compile) to this Xcode project? Or, just source files and header files are OK for compiling? Finally, what is the Targets item in left window of Xcode for?
Hi Justin,
Before answering your questions, there is something you might do that will make things clearer. Make a new Xcode Command Line Tool. Don't change anything in it, just build it and run it using Run | COnsole so you can see the output. It should just work. Click the disclosure triangle next to the Target name, then do the same for the "Compile Sources" list item (these list items are called "Build Phases"). This is the list of files to be compiled. Other phases perform a similar function, and more complicated project types contain more phases.
Now for your questions:
You don't need to add the headers to the project at all, but I usually do because then I can access them easily for editing.
Try this: 1. Ctrl-click on the project name at the very top of the "Groups and Files" window. 2. Select Add Group 3. Rename the group to "Headers" 4. Ctrl-click on the Headers group and select "Add", then "Existing Files..." 5. Pick all of your header files 6. In the dialog that appears, you can deselect the target if you wish. Then the header files won't be associated with it, but you can still edit them.
However, your target should build (and maybe get errors) even if you don't add the header files, as long as the include search path is set up correctly.
You certainly don't need to add any makefiles for the type of project you have described.
As far as Targets go, maybe this will help. Think of an Xcode project as being like a Visual Studio solution, and think of the Xcode targets as being VS projects. The way you edit the build settings for a Target is to double click it, then edit in the Build pane. Sort of like editing the Properties in a VS project, but thankfully all on one page with filtering capabilities. Also, you can use Xcode config files to control all these settings, so you can maintain uniform build settings across your projects. The closest Visual Studio analog to this is to use inherited Property Sheets, but it's more powerful in Xcode because you can configure everything with config files.
Best regards, Rush |