How to change Xcode build setup without modifying project files? - xcode

I would like to know if it is possible to change compile settings without modifying the xcode projects.
Example, adding -Wno-unused-parameter to CFLAGS in such way that it will be used by Xcode when building projects.
This has to work in both case: build made from xcode in GUI or from the console.
If someone asks about why, let's say that the number of projects is quite big and that you may want to alter the options only temporary.

Put the compiler settings you want to change in a configuration settings file. You can create a new one by choosing File > New > New File. The configuration settings file is in the Other group under both iOS and Mac OS X.
To tell an Xcode project to use the configuration settings file, select the project file from the project navigator to open the project editor. Select the project from the left side of the editor. Click the Info button at the top of the editor. You should see a list of build configurations in the editor. Click the disclosure triangle next to a build configuration to have it use a configuration settings file.

Related

How can I copy build settings from one target to another

I'm building a project with many individual test programs in it; each test program is its own target.
There are a number of settings that each target in "Build Settings" such as several preprocessor macros, and about half a dozen libraries in the "Build Phases" tab.
Every time I create a new target, I have to manually enter those values all over again. Or I can duplicate an existing target and edit its build sources.
Neither solution is easy. Is there any way to simply copy the build settings from one target to another?
Add a configuration settings file to your project. Choose File > New > File to create a new file. The configuration setting file is in the Other section under iOS or Mac.
Put the build settings you want to copy into the configuration settings file. Select your project from the project editor and click the Info button.
Use the Configurations section to tell Xcode to use your configuration settings file. You can find more detailed information on configuration settings files in the following article:
Xcode Build Configuration Files

How to get release configuration back

I deleted all the Release configurations in Xcode and now have only Debug. Is there a way to create another release configuration? I am looking to get Xcode to look like the image below.
There's no way to directly recreate the lost Release configuration.
You have two painful options:
Create a new project and copy all of your files from your existing project to your new project.
Copy the Debug configuration in the project with the missing Release configuration. Name the copy to Release. Then update all of the Build Settings for the new Release configuration.
Option 2 can be done by clicking the + icon just below the screenshot shown in the question. Then select "Duplicate "Debug" Configuration". Give the new configuration the name of "Release". The trick now is knowing what all of the release settings need to be. Create a new dummy project using the same template you used for your actual project. Then select the project and then the Build Settings tab. Choose the "Customized" and "Levels" options. Now scan down the list to see where it shows different values for Debug and Release. Make those same changes in your actual project.
As you can see in the picture below, the Build Active Architecture Only, Debug Information Format, Enable Testability, etc. settings are different between Debug and Release.

What does the Xcode > File > Project Settings actually do?

I recently discovered a handy menu item in Xcode.
There is a menu in Xcode 7.0.1 in File > Project Settings. Its content looks like just what I need ie set the Build folder on a per project basis.
It not exactly the same box as in Xcode > Preferences > Locations
However, even if Xcode seems to pick up the new location and compile in it, I don't see anything changed in the project pbxproj (using a git diff).
I want to commit them inside the project and tell the Continuous Integration server to use the same settings as my developement computer.
So my question is: What exactly these settings do (same as the ones found in locations?) and more importantly where are they stored?

Why doesn't Xcode 4 create any products?

Regardless of build configuration, building my iPad app does not actually output a .app file. It does run in the iPad simulator and on a device, but when I hit build or build and run, the binary appears under Products in red and is not created in the "build" folder as designated in build settings.
Any ideas?
Xcode 4 places its build products and other intermediaries/temporary files/indexes in a derived data directory now instead of a "build" directory that is mixed in with your product files. It does this to deal with the new workspaces and also so that you can have clean builds of different projects in different workspaces without contaminating each other.
If your original template was old, your built product is probably relative to your source directory instead of relative to your built products directory, which is why it's showing up red. By default, your derived data directory will be under ~/Library/Developer/Xcode/DerivedData. To see where your current workspace/project is placing these files, you can File->Workspace Settings... and take a look at the Build Location.
I was having this problem. not only the product .app was red, also simulator wasn't loaded the binary, it was stuck in attaching 'my app'.
i solved it by going to file->project settings. in the tab 'build' changed derived data location to 'project-relative', and in advanced changed build location to 'locations specified by targets'.
with the default options it wasn't possible to run the app, i'm not sure why.
To resolve the issue in XCode 4.x go through following steps :-
Open your project in XCode.
Select .xcodeproj file in XCode project Navigator.
Select the target under the PROJECT Heading. (i.e. the top most target, this target specify your project level build settings)
Now navigate to Build Settings.
Now search for option "Per-Configuration Build Products Path" and update it's value to $(SYMROOT) .

Three20 v1.1 and Xcode 4

Is there an easy way of getting Three20 v1.1 to work under xCode 4?
I followed the steps on http://three20.info/article/2011-03-10-Xcode4-Support but that seems to be for the master. I use v1.1 as I use the TTLauncher.
The project builds fine with a normal build, and runs perfect on an iPhone.
But when I want to create the archive (for the IPA for distribution) then I get 18 errors and 8 warnings.
The first one is:
../scripts/Protect.command: line 23: cd: /Users/XXX/Library/Developer/Xcode/DerivedData/iDoms-cmyivarwxpbvqdfnyclqdrikrtmw/ArchiveIntermediates/iDoms/BuildProductsPath/Release-iphoneos/../three20/Three20UICommon: No such file or directory
Most others are 'no such file or directory' on e.g.:
#import "Three20Core/TTGlobalCoreLocale.h"
or 'undeclared (first use of function)' which comes from the 'no such file or directory issue I presume'.
In my 'Header search paths' I have:
$(BUILT_PRODUCTS_DIR)/../three20
$(BUILT_PRODUCTS_DIR)/../../three20
../../three20/Build/Products/three20
/usr/include/libxml2
Any help would be very appreciated!
Just to add to Colin's answer: you can use Xcode's dependent projects feature to use three20, even though the three20 website says it's not "officially supported":
In your workspace, right-click on the empty space in your project navigator. Select "Add files to "My Workspace", and select the three20 project (three20/src/Three20/Three20.xcodeproj). This is the only project you need to add: it is not necessary to manually add the three20 subprojects.
Select your project in the navigator, go to Build Phases, open "Link binary with libraries", click on the "+" in the bottom left corner, and add the Three20 libraries: libThree20.a, libThree20Core.a, libThree20Network.a, libThree20Style.a, libThree20UI.a, libThree20UICommon.a and libThree20Navigator.a. This will cause Xcode to build Three20 when you build your project.
Add ${BUILD_DIR}/three20 to your include path as per Colin's answer: go to build settings, double click on "Header Search Paths", and add ${BUILD_DIR}/three20 (it will show as build/three20 when you close the dialog).
Add three20/src/Three20.bundle to your resources.
It's probably also a good idea to add the linker flags -ObjC and -all_load if you haven't already done so (same dialog, setting "Other Linker Flags").
The steps above are good enough for compiling the code. To make "Archive" work too, you will need to:
Add $(BUILT_PRODUCTS_DIR)/../three20 and $(BUILT_PRODUCTS_DIR)/../../three20 to the Header Search Paths setting. If you don't you will get compilation errors that the three20 headers cannot be found.
For all Three20 projects (so not just the top-level project), go the Build Settings and set "Skip Install" to YES. If you don't, the project will build, but you will not be able to create an IPA.
Make sure that your product name (select your target, go to Build Settings, then setting "Product Name") does not contain spaces, otherwise archiving will not work.
Finally, if you're getting errors such as ld: library not found for -lThree20 and you are using a custom build configuration (such as AdHoc), make sure to add the same build configuration to each of the Three20 projects too (just duplicate the Release configuration).
You should check out this StackOverflow question.
I've reproduced the accepted answer below:
So it looks like the easiest way
to get old Xcode 3.2 projects to work
with Xcode 4 is to do the following:
Go into Xcode 4's preferences (Cmd+,).
Select the "Locations" tab. Where it
says "Build Locations", select the
drop down and pick "Place build
products in locations specified by
targets" I'll write up a three20.info
article going into more details about
this.
Add these two paths to your header search paths in the build settings for your target:
"$(BUILD_DIR)/three20"
"$(BUILD_DIR)/../three20"
The first entry is needed for regular builds and the second entry is needed for archives.
It's that easy.
Incidentally, to create a file in your home directory with a list of all of Xcode's environment variables for your target's environement, add the following Run script build phase to your target with contents:
ENV > ~/xcode-environment.sh
Note that in this case, if your project is not making it through the compile phase of the build process, and your Run script comes later, the script won't get executed, so put it first.

Resources