Using Xcode to develop in Cappuccino

After the creation of Objective-J, one of the first things Francisco did was write a new mode for his favorite text editor, SubEthaEdit. It was immediately obvious that we should try to make our favorite development environment as productive as possible.

A lot of people working with Cappuccino are coming from the Cocoa world, which means they’re almost universally developing in Xcode. We’ve had several requests for writing tools to integrate well with Xcode, but we just haven’t had the time. Thankfully one of our users, Raphael Bartolome, took it upon himself to build a great new Xcode plugin specifically for Cappuccino!

If you’re an Xcode user, go ahead and download the plugin now, and we’ll take a look at how it works. When you first launch the installer package, you’ll be greeted with a welcome screen. Click continue, and you’ll be presented with three options:

xcode setup step 1

You should make sure the first option is checked, so that the build tools will be installed. Be aware that this will overwrite any existing build tools installation, so if you’ve installed tools off trunk, you may want to uncheck this. The second choice will pull the latest source from GitHub for creating new projects, and the final option installs all the Xcode extras that you’ll want on your system.

Once you’ve finished installation, open Xcode, and go the new project wizard (cmd-shift-n). Choose “Web” under Mac OS X on the left hand side, and you’ll see two Cappuccino Project templates.

xcode setup step 2

The first option is an empty project that puts “Hello Cappuccino” on the screen using a CPTextField, just like NewApplication in the Cappuccino starter package. The second creates a project that includes a “CIB”, the Cappuccino Interface Bundle. CIB based applications are not yet supported, so this won’t be useful to most people just yet, but if you’ve been playing around with nib2cib, or are developing CIB technologies, you may want to use this template. Once you’ve selected your template, go ahead and finish creating the project. You’ll be greeted with a new Xcode window that looks something like this:

xcode setup step 3

You’ll find AppController.j in the Classes folder, and your other, mostly standard, files in Other Sources. Even the documentation is directly accessible in the navigation on the left, to help you look up API questions and get answers quickly. Finally, the coolest part of all — click Build & Go, and you’re Cappuccino project will automatically be bundled together and loaded in your default Browser.

Now you can edit in style with syntax coloring, (basic) code completion, and many of the other powerful features Xcode offers. Thanks again to Raphael for this exciting contribution to Cappuccino! If there’s some feature you’d like to see in the next version of the plugin, post it to the comments.

Update: I should have mentioned that it requires Xcode 3.1. The developer is working on support for earlier versions.

Tags: , ,

  • marius

    Thanks, Raphael ;-)

  • Dave

    Is there something that one must do for this package to work with Xcode 3.1 for iPhone?

    http://img.skitch.com/20081002-3xnehbyh2p6a9uph…

  • Raphael

    No, this is am known Bug, i'm not 100% eure why the Syntax coloring sometimes not work.
    If you open the file again it works normaly.
    Try to fix it in the next version!
    Their are more open fixes for the next version.

    -raphael

  • Raphael

    Thanks! :-)

  • Andrew

    I have noticed since 3.1 Xcode syntax coloring has been kind of hinky in general.

  • http://steventroughtonsmith.blogspot.com/ Steven Troughton-Smith

    Very nice work here, going to enjoy this a lot.

  • Miles T

    Whenever I “Build and Go”, only the AppController.j is packaged into the debug build. That is to say, my other classes never appear in the debug build folder. Once I copy and paste the missing classes, the app runs fine.

    I am new to Xcode and feel like I am missing something obvious…!!

  • boucher

    I've also run into this. Raphael, any suggestions?

  • Miles T

    Hey, I have just worked out the solution. In the Groups & Files list, you need to drag the new classes you have created (i.e not AppController.j) into the Sources folder of your app in the Targets section. I think this just tells the compiler to include the new files when it builds you app. Although, I am sure someone can explain it much better! It works though :P

  • http://web.mac.com/raphaelbartolome Raphael

    Hi,
    yes this is the solution, normaly the xcode project copies by default the file into the right
    build phase.
    Currently you have to copy the files into the target where it has to be after the build.

    For example you create a new j source file you have to drag the file inside Source and so on.
    I work on a version that filter the files and copy it to the right target.

    -raphael

  • Tim Henrion

    After installing this on XCode 3.1, Build and Go would not work on a created skeleton app created from New Project. I debugged this down to the /Developer/Cappuccino/Frameworks directory being empty after the install. I copied all of the folders from the Frameworks directory in the “Starter” ZIP file to this directory, re-generated the project and this seems to work.

  • Glenn Rempe

    I also had problems with this (as a cappuccino newbie).

    First problem, this seems to install and entirely separate installation of Cappuccino than the one that is installed by downloading and installing as recommended on the download page. This XCode tool seems to install to /Developer/Cappuccino and the official install goes into /usr/local/share/objj and /usr/local/bin. Can you make it so that the Xcode plugin uses the same installation?

    Second problem is that you installer seems to install all of your tools under /Developer/Cappuccino as root owned and rwx permissions for ALL users. This should clearly be more restrictive.

    As mentioned by someone else, the /Developer/Cappuccino/Frameworks dir is empty by default. So even the sample project template as generated by Xcode does not work when you do build and go.

    I think its an awesome start. I look forward to the next version that hopefully clears up the remaining issues. Is there a project home page for this new tool?

    Thanks!

  • http://www.memoryminer.com/blog John Fox

    Hi Folks:

    The Xcode plugin is a glorious thing, but I'm having a bit of trouble with one thing. In my Xcode preferences, I have it set so that closing brackets are automatically added, and the tab key will indent any selected text. For some reason, these preferences don't work for Cappuccino projects.

    Here's a quick screen movie that demonstrates what I'm talking about:

    http://memoryminer.com//video/XcodeCappuccino-w…

    Is this a known issue, or is there something I can do to help fix this?

    I would very much love to use Xcode to both edit, and build (including bake).

  • j4johnfox

    Hi Folks:

    The Xcode plugin is a glorious thing, but I'm having a bit of trouble with one thing. In my Xcode preferences, I have it set so that closing brackets are automatically added, and the tab key will indent any selected text. For some reason, these preferences don't work for Cappuccino projects.

    Here's a quick screen movie that demonstrates what I'm talking about:

    http://memoryminer.com//video/XcodeCappuccino-w…

    Is this a known issue, or is there something I can do to help fix this?

    I would very much love to use Xcode to both edit, and build (including bake).

  • http://cocoadevblog.wordpress.com/2008/11/16/xcode-and-cappuccino/ Xcode and Cappuccino « cocoadevblog

    [...] and Cappuccino Not so long ago, I have write a Xcode Plugin for Cappuccino. The problem is time. The latest version is not really up-to-date but I can see a lot of people who [...]

  • http://www.pomcast.com stuffmc

    Is this Plugin being updated one day? :-)

  • bensyverson

    I'm anxious to see an update too… Currently, the skeleton apps bail with errors.

  • http://DavesDailyDose.com dparizek

    Any way the source of the plugin could be released or open sourced so that others can add to it?

  • boucher

    Another user contributed a new xcode plugin, which is in the source
    repository. It should be a lot easier to extend, but it doesn't do
    quite as much as the old one just yet.

  • beefon

    Thanks!! Great!!!

  • odotash

    Hi,

    I tried to add the tools to Xcode 3.2 under Snow Leopard.
    The folders in the Developers/Cappuccino stay empty.

    Is it mine bad manipulation or the Cappuccino_Developer_Tools.pkg is not compatible with those versions ?

  • boucher

    It's probably not compatible. You might want to try the newer plugin
    that's in the github repository.

  • robde
  • Klaus

    Is there anybody out there, who got the xcode plugin to work properly with Snow Leopard and xcode 3.2.1? I extracted the cxhelper from the installer package with pacifist and put it into /Developer/Cappuccino/Tools/cxhelper because the installer does not work.

    I created a new blank Application from New Project.

    But when I hit build (release) I still get an error mkdir /Users/klausk/Klaus-Dokumente/xcode/cappuccino/fourthTry/build/Release/ : File Exists.
    And it Stopps.

    With build (debug) I get hundreds of errors like this:
    2010-03-26 00:07:41.317 fourthTry[42459:903] Argument 0: /Users/klausk/Klaus-Dokumente/xcode/cappuccino/fourthTry/build/Debug/fourthTry
    2010-03-26 00:07:41.337 fourthTry[42459:903] Argument 1: –build
    2010-03-26 00:07:41.338 fourthTry[42459:903] Argument 2: .web
    2010-03-26 00:07:41.338 fourthTry[42459:903] Argument 3: /Developer/Cappuccino/Frameworks
    2010-03-26 00:07:41.339 fourthTry[42459:903] Argument 4: index.html
    2010-03-26 00:07:41.390 fourthTry[42459:903] is it a nib file /Users/klausk/Klaus-Dokumente/xcode/cappuccino/fourthTry/build/Debug/fourthTry.web
    2010-03-26 00:07:41.407 fourthTry[42459:903] recheck check at /Users/klausk/Klaus-Dokumente/xcode/cappuccino/fourthTry/build/Debug/fourthTry.web/AppController.j
    2010-03-26 00:07:41.408 fourthTry[42459:903] is it a nib file /Users/klausk/Klaus-Dokumente/xcode/cappuccino/fourthTry/build/Debug/fourthTry.web/AppController.j

    Then the Browser shows up with a never ending rotating animating gif.

    Any ideas?

    It´s not clear to me, where all the different files, packages, frameworks, libs and tools should go.
    As I understand xcode should assamble it alltogehter into the build folder.
    A tutorial where I have to put what files and the exact location or URL where to get them would be nice.

    Thanks

  • http://twitter.com/MySchizoBuddy Ziyad Saeed

    shouldn't xcode support be top prority? right now it looks like it's up to the mercy of third party developers.

  • bfrolicher

    hello,

    I have some problems with this plugin.

    First is corrected (problem with cxhelper : use pacifist to extract cxhelper)

    but i can't resolve the second problem :

    Xcode say

    “mkdir: /Users/BiB1/Documents/Cappuccino/firstApp/build/Release: File exists”

    Any idea ?

    thank you in advance

    Ben

  • http://www.facebook.com/sven.resch Sven M. Resch

    Would really like to see installer working with xCode 3.2.1 on Snow Leopard as well. Under /Developer/Cappuccino the frameworks and tools directories are empty. Selected all 3 options in the installer. Resulting new project will not build.

  • http://www.facebook.com/sven.resch Sven M. Resch

    Installed and ran successfully with 3.2.2 on Snow Leopard.

    - Install cappuccino first following http://github.com/280north/cappuccino/
    - Install cappuccino-xcode next following http://github.com/rbartolome/xcode-cappuccino/
    - Create a project in xcode and build|run.

  • http://twitter.com/Logicopolis Sven Resch

    Just did a build|run of an empty project and then added some widget using Interface Builder. Very impressed to see the result of a build|run again afterwards.

    Looking forward to trying this out more.

  • louisk2

    Hi all, this blog post is out of date. Don't use the installer package noted in the article.

    Grab the new Xcode Template from the following link and follow the installation instructions in the download.
    http://github.com/rbartolome/xcode-cappuccino

    A few notes on my experience in getting the templates to work correctly.

    1. I would recommend copying the folders into the /Library/Application Support/Developer/Shared/Xcode folder rather than your ~/Library… to avoid permissions errors.

    2. If you intend on using images and setting them in your object attributes in the nib, you MUST do the following:

    2.1. Name all of your image attributes with their extension (ex a button image will be “add.tiff”). This will cause IB to display a (?) in the simulated interface, but don't worry it will appear in cappuccino.

    2.2. Alter the Build Script in Xcode to tell the nib2cib converter where your image resources are. To do this go to your build targets, and open the Build Application script. Go to line 178, and change it to this:

    test $xibFile -nt $cibFile && nib2cib $xibFile -R ./Resources/ || echo “- Interface Builder File '$cibFile' is up-to-date”;

    Do the same for line 185

    test $nibFile -nt $cibFile && nib2cib $nibFile -R ./Resources/ || echo “- Interface Builder File '$cibFile' is up-to-date”;

    This will save you a HEAP of time, i.e less interface coding.

    Don't forget to use the Build Results window (Shift-Command-B) and enable the script log to see any errors in the nib conversion as they won't appear anywhere else. You'll be scratching your head as to why your interface doesn't update between builds, when you stick in an cappuccino unsupported cocoa object.

  • switcherdav

    Thanks for the tips,

    I installed the version linked here and of course it doesn't works

    Now, I try to instal the new one and create the folder Application SupportDevelopper/Shared/Xcode

    re launch Xcode but it's the same result

    What the first installer do ?
    May I have to re install Xcode ?

    regards

  • http://twitter.com/nacho4d nacho4d

    Did anyone get this working in Xcode 3.2.3? (Or even better in 4.0 preview?)
    It installs without problems, but when I try to build my project, it does not work.I get:

    mkdir: /Users/nacho4d/Desktop/CappuccinoText/build/Debug: File exists
    cp: /Developer/Cappuccino/Tools/cxhelper/cxhelper: No such file or directory
    /Users/nacho4d/Desktop/CappuccinoText/build/CappuccinoText.build/Debug/CappuccinoText.build/Script-643C0D440E7F85EC00F64609.sh: line 4: /Users/nacho4d/Desktop/CappuccinoText/build/Debug/CappuccinoText: No such file or directory

  • Gmugmu

    I am seeing the same thing. Any pointers on how to proceed with XCode?

  • Hallodom

    Yep having the same build error on Xcode 3.2.3.

  • Aman Patel

    I got it working on xcode 3.2.2 (will probably work on newer version). Please see the following post by raphael himself:

    Gist: You have to start again and use the GIT files from the link. Do not rely on the automatic installer.

    https://github.com/rbartolome/…

  • Jigzat

    Mmmm don't take it the wrong way but it is not working under Xcode 4….. yeah I know Apple tends to break up things with every update.

  • akapit

     Dont know what he means with “use GIT files from the link. Anybody can tell me how to make it work?  xcode 3.2 .
    Thanks!

blog comments powered by Disqus

Download

Cappuccino and Objective-J are licensed under the LGPL. For more information, see our licensing page.

Copyright © 2008-2011 - 280 North, Inc. Cappuccino and Objective-J are registered Trademarks of 280 North. Logo by Sofa. Hosting by Slicehost.