xcodebuild setting parameter equivalent in Xcode GUI build? - xcode6

I have an Xcode workspace. The workspace has multiple projects. Each project has at least 1 target.
The command xcodebuild allows you to add setting parameters on the command line. These settings are passed to all targets.
For example, I can build everything in the workspace by doing this:
xcodebuild -scheme KitchenSink build BOB=newhart
And the setting BOB=newhart will be passed to every project.
What is the equivalent of this when choosing Product | Build from the Xcode menu bar (pressing Command+B)?
Some points:
I would prefer not to edit every project.
I created an xcconfig file named "Global", but how do I get the Xcode build process to use it for all targets?
The Build section when editing a scheme does not contain a way to attach xcconfig files.
When I select Global.xcconfig in the Navigator pane, and look at the File Inspector in the Utilities pane, I do not see a way to add that file to any targets.
The xcconfig file is only part of the workspace. It is not part of any 1 project.
I'm not certain the use of xcconfig files is how to accomplish what I want; I'm just explaining what I've tried.

Related

qtcreator can only build all not each single targets for cmake projects

I use cmake to generate qtcreator's project files, For the run part I can have different targets, but the build parts, I can only select all, and could not build each targets separately. Is there anyway I can build only one targets with qtcreator's cmake projects?
Since QtCreator 4.0.0, on Projects pane, go to build steps -> Details and select your target.
You can also use the "--target" command line option with cmake.
Update:
Since QtCreator 4.3.0 with CMake 3.7.2 or greater the list of targets is on the project view, so you can just right click and build.
With QtCreator 4.0+ it is is possible, see rboc's answer below.
Old answer
I believe this is currently essentially impossible. I say "essentially" because if you wanted to, you could make a custom build configuration for each target you want to create, manually specifying the target as an argument in the command for that configuration. Then, to build that target, simply select that configuration and build. This is an extremely hacky workaround, but unfortunately I think it's the only viable option at the moment. A better solution might be to create a separate project for each target.
One can configure QtCreator to build the target that is currently selected for running, which IMHO should be the default.
To do so, navigate to the "Projects" pane, then in your Kit's "Build" tab, locate the "Build Steps" section. Remove all existing build steps by clicking on the cross.
Add one "Custom Process Step". Fill the "command" field with "%{CMake:Executable:FilePath}", the "arguments" field with "--build . --target %{CurrentRun:Executable:FileBaseName}" and the "working directory" field with "%{buildDir}" (all without quotes).
Tada!

Xcode4, I've created a new scheme for adhoc, unlinked a library, but the build seems the same size?

I'm trying to automatically exclude a library from my release build, but have it present in my adhoc build.
I've found the file build file under ~/Library/Developer/Xcode/DerivedData
I've deleted them, between builds, to make sure they were getting created as the modified date was the same. However, the build is the same size...
Remove from the libaray target.
Make AdHoc build configuration by copying the Release build configuration.
Add -lTestFlight in the other linker flags section of AdHoc build configuration.
Taken from http://d.hatena.ne.jp/basuke+en/20111122/1321924385
Any ideas ?
You can easily manage this by looking at your Build Target in XCode.
Select the one which you do not want to contain the library then click Build Phases and under the sections
Link Binary With Libraries
Copy Bundle Resources
You should be able to remove the unwanted library for that particular build.

Adding dependent project in XCode 4

I am trying to add a dependent project in XCode 4. The link to the project is this: https://github.com/jverkoey/ObjQREncoder
The author described a way to add this but it's for XCode 3. I am trying to add it to XCode 4.
I dragged the project inmy frameworks, then went to Targets and QREncoder in Target Dependencies. Then I added libQREncoder.a in "Link Binary with Libraries". Then I added this for header search path "src/Classes".
When I include "QREncoder/QREncoder.h", it gives me this error: file://somePath/FINALQRAppDelegate.m: error: Lexical or Preprocessor Issue: 'QREncoder/QREncoder.h' file not found
This is how my project is set up:
FINALQR is my project to which I am trying to add the dependency and the dependency project is in src.
Thanks.
The problem is it doesn't recognize the QREncoder class.
Only Xcode 4 workspaces benefit from shared build folders across multiple projects. From the main menu, select File > New > New Workspace... Save the workspace, then drag your subprojects into its Project navigator panel.
Be careful where you place them (make sure you're not making one project a subproject of another within the workspace) so that they're all top-level projects within your workspace. This will cause them to share the build folder and automatic dependency detection should work.
Unless, of course, you have custom search paths set in your targets' build settings. :-)
I think your problem is you need to set the following as your search path:
"$(SRCROOT)/src/Classes"
not
"src/Classes"
If you already have an Xcode4 project, you should be able to drag QREncoder into it as a subproject, as I think you have already done, and then add the .a file, also as you've done.

How do I archive multiple targets with one action in xcode 4

I have a project with multiple targets that are all for different iOS Apps. For instance one traget for the lite version and another one for the pro version.
I want to build and archive all of my Apps at once. Currently I have a scheme for every target which I use to archive each app independently. But now I have to start the archiving, wait until it is done and then start the next one.
Is there a way to archive all apps with one single action in xcode 4 or using the command line?
The Build action in a scheme dictates what targets are built for what actions. Leave the defaults (so they'll all be built for the Archive action). When that scheme is active, it'll build all the requested targets just prior to archiving when you select Product -> Archive.
You could create a new scheme called "All", edit it, then in its Build action, add all targets you want to archive. Then just select that scheme and ask it to archive.
Alternatively, add all targets to your existing scheme and uncheck unwanted actions for which it should build those extra targets, leaving only Archive.
You can use xcodebuild from the commandline
e.x.
xcodebuild -configuration Release -project MyProject -scheme MyProjectScheme clean build
Also you can use xcrun to build an ipa from the commandline as well, see:
https://stackoverflow.com/a/4198166/618419

Xcode 4 - build output directory

I have problems with setting up/locating my output files in Xcode4 (beta 5). They are placed somewhere in ~/Library/Developer/ugly_path/.... I can't even select "show in finder" on my products. It is the same for a simple C project, Foundation tool and even Cocoa bundle. A Debugging works fine.
Could you please point me out where and how to set up / build output directories? (I know it sounds dumb, I've been coding in Xcode3 for months, but I can't figure it out in Xcode4 beta).
Thanks a lot.
From the Xcode menu on top, click preferences, select the locations tab, look at the build location option.
You have 2 options:
Place build products in derived data location (recommended)
Place build products in locations specified by targets
Update:
On xcode 4.6.2 you need to click the advanced button on the right side below the derived data text field. Build Location select legacy.
If you build from command line, you can set output directory in the following way:
xcodebuild -workspace 'WORKSPACE_NAME.xcworkspace' \
-scheme 'SCHEME_NAME' \
-configuration 'Release' \
-sdk iphoneos7.0 CONFIGURATION_BUILD_DIR='OUTPUT_DIRECTORY'
In Xcode 5: Xcode menu > Preferences... item > Locations tab > Locations sub-tab > Advanced... button > Custom option.
Then choose, e.g., Relative to Workspace.
If you have Xcode 4 Build Location setting set to "Place build products in derived data location (recommended), it should be located in ~/Library/Developer/Xcode/DerivedData. This directory will have your project in there as a directory, the project name will be appended with a bunch of generated letters so look carefully.
Keep derived data but use the DSTROOT to specify the destination.
Use DEPLOYMENT_LOCATION to force deployment.
Use the undocumented DWARF_DSYM_FOLDER_PATH to copy the dSYM over too.
This allows you to use derived data location from xcodebuild and not have to do wacky stuff to find the app.
xcodebuild -sdk "iphoneos" -workspace Foo.xcworkspace -scheme Foo -configuration "Debug" DEPLOYMENT_LOCATION=YES DSTROOT=tmp DWARF_DSYM_FOLDER_PATH=tmp build
You can always find the build directory by looking in the build log viewer, and copying the path there into a terminal window.
I use this to analyze my iOS .app bundles before they get installed to make sure no stray files are being included.
For anyone who wants to find the build directory from a script but does not want to change it, run the following to get a list of all the build settings that point to a folder in DerivedData:
xcodebuild -showBuildSettings | grep DerivedData
If you run custom targets and schemes, please put them there as well:
xcodebuild -workspace "Foo.xcworkspace" -scheme "Bar" -sdk iphonesimulator -configuration Debug -showBuildSettings | grep DerivedData
Look at the output to locate the setting output that you want and then:
xcodebuild -showBuildSettings | grep SYMROOT | cut -d "=" -f 2 - | sed 's/^ *//'
The last part cuts the string at the equal sign and then trims the whitespace at the beginning.
If you use the new Xcode4 Workspaces, you can change the Derived Data Location under File -> Workspace settings...
You can configure the output directory using the CONFIGURATION_BUILD_DIR environment variable.
Source: http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/0-Introduction/introduction.html#//apple_ref/doc/uid/TP40003931-CH1-SW1
Another thing to check before you start playing with Xcode preferences is:
Select your target and go to Build Settings > Packaging > Wrapper Extension
The value there should be: app
If not double click it and type "app" without the qoutes.
This was so annoying. Open your project, click on Target, Open Build Phases tab. Check your Copy Bundle Resources for any red items.