May 26, 2011

Command Line Building using Xcode

Posted in Uncategorized at 8:42 pm by tetontech

Most professional software development companies or professional software organizations within companies eventually need to be able to build their products from the command line as part of an automated build process.  Usually this is proceeded by doing a pull from a software repository.  Often such builds are done at night or during other off-time hours.

This posting will not cover the use of git or other repositories.  It will cover the use of the terminal to build an Xcode project in Xcode 4.  Most of this information has been gleaned from examining the man page of xcodebuild.  You can see the help for xcodebuild if in the terminal you enter man xcodebuild.

Getting the version of xcode

Often in scripts a check of the compilation tool version is done to ensure correct compilation.  This is done by calling xcodebuild -version

Listing available sdks

                It is possible that you may need your script to check for a specific SDK version prior to triggering a compilation of your code.  This uses the xcodebuild -showsdks call.

Listing available schemes in a workspace

               If you have a workspace that has many projects in it t is, again, wise to check if a scheme for the project you want to compile exists.  Each project has a scheme, by default, in Xcode 4.  Here is the call to list schemes available in a workspace.  xcodebuild -list -workspace <full path to workspace file>
                The example shown here lists the schemes from the Examples.xcodeworkspace found in the QuickConnect 2.x download.

Listing available targets in a project

                If you are using a project that is or is not independent of a workspace your script may need to check to make sure that the correct target is available in the project since a project can have any number of targets.  The command to list targets is xcodebuild -list -project <full path to project file>
The example here lists the targets available in the File List project as well as the build configurations available.

Building all projects in a workspace

                To do this you would need to call each project individually or, and this may or may not be much better in the case of you projects, build dependencies into the xcode projects and then trigger the building of them all by building the topmost build.  This would be the one that has dependencies on the others.

Building a project in a workspace

                To do this what you really do is to either build the project directly without the workspace involved (see Building a project that is not part of a workspace below) or build the workspace with a scheme that is specific to your project.  The example shown here is for the second case.  This example builds the File Reader scheme that is part of the File Reader project of the QuickConnect Examples workspace.  I have removed the build output since it had sensitive information regarding the directory structures on my working machine.  The command to build a scheme in a workspace is xcodebuild -workspace <path to workspace file> – scheme <Scheme Name>.

Building a project that is not part of a workspace

                Maybe you need to compile a project without it being in a workspace.  If have cd’ed into the directory and the project is the only xcodeproj file in the directory the command to do this is xcodebuild.  If you are not in the directory the command is xcodebuild -project <path to project>.
                The example shown here is an example of the first.  I have again removed the build results because of the sensitive data exposed regarding the file structure on my machine.

There are many more options available with xcodebuild.  Check out the man page to learn more about targeting platforms, SDK versions, etc.

May 11, 2011

iPad and Showing the camera in Objective-C

Posted in iPhone development tagged , , , , , at 5:57 pm by tetontech

So here is a hint for using the camera with the iPad.

The iPad allows the camera view to rotate as the orientation of the device changes.  Imagine this set of views.


———-> base view

—————> subview

————–> camera view

If you display the camera from the subviews’ view controller the camera views’ control bar and the orientation of the camera view itself will only be correct if  the device is in portrait-right-side-up orientation when the camera view is displayed.  In any other orientation the camera view will be displayed incorrectly and this orientation error remains as the device orientation changes.

If the set of views is like this the camera view will be displayed correctly regardless of the original orientation of the device.  It will remain correct as the orientation of the device changes.


———-> base view

—————> camera view

So here is a rule for showing the camera via the UIImagePickerControllerDelegate class.

“The view controller that displays the camera must be controlling a view whose superView is the main window if the controlled view auto rotates.”

%d bloggers like this: