Xcode 3.2

Shark and Java on Snow Leopard

In my research for the Shark chapter of the new edition of the Xcode book, I had a difficult time getting Shark to profile a Java program in Snow Leopard. I’m writing this post to spare others my pain.

For Java profiling to work with Shark, you must link Shark with the Java virtual machine. To link Shark with the Java virtual machine, you must add the following flag to the virtual machine:

-agentlib:Shark

Profiling with Shark on Snow Leopard is complicated by the fact that Snow Leopard initially uses the 64-bit version of the Java virtual machine. Shark does not work with 64-bit Java applications. You must use the 32-bit version of the Java virtual machine to profile with Shark. Add the following flag to the virtual machine

-d32

If you’re using Xcode 3.2 to write your Java applications, you must add the flags to the build.xml file Xcode includes when you create a Java project. Search build.xml for the </java> tag and add the flags before that tag.

<jvmarg value="-d32"/>
<jvmarg value="-agentlib:Shark"/>

At this point you’ll be able to use the Java Time Profile and Java Call Trace profiles. You won’t be able to use the Java Alloc Trace profile because Snow Leopard uses JVM 1.6, and the Java Alloc Trace profile doesn’t work with it. You will have to install JVM 1.5 to use Java Alloc Trace.

No comments | Trackback

Xcode 3.2: Renaming Projects

Xcode 3.2 added the ability to rename projects. Choose Project > Rename Project.

RenameProject.png

Xcode is set to rename all files in the project that are based on the project name: project file, targets, build products (application name is an example), precompiled headers, and property lists. If you want to keep the old name for some files, deselect the checkbox in the left column.

Comments (2) | Trackback

Reading Third-Party Documentation in Xcode 3.2

Apple supplies documentation sets that let you read Mac OS X, iPhone, and developer tools documentation in Xcode. But you are not limited to reading Apple’s documentation in Xcode. This post shows you how to install and read third-party documentation in Xcode.

Xcode has one requirement for third-party documentation sets. The documentation set must be either an RSS or Atom feed. If you want an example of a documentation set, the cocos2D game engine has an Atom feed at the following URL:

http://aptocore.com/downloads/cocos2d/cocos2d-iphone-doc.atom

Opening Xcode’s Documentation Preferences

Open Xcode’s preferences by choosing Xcode > Preferences. Click the Documentation button in the Xcode toolbar window. The Documentation button is on the far right. You’ll have to use the scroll bar to get to it unless you have a very wide monitor. You should see the documentation sets on the left side of the documentation preferences.

Documentation Sets.png

Adding a Documentation Feed

Click the Add Documentation Set Publisher button. You will be asked for a feed URL. RSS feeds start with feed:// while Atom feeds start with http://. Click the OK button when you’ve finished entering the feed URL.

Installing the Documentation

After adding your documentation feed, it should appear in the list of available sets. Click the Get button to install the documentation in Xcode.

Reading the Documentation

After installing the documentation, open Xcode’s documentation window by choosing Help > Developer Documentation. Click the Home button in the documentation window toolbar. A menu with a list of installed documentation sets opens. The documentation set you installed should be one of the menu choices. Choose it to read the documentation.

Removing the Documentation

To remove documentation you installed, open Xcode’s documentation preferences. Select the documentation set from the list of available sets. Right-click and choose Reveal In Finder. Drag the documentation set to the Trash.

No comments | Trackback

Xcode 3.2: New Project Assistant

Xcode 3.1 changed the way you pick a project template when creating a new project. Previous versions of Xcode had a list of all installed project templates for you to choose. Xcode 3.1 filled the left side of the New Project Assistant with project categories like Application and Framework. Selecting the category filled the top of the New Project Assistant with the project templates in that category.

Xcode 3.2 makes further changes. Suppose you’re writing a Cocoa application in Objective-C. In Xcode 3.1 you could choose from the following templates:

  • Cocoa Application
  • Cocoa Document-based Application
  • Core Data Application
  • Core Data Document-based Application
  • Core Data Document-based Application with Spotlight

In Xcode 3.2, you have one template: Cocoa Application. There is an Options section with checkboxes for document-based applications, Core Data, and Spotlight importer.

NewProjectCocoaApp.png

The screenshot provides a hint on how to create a command-line application in Xcode 3.2. Select Command Line Tool, and the Options checkboxes are replaced by a Type pop-up menu. Use the Type menu to pick the language: C, C++, or Objective-C. Choose Foundation to write an Objective-C command-line application.

No comments | Trackback

Interface Builder 3.2: Outlets and Actions

In previous versions of Interface Builder, you used the identity inspector to add outlets and actions to a user interface element. Interface Builder 3.2 moved this functionality to the Library. If the Library window isn’t open, choose Tools > Library to open it. Click the Classes tab in the Library window. Select a class. Use the Outlets and Actions tabs to view, add, and remove outlets and actions for the selected class.

InterfaceBuilderActions

No comments | Trackback

Xcode 3.2: Project Templates Removed

In Xcode 3.2 Apple removed all Carbon project templates as well as the Cocoa projects that used Python and Ruby. You can install Xcode 3.1 alongside 3.2 if you need the templates Apple removed. Apple doesn’t officially support Xcode 3.1 on Snow Leopard, but Xcode 3.1 can be installed and run on Snow Leopard. If Xcode 3.1 doesn’t work well for you, you can copy the project templates to the user templates location so you can use them in Xcode 3.2. Refer to this blog post from the old blog for more information on where the templates should be copied.

The PyObjC and Ruby Cocoa websites are the places to visit for the latest Python and Ruby project templates. For those of you interested in writing Cocoa applications in Ruby, Mac Ruby is another project to check out.

No comments | Trackback

Xcode 3.2: Creating Java Projects

In Xcode 3.2 when you choose File > New Project, there are no Java templates in the New Project Assistant. To create Java projects you must open the organizer by choosing Window > Organizer. At the bottom of the Organizer, you will see three buttons.

OrganizerBottomBar

Click the + button on the left and choose New From Template > Java Templates to create a Java project. Click the right button at the bottom of the Organizer to show the editor. Use the editor to write your code.

Comments (1) | Trackback

Xcode 3.2: Changing the Organization Name

In Xcode 3.2 Apple made it easier to change the organization name so the copyright notice at the top of newly created files doesn’t say __MyCompanyName__. Choose Project > Edit Project Settings and click the General tab in the inspector. At the bottom of the inspector is a text field to enter the organization name. This name will appear in the copyright notice for any new files you create for this project.

OrganizationName

No comments | Trackback

Xcode 3.2: Where Did the Build Transcript Go?

The build transcript lets you see the details of how Xcode built your project. If you upgraded to Xcode 3.2 and looked at the build results window, you noticed the group of four buttons that let you open the build transcript was missing. How do you access the build transcript?

In the build results window you should see a listing for each step in the build. At a minimum, you shoud see one listing for each source code file in your project. Selecting a listing displays the build transcript button on the right side of the window. In the screenshot below, you can see the build transcript button next to the icon saying the file GameApp.cpp has 6 warnings.

BuildResultsWindow

Click the button to see the build transcript.

BuildTranscript

If a step in the build process generates errors or warnings, the build transcript button appears automatically.

No comments | Trackback
Powered by WordPress