Weekend Project: Nike+ and iPhone 3G – Part 1

Preface

Jason Chen over at Gizmodo, 2+ years ago threw down the gauntlet and started the iPhone Hacker Challenge: Make the Nike+ iPhone Work With Nike+ Sport Kit.  To my knowledge no one yet has successfully met this challenge until now.

At first I kept watching and hoping Apple/Nike would support the iPhone 3G.  With each new firmware update the rumour mill would start and people would say finally Nike+ would be available on the iPhone 3G.  Sadly it still isn’t and the rumours are getting quieter and fewer with each passing update.

This is nothing more than a proof of concept – to say that the iPhone 3G has no technical limitations to being able to run Nike+.  It might not have the built in hardware like its big sister, the 3GS, but neither does the Nano and it at least gets a receiver.  Maybe the battery will drain faster, maybe there are incompatibly issues with other accessories and it is a necessary trade-off, or maybe tethering won’t work, but whatever the reason(s) is, my hope for releasing this proof of concept is to get Apple/Nike to reconsider their decision and support the iPhone 3G.  I believe there are a group of consumers that would gladly spend money on the Nike+ Sport Kit if they are able to use it with their iPhone 3G.

Warning

I take no responsibility for the method described below.  I am simply describing the method I used and what I found to have worked.  This may or may not brick or otherwise damage your iPhone since this is something your iPhone wasn’t intended to do.  And remember: this is the internet.

Other accessories, such as bluetooth handsfree headsets may or may not work.  I don’t have any so I’m unable to confirm or deny.

If you still brave and willing to continue then please: Backup, Backup, Backup.

Requirements

Software

A method to decrypt the firmware -  vfdecrypt

A method to extract the files from the firmware: I used Acute System’s Transmac

A method to copy files to your iPhone and ssh: I used winscp and putty

A method to edit plist files: I used plist Editor for Windows

ldid from Cydia for pseudo-signing – see here

iTunes v9 (I am running 9.0.2.25)

Additional Files

Firmware for the iPod Touch 2G v3.0 (7A341)  – here

The firmware key

Patched iapd file – here or here

Hardware

A jailbroken iPhone 3G running v3.1.2 firmware (7D11) with SSH access

And obviously the all important Nike+ sensor and receiver kit

nike-plus-sensor-receiver

Setting up the Nike+ Application on the iPhone

The first thing we will need to do is get the Nike+ app working on the iPhone.  Simply, we will extract the necessary files from the firmware and copy them over and make sure everything is working.  If you have an iPod Touch running v3.0 (7A341) firmware then you can copy the files from it rather than extracting them from the firmware.

A special thanks to JorgiBob for pointing me in this direction

Extracting the required files

  1. Rename iPod2,1_3.0_7A341_Restore.ipsw to iPod2,1_3.0_7A341_Restore.ipsw.zip and extract it’s contents
  2. Decrypt the root file system, ie:
    C:\Temp\Nike+>vfdecrypt.exe -i "iPod2,1_3.0_7A341_Restore\018-5300-002.dmg" -k 415225778E1BEBF8EEFF2A9050B04CE429DE9680E4ACBA50820A3FA453897BC4A4B307E2 -o "iPod2,1_3.0_7A341_Restore\decrypted 018-5300-002.dmg"

  1. Open the decrypted root file system with Transmacimage
  2. Extract the following folders and file
    /Applications/Nike.app

    /System/Library/PreferenceBundles/VictoriaSettings.bundle

    /System/Library/PrivateFramworks/SportsTrainer.framework

    /System/Library/PrivateFrameworks/IAP.framework/Voices

    /System/Library/PrivateFrameworks/IAP.framework/Templates

    /System/Library/PrivateFrameworks/IAP.framework/IAP(just the file)

    /System/Library/SpringBoardPlugins/NikeLockScreen.bundle

Copying the files to the iPhone

Copy all the folders and file to your iPhone using winscp to the same location you found them in the root filesystem of the decrypted firmware.

Open a ssh termial to your iPhone and login as root.  You will need to reset the permissions, psuedo-sign each application or library and correct the CodeResources link.

The Nike application

iPhone:~ root#: cd /Applications/Nike.app

iPhone:/Applications/Nike.app root#: rm –f CodeResources

iPhone:/Applications/Nike.app root#: ln –s _CodeSignature/CodeResource CodeResources

iPhone:/Applications/Nike.app root#: chmod 755 Nike

iPhone:/Applications/Nike.app root#: ldid –S Nike 

The VictoriaSettings library

iPhone:/Applications/Nike.app root#: cd /System/Library/PreferenceBundles/VictoriaSettings.bundle

iPhone:/System/Library/PreferenceBundles/VictoriaSettings.bundle root#: chmod 755 VictoriaSettings

iPhone:/System/Library/PreferenceBundles/VictoriaSettings.bundle root#: ldid –S VictoriaSettings

The SportsTrainer library

iPhone:/System/Library/PreferenceBundles/VictoriaSettings.bundle root#: cd /System/Library/PrivateFrameworks/SportsTrainer.framework

iPhone:/System/Library/PrivateFrameworks/SportsTrainer.framework root#: chmod 755 SportsTrainer

iPhone:/System/Library/PrivateFrameworks/SportsTrainer.framework root#: ldid –S SportsTrainer

The IAP library

iPhone:/System/Library/PreferenceBundles/VictoriaSettings.bundle root#: cd /System/Library/PrivateFrameworks/IAP.framework

iPhone:/System/Library/PrivateFrameworks/IAP.framework root#: chmod 755 IAP

iPhone:/System/Library/PrivateFrameworks/IAP.framework root#: ldid –S IAP

The NikeLockScreen library

iPhone:/System/Library/PrivateFrameworks/IAP.framework root#: cd /System/Library/SpringBoardPlugins/NikeLockScreen.bundle

iPhone:/System/Library/SpringBoardPlugins/NikeLockScreen.bundle root#: chmod 755 NikeLockScreen

iPhone:/System/Library/SpringBoardPlugins/NikeLockScreen.bundle root#: ldid -S NikeLockScreen

Making the iPhone Nike+ aware

Backup the M68AP.plist file

iPhone:/System/Library/PrivateFrameworks/IAP.framewrok root#: cd /System/Library/CoreServices/SpringBoard.app

iPhone:/System/Library/CoreServices/SpringBoard.app root#: cp M68AP.plist M68AP.plist.backup 

Copy the M68AP.plist file to your computer, leaving the backup alone

Open the local M68AP.plist with the plist Editor and add the following key:

image

and close to the bottom of the same file, add the following key:image

Copy the modified M68AP.plist back to your iPhone, overwriting the original file.

Respring or reboot your iPhone

Sanity Check Point

Once your iPhone has resprung or rebooted, the Nike+ iPod application should be available.

Nike  Homescreen

You should be able to open the Nike+ iPod and see the following:

Nike  iPod Running

If the application closes immediately then you have missed a step above.

Go into Settings and at the bottom, you will find:

Nike  Settings

with the following settings if you select Nike + iPod

Nike  Settings 2

Again, if the Settings application closes or doesn’t look like the above, you have missed a step above.

The sensor will still not be detected and if you plug in the receiver then you will still simply get “The Nike + iPod reciever is not required for this iPhone because it has the built-in receiver.”  Go ahead, try, I’ll wait.

Using the Receiver and Sensor with the iPhone 3G

So far the above hasn’t been anything new.  Many people have figured this part out and it was all necessary groundwork.  In order to “trick” the iPhone into accepting the receiver, we will need to add a preference key and update the iapd daemon (the application that handles accessories as well as a lot of the lower level Nike+ operations).  The iapd service is what prevents the iPhone from using the receiver but allows other devices.

Support A45, you will

Backup the .GlobalPreferences.plist file.  Note: this is a hidden file (notice the ‘.’ at the beginning)

iPhone::/System/Library/CoreServices/SpringBoard.app root#: cd /private/var/mobile/Library/Preferences

iPhone:/private/var/mobile/Library/Preferences root#: cp .GlobalPreferences.plist .GlobalPreferences.plist.backup 

Copy the .GlobalPreferences.plist file to your computer, leaving the backup alone

Open the local .GlobalPreferences.plist with the plist Editor and add the following key:

image

Copy the modified .GlobalPreferences.plist file back to your iPhone, overwriting the original file.

iapd

Up until this point we really haven’t changed anything on the iPhone, sure a setting here or there and added files.  This change will mean you are changing core system files.  If you feel uneasy about doing so, then look away now.

Backup the iapd file

iPhone:/private/var/mobile/Library/Preferences root#: cd /System/Library/PrivateFrameworks/IAP.framework/Support

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: cp iapd iapd.backup

Copy the modified iapd (linked above) to your iPhone using winscp.

And now we will setup the iapd like we did with the apps & libraries above and copy it over the original iapd file.

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: chmod 755 iapd.nikeplus

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: ldid -S iapd.nikeplus

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: cp iapd.nikeplus iapd

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: ps aux

iPhone:/System/Library/PrivateFrameworks/IAP.framework/Support root#: kill <pid of iapd>

Deep breath, it is the moment of truth.

Pairing the sensor

Open the Settings app and got the Nike + iPod screen.

Plug in the receiver.  There should be no message.

Click on sensor to begin the search.

Squeeze hard on the sensor between your index finger and thumb over the Apple logo and/or shake.  That is simulate walking around.

If all goes well, and your sensor should be linked.  Once it is linked you then use it with the Nike+ application.  If you plug in the receiver after the sensor search has started, simply cancel and start the search again leaving the receiver in.

Sensor Linked

Nike+ Workouts and Calibration

This is pretty much the same procedure as above.  Again if you plug in the receiver after the sensor search started, simply cancel and start the workout/calibration again with the receiver still plugged in.  You won’t see the pace or distance change until you have started the workout/calibration.

Calibrating 2

Calibrating

iTunes

Once the sensor has been linked with the iPhone, it will create the necessary files for iTunes to detect and display the Nike+ tab.

iTunes Nike

iTunes Nike  2

iTunes Nike  3

Conclusion

The patch iapd is not perfect but works.  So far I have not experienced any negative pact but since this is still new, please leave feedback.  I will post again about the method used and hopefully someone with much more ARM assembly knowledge than me can pick it up.

I hopefully have got everything, if I missed a step or something is unclear, I’ll try to be prompt to revise it.

And Apple/Nike: please support Nike+ in the 3.1.3 firmware, please, please, pretty please, with a cherry on top.

Tired of writing, off to run.

Nike + iPhone 3G.  Done.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Live

Tags: ,

224 Responses to “Weekend Project: Nike+ and iPhone 3G – Part 1”

  1. kaykoo says:

    I killed PID of “accessoryd”, but I still cannot pair the sensor :-(

  2. Mia says:

    You can’t load preference bundle because Sbsettings is installed, so it’s necessary remove it

  3. chris says:

    For those interested in the 4.0 FM:

    I have spent more time looking into running Nike+ on the iPhone 3G with iOS 4.0. There are unfortunately a few issues:

    1) The required libraries and this is the biggest problem. In 4.0, Apple has consolidated all the libraries into a single cache file. For additional reading – see http://blog.howett.net/?p=75

    So far no luck getting these to be dynamically loaded either (out of address space).

    unknown Preferences[2202] : Error loading /System/Library/PreferenceBundles/VictoriaSettings.bundle/VictoriaSettings: dlopen(/System/Library/PreferenceBundles/VictoriaSettings.bundle/VictoriaSettings, 265): Library not loaded: /System/Library/PrivateFrameworks/SportsVoices.framework/SportsVoices
    Referenced from: /System/Library/PrivateFrameworks/SportsWorkout.framework/SportsWorkout
    Reason: no suitable image found. Did find:
    /System/Library/PrivateFrameworks/SportsVoices.framework/SportsVoices: out of address space
    /System/Library/PrivateFrameworks/SportsVoices.framework/SportsVoices: stat() failed with errno=1937330991
    Preferences[2202] : Failed to load PreferenceBundle at /System/Library/PreferenceBundles/VictoriaSettings.bundle.

    2) Language files which are suspiciously zero bytes in the ipsw. On an actual device they aren’t so at some point from somewhere they are overwritten and I’m assuming this is also to conserve disk space by unneeded resources.

    And finally,

    3) Springboard is restricting launch attempts for Nike:
    SpringBoard[1987] : Attempted to activate restricted application com.apple.nike

    This one is new but easily side stepped with a pair of pumas ;-) but not sure how deep the restriction goes.

  4. Alex says:

    I killed the pid of aipd and i can´t pair the sensor
    When I kill the pid and then i do ps aux the aipd appear another again

    Help please….

  5. Alex says:

    Someone have patched iapd???
    Someone can upolad????

    Thanks

  6. crs says:

    Got it working on original iphone (iphone 2g) using the same method.

    • JB_PL says:

      Cheers,

      on which software version did you manage to make it working on iPhone 2G ?

      I have 3.1.2 as recommended, did all the things from this tutorial, but it seems not to work for me. Sensor is being paired, without warning of incompatibility, but when I start calibration – screen closes … same when I start workout…

      Does anybody can help ? Please :)

  7. Herman says:

    when i try to do
    iPhone:/System/Library/PrivateFrameworks/IAP.framework root#: ldid –S IAP

    on my iphone,it says “ldid command not found”, why is that ?

    • Claudio Segoloni says:

      you have to install the full version for cydia, then you will have ldid…you can also get ldid with the apt command, but you have to install apt0.7 in your iphone and log with ssh protocol to it, then type apt-get install ldid

      hope this helps

  8. Dennisdej7 says:

    Go on Chris, you can do it. :p

  9. leo12321 says:

    Hi, i have a problem with Idid, cant get it to work. I have Cydia and Apt, i even tried to install Idid trough MobileTerminal, but there it says that it cant find Idid. When i try to use the Idid command, it just says that the command does not exist. Other than that i have done everything, the program shows, but i get the popup about the dongle not being supported.

  10. leo12321 says:

    Situation update: I had also forgotten to replace iapd with patched iapd, but now the whole phone hangs everytime i try to start nike +.

  11. [...] i have been trying to get nike + to work on my iphone 3g, following this guide. I have done everything cept for the pseudo signing of the new files, with Idid. I cant get [...]

  12. Todd says:

    Got this working great on my 3G.
    Thanks alot man.
    very good guide.

  13. leo12321 says:

    anyone??

  14. Chris says:

    All looked fine in the beginning but when i plug the receiver in the phone says something like “not compatible”. when i start the nike+ settings the symbol starts to blink but no pairing. its no problem to pair using the iphone nano… have i missed something? Thanks to all. By the way GREAT WORK! Greetings from Germany.

  15. Cody3G says:

    Man I just bought a new pair of Nikes and the new Nike sensor tonight. The Nike box says “iPhone”, not “iPhone 3GS”, so I’m extremely pissed that it’s not built in to my 3G. I’m a jailbreaker though, so I figured I’d google my issue and find simple-solutions-o-plenty. This seems to be the best guide out there, but i’m on lousy 4.0.1. :( Great job getting everything to work. I read the guide in hopes of finding 4.0.1 eligibility, but it looks daunting. I’m so angry at the Apple/Nike lovefest now. I understand that the 3GS can work w/out the ‘dock sensor’, but why the heck shouldn’t I be able to plug that thing into my phone and it actually works? Thank you for your continued effort.

  16. Acid says:

    Has anyone tried to update iTunes 10?

  17. Pogz says:

    Can somebody already create a cydia package for this one?

    I was planning to jog tomorrow but apparently, if I do this, I wouldnt have the energy if I pull in an all nighter for this. Haha..

    Good work though! :)

  18. alex says:

    Your simply the BEST

    Thank you…

  19. Acid says:

    Anyone … iTunes 10?

  20. Zach says:

    Having a problem…followed all the instructions. I have an iPod Touch 1G with 3.1.3.

    I followed everything, but it doesn’t show the Nike+ app or in settings. I can access the app from SBSettings (by putting it in the dock), but when I go to calibrate the device, it can’t find the sensor.

    No errors when I plugged in the receiver, and followed all instructions. I’ve tried restarting it…no dice…

  21. tk says:

    Okay… tried to do this on 4.2.1 and some luck. The Nike app crashes and Nike+Ipod shows up in the settings but it won’t load the PreferenceBundle. There does not appear to be a M68AP.plist file in 4.2.1 so guessing that this may be part of the problem. I placed it in the directory anyways but still no luck. Yeah, I know that Nike+GPS is out but I ask “what good will that do on a treadmill?”

    So, if anyone has got this working on os 4, please post instructions.

    Thanks!

    • Anonymous says:

      Have you tried adding the keys into the existing .plist file? I don’t remember what they changed it to (N something I think). The purpose of the file, as far as I can tell, is to determine that features are available on the device. Adding those keys to the existing file should work, in theory. The patched iapd file is what I would figure is giving everyone the problem. My wife has an old iPod touch with the sensor built in, but for the life of me I can’t track down all the files associated with the Nike+ app.

  22. Arved says:

    I neither can find the package ldid in cydia, nor install it via apt-get in MobileTerminal or via ssh. I always get “sh: apt-get: command not found”

    I’ve installed APT 0.7 and rebooted my iPhone 2G, but it didn’t do anything. I still can’t use apt-get. I know that it should work, because I installed Nike+ once on my iPhone 2G, but I restored it recently.

    Can somebody help me?

  23. sophie says:

    i’m kinda lost… should i do this with a 4.0.2 OS iphone 3g? if i shouldn’t what can i do?
    i know i may be asking for too much, but can’t u guys create a pckg for people like me who will probably screw up their phones trying… i mean, at least i try… =P have mercy! =)
    i need help… =S
    thnx though!
    =)
    soph

  24. Peter says:

    I am Peter from Sktek.HK.Co.Ltd in China.Our company can provide more the service of iPhone,iPad and iPod.What’s more .We can give you the best price for you.
    I look forward to your early reply.
    My email is peter@sktek.net
    Thank you very much.

  25. David says:

    I am going to try to get this to work on an iPhone 4. I know the iPhone 4 already detects the watch and sensor with no extra hardware, but I want to be able to use just the watch during my regular workouts without having to do it through the Nike+ app.

  26. ma3rian says:

    i configured on my 3G iOS 4.2.1 (custom firmware), but i have the same issues:

    /System/Library/PrivateFrameworks/IAP.framework/Support$ chmod 755 iapd.nikeplus
    chmod: cannot access `iapd.nikeplus’: No such file or directory
    /System/Library/PrivateFrameworks/IAP.framework/Support$ chmod 755 iapd.nikeplus
    chmod: cannot access `iapd.nikeplus’: No such file or directory
    /System/Library/PrivateFrameworks/IAP.framework/Support$ cp iapd.nikeplus iapd
    cp: cannot stat `iapd.nikeplus’: No such file or directory
    /System/Library/PrivateFrameworks/IAP.framework/Support$ ps aux
    -sh: line 142: ps: command not found

    what should i do…?
    or… it can be configured on 3G iOS 4.2.1?

  27. Kupy says:

    I just downloaded Nike+ GPS on my jailbroken iPhone 3G and the app works using the phone’s accelerometers. It does not seem to recognize the sensor and the Nike+ app does not show up under /Settings.

    I need help taking it from here into fully enabling the sensor. A step by step guide (assuming nothing) would be helpful for me and the community.

  28. Austin says:

    Thanks for this amazing tutorial.. I got Nike+ iPod app installed and working on my iPhone 2G running iOS 3.1.3. It is beautiful working and looks like it is a native app for iOS 3.1.3.

    At first I had some problem understanding the tutorial as I am new with the editing iPhone files, but as I started doing it, I was able to it very easily..

    Thanks!

Leave a Reply