Setting up a HumanApi prototype for Xcode/iPhone

In this blogpost I will explain all steps you need to take to get a HumanApi prototype running on your iPhone and in Xcode. This article does not cover how to do the same for other types of devices but it should be fairly simple if you are familiar with the respective native platform of the device.

Video

Take a look at following video which runs through all required steps. Every step then is explained in detail in this blogpost.

Prerequisites

I have created all prototypes on a MacBook Pro running Mac OSX 10.6.2 – if you encounter issues, please visit the HumanApi forum, we’ll try to figure out the issues there :)

You also already have to have the btstack deamon installed on your iPhone. If you don’t have it installed this prototype won’t be able to receive Bluetooth data. There is a very good tutorial on the btstack WIKI which describes all the steps you need to take to get btstack running.

1. Clone the HumanApi git repository

$ git clone git@github.com:nonken/humanapi.git

2. Make sure all git submodules are initialized and updated

$ git submodule init
$ git submodule update

3. Create the HumanApi prototype PhoneGap project for testing

$ cd build
$ make clean
$ make tempinfo

(tempinfo is the name of the HumanApi prototype you want to test)

Setting up Xcode

Now things get a little bit complicated, if you are used to iPhone provisioning though this should be fairly simple for you. If this is completely new, go take a look at the Apple Developer pages which give you excellent material on how to set up provisioning profiles for your applications.

1. Select the correct provisioning profile in the Projects Settings.

2. Change the Bundle Identifier in the appname-Info.plist to match your provisioning profile

Adding btstack header files and dylib

Now we are almost done with the required steps, all we have to do now is tell Xcode to also include the btstack header files and dylib when compiling the app.

1. The required files are already copied over to your dev/prototypename/iphone/Plugins directory. All you need to do is make Xcode aware of them by dragging them onto the Plugins folder within Xcode.

2. Open the Project settings again and add following line to the Other C Flags field:

-I/absolutepathto/git/humanapi/prototypes/dev/ecg/iphone/Plugins

On my machine this would be:

-I/Users/nikolaionken/dev/git/humanapi/prototypes/dev/ecg/iphone/Plugins

3. Include the Bluetooth header file (this will be made easier!)

Open up Classes/appnameAppDelegate.h and add following line:

#import "Bluetooth.h"

Then open up Classes/appnameAppDelegate.m and add folowing to “webViewDidFinishLoad”:

Bluetooth *myblue = [[Bluetooth alloc] init];
[myblue initBlueTooth:theWebView];

Testing the app

1. Open up the Xcode Organizer and open the Console tab of your connected device.

2. Compile the application in Xcode and wait for it to start on your device.

3. You now should see following logs (or something similar)

... : Turn on the Arduino BT
... : Please enter PIN 12345 on remote device
... : Channel successfully opened:

9 Responses to “Setting up a HumanApi prototype for Xcode/iPhone”

  1. stephan schulz says:

    hi
    would it be possible for you to make the already set up xcode project available?

    i tried make ecg but it did not make the xcode iphone project. it seems to be missing when i downloaded it from git hub.

    thanks,
    stephan.

  2. Jason says:

    Hi,
    Same thing happen to me too
    Please somehow could you make the ecg xcode project ready in zip file so that I could download it directly and try it ?

    Really appreciate that
    Jason

  3. Hi Stephan and Jason,

    I will check in the already built project today (latest tomorrow).
    I’ll also recreate the setup from scratch, I hope I didn’t miss a step somewhere in between :)
    Regards,

    Nikolai

  4. Jason says:

    Just FYI,
    I managed to figure out why I can’t get it build.
    READ ALL the ReadMe files and follow instructions !!!!!
    the above instructions are missing a part where you have to come in the phonegap folder and do the init and update commands ALSO.
    git submodule init
    git submodule update
    and it’s not “build clean” and “build tempinfo” in my case. It was “make clean” and “make tempinfo”.
    I may miss some here but make sure you read all the ReadMe files.

    Thanks Nikolai for the great project.
    Cheers :)
    PS: I’m running OS 10.5.8 leopard.

  5. Very cool, great to hear that it is working for you.
    Do you have anything we can look at already? Would love to post a video or blog entry of what you’re doing here.
    Keep us posted.

    Nikolai

    (I fixed the typo in this article build should have been make, sorry for that)

  6. Hey, that was a great article. You make some really great points.

    I personally think Apple is going too far with the secrecy about their new products. Case in point, the new iPhone. One gets lost in a bar by a drunk employee, and the person who finds it tries to return it. Apple won’t take it because they don’t believe him, so he sells it to Jason Chen, and they’re in hysterics about it and are charging him with a felony. I personally find it ridiculous.

    Anyway, I’ve written about it on my site. Check it out at http://4thgeniphone.com. Thanks for the read!

  7. hello, thank for this astonishing information. Therefore, I would like to ask for your permission to add some of this information in my blog. Of course, I will provide a link to your , as a source of my quoted information.

  8. Heyadmin I enjoy w/ your article . May i save this posting for my college test ? thanks adminstrator

  9. Hey great site, I found your website when I was doing investigation on some methods to develop my site. I was just what spam software package you utilize for comments because I get a good deal on my blogs.

Leave a Reply