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

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

Related

How do I prevent xcodebuild in Xcode 9 from creating extraneous metadata files?

After the upgrade to Xcode 9 on our TeamCity-based CI Server, xcodebuild no longer exports ONLY the .ipa artifact. It now also creates three meta-data files that I'd prefer it not create.
com.mycompany.ourapp.ipa
DistributionSummary.plist
ExportOptions.plist
Packaging.log
Is there a way to tell xcodebuild I only want the .ipa? I could of course delete the three meta-data files in a post-build shell script, but it'd be cleaner if xcodebuild never created them in the first place.

xcodebuild setting parameter equivalent in Xcode GUI build?

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.

iOS test target build breaks, library not getting built for right architecture

My project contains two targets, the main application and a separate target for testing. The main target builds no problem but the test target fails with the following linker warning:
"ld: warning: ignoring file .../libj2objc_main.a, file was built for archive which is not the architecture being linked (i386)"
It seems like this is a common problem, and there are several posts that deal with solutions, from setting the "Build Active Architectures Only" flag to No (or is it Yes?) to using shell scripts to force Xcode to build a fat binary. (Using lipo I've confirmed that the compiled .a file only contains the x86_64 binary.) It's really bizarre that when I create a new test target and run the default XCTest suite everything builds fine, but if I attempt to add the Pods config file to the test target in Info -> Configurations and run the tests again everything blows up. This has never been a problem in other projects.
My question is why is this only failing for the test target? I'm using the same architecture in both the regular and test builds, so why is the .a only being a problem in the latter case?
So it turns out that the reason things weren't building was because (unbeknownst to me) my team was manually managing the header search paths. I'd encourage anyone working on a team to check the header search paths inside the primary target and see if they're all being added individually. If they are, you'll similarly need to add any test-specific headers manually in your test target.

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.