Thursday 15 December 2011

Setting up a project in XCode 4.2 with Git and Bitbucket

Xcode now includes a powerful source control client which supports (in fact by default uses) the Git DVCS.

Bitbucket have recently started offering unlimited private repositories (for free!) and now support both Git and Mercurial repositories.

If you're starting a new closed source iOS project and want to store your app source safely offsite but at the same time can't initally afford to pay a fee for the privilege then this is great news.

An hour or so ago, I discovered this great news myself and decided to give it a try. I've had some dealing with various source control systems over the years but up until today I've not had the pleasure of using Git. I've previously been a CVS and Subversion user.

I did a quick google to see if many people were using Bitbucket with Xcode and discovered quite a few threads where people had found issues getting the two to play nicely together, so I decided to have a go myself.

Its quite an easy process in Xcode 4.2, here are the steps:

Step 1: Register with Bitbucket

Step 2: Start a new Xcode project, select the option for Xcode to put your source under version control. It will create a Git repository for your project. You can find the repositories Xcode is managing in the Organizer on the Repositories page.

Step 3: Create a new repository on Bitbucket.  Select Git as the repo type.

Step 4: Bitbucket will show you a command to type to clone your repository locally. We won't use this command but copy the url from the command eg:

https://jumpsource@bitbucket.org/jumpsource/hellobucket.git

Step 5: In Xcode open up the Organizer and switch to Repositories, find your new project's repository. Under your repository name you'll see 3 folders: Branches, Remotes & YourProjectFolder, select Remotes.

Step 6: At the bottom of the screen you'll see the Add Remote option - select it and enter a name for your remote repository and in the URL paste the one you copied from bitbucket in step 4.

Step 7: Click Create, enter your username and password when prompted.

Step 8: You should now have an empty folder in the Remotes view with the name of your remote repository.

Step 9: You now need to Push your local changes to your empty remote repository. To do this, from the menu in Xcode choose: File -> Source Control -> Push. Select the remote repository to push to - if your reading this article there will probably just be one remote - the one you just configured in step 6 & 7. Press Push, Xcode will chug for a bit, then report (hopefully!) that the push was successful.

Step 10: Refresh your page at Bitbucket and you will see your updates.

Wednesday 14 December 2011

Not able to Debug As... Local App Engine Connected Android Application for CloudTasks


I've downloaded the source code for the tutorial above and followed along the Brad Adams Blog but couldn't get the Debug As... option to come up. With some Googling I found this blog by Bill Lahti
which just changed the <nature> contents.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>CloudTasks-Android</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ApkBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
        <nature>com.google.gdt.eclipse.appengine.rpc.appengineConnectedNature
        </nature>
    </natures>


    <linkedResources>
        <link>
            <name>shared</name>
            <type>2</type>
            <locationURI>WORKSPACE_LOC/CloudTasks-
                AppEngine/shared</locationURI>
        </link>
    </linkedResources>
</projectDescription>

Friday 2 December 2011

Error: The RequestFactory ValidationTool must be run for GWT 2.4

When loading up the CloudTasks tutorial as downloaded from the Google website, I encountered the following Runtime error:

SEVERE: Unexpected error
java.lang.RuntimeException: The RequestFactory ValidationTool must be run for the com.cloudtasks.shared.CloudTasksRequestFactory RequestFactory type

I found this article:

http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation

Here's an excerpt:
The RequestFactory annotation processor will validate the RequestFactory interface declarations and ensure that the mapping of proxy properties and context methods to their domain types is valid. The manner in which the errors are reported depends on the method by which the annotation processor is invoked.
In addition to validating the interfaces, the annotation processor also generates additional Java types which embed pre-computed metadata that is required by the RequestFactory server components. Users of RequestFactorySource must also run the annotation processor in order to provide the client code with obfuscated type token mappings. In the client-only case, the server domain types are not required.
If the validation process is not completed, a runtime error message will be generated:
The RequestFactory ValidationTool must be run for the com.example.shared.MyRequestFactory RequestFactory type
In GWT 2.4, RequestFactory interfaces must be validated before they can be used by the RequestFactory server code or JVM-based clients. I followed the instructions for Eclipse as follows:
  • Right-click on Project and select Properties > Java Compiler > Annotation Processing
  • Tick "Enable project specific settings"
  • Then make sure that both "Enable annotation processing" and "Enable processing in editor" are ticked.
  • Go to Factory Path underneath Annotation Processing in the left-hand menu
  • Click the button "Add External Jar"
  • Add the requestfactory-apt.jar file from your Eclipse distribution
  • Press Apply and the project will re-build.
The images on the above link ask you to add this file from GWT_TOOLS, but the text says to use your distribution. I found my file under:

C:\dev\eclipse-3.5.2\plugins\com.google.gwt.eclipse.sdkbundle_2.4.0.relr35v201110112027\gwt-2.4.0

Thursday 1 December 2011

Eclipse Android Library Error: Unable to get system library for the project

I downloaded some code via subclipse from the SVN server of Google to follow a tutorial. However, eclipse didn't know that it was an Android project and wouldn't let me build it as one no matter how many different ways I tried to add the android jar file. I found this great discussion on StackOverflow but this is what was wrong for me:
  • Right click on project > Properties > Android
  • Set Project build target (mine was ICS Android 4
  • Press Apply (I had to press apply 3 times for it to listen to me!)
  • Then go to Build Configuration and set the "Unable to get system library for the project" libraries Native folder to your Android jar (something like  C:/dev/AndroidSDK/platforms/android-14)
  • Right click on project > Android Tools > Fix Project Properties
  • Clean & Build
  • If nothing, try opening and closing the project
  • Also try pressing Apply on the build target some more
Sounds silly, but eclipse can be silly sometimes too!
Obviously check to make sure that you've set the Android SDK location in Window > Preferences > Android. My SDK location is C:\dev\AndroidSDK (not sure why eclipse holds the backslashes here and forward slashes above)