Posted by admin on May 15, 2010 in Mac OS X
When working on an Xcode project, it’s really easy to end up with a dozen windows open. You did know that you can close all of them and leave just the main project window open, right?
Just option-click in the close “box” (that’s what we used to call it when it was square, is it the “close circle” now?) of any editor window, just not the main project window. Et voilà — all windows closed.
Posted by admin on Dec 30, 2009 in iPod / iPhone
In Xcode when I just recently launched an app on the device:
0x2fe0104c <+0036> blx 0x2fe01564 <__dyld__ZN13dyldbootstrap5startEPK12macho_headeriPPKcl>
Posted by admin on Sep 8, 2009 in Mac OS X
I’m not sure why Xcode doesn’t support Print Selection like Terminal (and other) apps do. Anyway, I finally got tired of not having this feature and implemented it myself using a shell script. No step-by-step this time — you should know how to do that by now. Just notice the script’s contents, input/output, etc. This specifically prints the selection two-pages-per-sheet and will display an alert with the command output.
Posted by admin on Jun 15, 2009 in Mac OS X
During a recent presentation about Xcode, when the speaker brought up how to create a “snapshot,” my colleague Chris and I both had the same answer:
$ git commit
Posted by admin on Apr 29, 2009 in Mac OS X
I am collaborating on a project right now where multiple developers may be making changes to a single Xcode project. Since in my experience, Xcode project files “don’t merge well,” we have setup git so it treats the Xcode project file (project.pbxproj) as if it were a binary. Consequently, it sucks to have too many outstanding changes to the Xcode project file that have to be merged back in manually. To help shorten the amount of time someone might be working on an out of date Xcode project file, I setup a post-commit hook on the git repository that sends email to the developers in case this particular file changes.
- Add the following “hooks” section to the config file for the target git repository, of course updating the email(s) as appropriate:
mailinglist = email@example.com firstname.lastname@example.org
- In the “hooks” directory in your repository, you should find a file named “post-commit.” Add the following to the file:
git show --pretty="format:" --name-only HEAD | grep project.pbxproj
if [ $? -eq 0 ]; then
mail $(git config hooks.mailinglist) -s "Xcode project changed" <<-EOF
Please pull the latest Xcode project.
- Make the post-commit file executable if you have not done so already.
chmod +x post-commit
That’s it! Piece o’ cake, huh? Anyway, even if my logic regarding the “mergability” (or lack thereof) of an Xcode project is flawed, the principle behind email notification on a single file is still valid. I’m sure generalizing this to notify upon changes to a list of files is easy enough.
Posted by admin on Apr 27, 2009 in iPod / iPhone
, Mac OS X
With some encouragement from my colleagues, I expanded the original post here to be a more soup-to-nuts recipe for setting up CC.rb with git and xcodebuild on Mac OS X. Thanks, guys!
I am currently working on a cross-platform project which has multiple targets that need to build on Mac OS X. On my previous project, we were using CruiseControl.rb on linux to watch a Subversion repository for a Rails project and run all the associated tests upon checkin. Since we wanted to be like the Cool Kids on this new project, we of course decided to use git for source code management. We use gitosis to manage multiple remote git repositories under a single user. However, you can use any approach you want for the remote repository management as long as you can compose a git URL that points to it.
- You have a Mac that is probably not your development machine that will serve as a Continuous Integration (CI) server.
- You have a remote git repository that the CI machine can monitor and pull changes from.
It took a little doing to make CC.rb play nice on Mac OS X. In addition to the typical CC.rb installation, getting CC.rb to launch at system startup using launchd took the proper file in the proper location. Nevertheless, the whole setup is pretty darned straightforward. Here’s how I did it:
- I created a user named “continuousintegration.” You can name yours anything you like, or use an existing user. Log in as this user.
- Download and install CruiseControl.rb. I unpacked it into the the home directory of the continuousintegration user. So, the absolute path to the CC.rb installation directory in my case is:
- Create the work directory for CC.rb. In my case, I use
/var/cruise as the work directory. This required admin privileges to create; just make sure that your CI user has access to this directory.
sudo mkdir /var/cruise
sudo chown continuousintegration /var/cruise
- Add your git repository to CC.rb.
./cruise add <project name> --url <git repository url> -s git
- At the root level of your git repository, add a file named
cruise_config.rb. This provides some useful configuration information so that CC.rb knows what to do in order to build your project as well as whom to notify when the build fails. You provide the build command for CC.rb in
cruise_config.rb by assigning to
project.build_command. I actually made my build command point to
./ci_build.sh so that I can do anything I want for the build in a separate shell script named
ci_build.sh in the git repository root. In my case, I am actually running
xcodebuild to build a target I created in my Xcode project; you can do literally anything you want here, e. g.
make check, rake… whatever! Witness my
ci_build.sh files. (If you create a
ci_build.sh or equivalent file, be sure you make it executable.) Make sure you
git push your changes to add the
ci_build.sh if you choose to do so).
- You should now be able to start up CC.rb and look at the dashboard to see your project.
Browse to http://localhost:3333
- Wait! You’re not finished yet! There’s one more step: setting up CC.rb to start every time the system starts up. This is accomplished by creating a plist file in
/Library/LaunchDaemons which starts up CC.rb. (For more information on what’s going on here, see the Apple documentation or
Download this plist file and copy it into
sudo cp localcruisecontrol.plist.txt /Library/LaunchDaemons/local.cruisecontrol.plist
Now when you restart the CI machine, CC.rb should start up automatically.
Setting up CC.rb all by itself tends to be pretty easy; it’s getting the daemon to run at system startup as well as getting your build to work properly that tend to be the problems. If you’re having trouble getting things running after following these directions, or if you find errors in these directions, please let me know.
Posted by admin on Dec 22, 2008 in Mac OS X
Just got this message from Xcode. Sounds borderline painful.
Posted by admin on Nov 30, 2008 in BMW
, iPod / iPhone
, Mac OS X
I finally made an honest blog out of this thing.
Posted by admin on Jun 26, 2008 in Mac OS X
I was building a new project to do some experiments with wchar_t this morning. (Look here for the reason.) It seemed to me it took way longer than it should simply to get a CppUnit project setup in Xcode with a single test case. (It was primarily due to C++ and pilot error; I gotta say I’m gonna get a cold constantly moving between Ruby and C++.)
Consequently, I have built a skeleton CppUnit Xcode project. This provides you with a single class with a test method which asserts FALSE, demonstrating that the test process is working properly. It’s up to you to do something interesting with this head start.
Prerequisite for all platforms: install CppUnit.
If you’re on Mac OS X, with any luck you can simply build-and-go and you’ll see the results of the test (failure) in the debugger console.
If you’re on Linux, just disregard everything Xcode-related; you can still build and run the code from the command line (see the README file).
If you’re on Windows, gosh I’m sorry. Nevertheless, you should be able to load these files into Visual Studio, set your header search directory to wherever CppUnit is installed, add the CppUnit library to your project, build and run.
Please let me know if you have any problems with this so I can keep it updated and hopefully save others a little time during CppUnit ramp up. Now GO WRITE A TEST!
Posted by admin on Mar 29, 2008 in Mac OS X
I’ve been working in TextMate for Rails development for the past year now. Recently, I’ve been doing a lot of Mac OS X and iPhone development in Objective-C. Of course, this puts me into Xcode for the vast majority of my day.
The one keyboard shortcut I missed the most in Xcode from TextMate was ctrl-shift-D or “Duplicate Lines.” It turns out it’s insanely simple to add this to your Xcode environment.
- In Xcode, go to the Script menu (the stylized S to the left of Help) and select Edit User Scripts…
- Decide where you want to place your new command (I put it at the bottom of the Text menu). Click there. Then click the + menu (lower-left corner of the window) and select New Shell Script.
- Double-click where it says “Shell Script” to edit the name of your new command. Double-clicking to the right of the name allows you to assign a keystroke to the command. I used control-shift-D — same as TextMate.
- The menus should read as follows:
- Input: Selection
- Directory: Selection
- Output: Insert after Selection
- Errors: Ignore Errors
- Now click in the script area of the window and type in the following new line:
Here’s how mine ended up looking:
That’s it! Close the window and enjoy.