问题
I have a few c++ Xcode 3 projects which I need to move to Xcode 4. I have done this by simply renaming the Xcode 3 folder, loading the Xcode 3 project in Xcode 4 and then hitting the modernize button. In the case of some of these projects I cannot build them because the Xcode 4 "Build" and "Clean" menu options are disabled (they are all static libraries so there is no question of running them). I have added some of these ported Xcode 4 projects into an Xcode 4 workspace where they build fine as part of building the entire workspace contents. None the less I will probably need to build these projects independently as well. Any ideas?
Thanks,
Barrie
回答1:
I was getting the same problem with an Xcode 3.2 project when loaded into Xcode 4.2. What solved it for me was changing the "Schemes", which is Xcode 4.2 for "Project Settings." They seem to interpret the settings files a bit differently.
Go to Menu: Product -> Edit Schemes. Note which library is selected in the pulldown menu along the top of the new dialog. You'll probably need make this change for each library. Mine defaulted to all boxes checked & I left it like that.
Click to see Scheme build panel
Along the left column, expand the "Build" block. Select "Build" from Pre-Actions, Build, Post-Actions. Now in the larger right block, you'll see a build target (possibly in red, mine all were).
Click the "+" button at the bottom of this block; it should bring up a list of targets. Select the one you want to build for this library and click "Add". Now you can select the old invalid target and click the "-" button at the bottom to remove it. Click "OK".
After fixing one of these targets, "Build" and "Clean" should become enabled when that fixed library is selected as your current scheme in the upper-left of the main window.
If you have a master project, you want each sub-project set up as a dependency of the master project too. Xcode 4.2 also missed this from the Xcode 3.2 project.
On the main window, bring up the Project Navigator (leftmost icon above left column) and select your master project. To the right, select the target. To the right of that, on the top select "Build Phases." You should get a list below that for your current dependencies. Click the "+" button at the bottom again to add the targets from each project.
Click to see Target dependencies dialog
来源:https://stackoverflow.com/questions/7830444/xcode-4-menu-build-and-clean-options-disabled