Archive for iphone development

So I Considered AppStore vs. Cydia

From ChaZg33k on So I Made My iPhone Say Hello, World…

Why would you want to use the App Store when you could submit to Cydia?

Hmm. Troll, or serious question? Guess I’ll respond as a serious question, because I have something serious to say.

Cydia is cool. But the AppStore reaches more iPhones (all jailbroken and all “stock” iPhones) – and most people I see with an iPhone don’t have it jailbroken (and yes, I’ve been asking – current ratio is about 10:1).

Also, there’s a strange behavior with iPhone users – they actually seem willing to PAY for software in the AppStore! <NY Times>.

Given the prevalence of Crackulous, I don’t know that the same holds true for many Cydia users (n.b., I use Cydia, but not Crackulous, and yes, I realize that there are fair use arguments for tools like that, and that the DMCA also has a few arguments to make).

kb

P.S. Just about ready to submit my first app to the AppStore (nothing fancy, though it made me build infrastructure and experience for other projects I have going), then hoping to begin posting more about details, and should be following on with more interesting apps shortly!

Comments (1)

So I used sshfs to Mount a Remote Filesystem

This is the one Linux way to edit files remotely as if they were local. For a Windows approach, see my post on WinSCP. There’s also a Windows sshfs called Dokan SSHFS.

sshfs is a user-space Linux filesystem that makes an ssh connection look like a local filesystem.

It’s trivial to use:

  1. As root (or using sudo) add your user to the ‘fuse’ group:

    # adduser butler fuse
    Adding user `butler' to group `fuse' ...
    Adding user butler to group fuse
    Done.

  2. Start a new shell as the desired user (to get the updated group list), make a mount point, and start sshfs. Note that sshfs will prompt you to accept the remote key (not shown) if this user hasn’t previously connected to this remote account.

    $ mkdir soi
    $ sshfs kevinbutler@soi.kd6.us:soi.kd6.us soi
    kevinbutler@soi.kd6.us's password:
    $ ls soi/images
    changeDirectories.jpg keepRemoteSynced.jpg updatingFiles.jpg
    directoriesSynced.jpg session.jpg watchForChanges.jpg
    firstSession.jpg updateFiles.jpg
    $

  3. Read and update files as if they were local – but with some transfer lag…

If you don’t want to deal with the lag every time you read or write the file, you’ll probably want to use scp or rsync to copy the files over when you need them on the remote machine – and you’ll probably want to use ssh-agent and ssh-add to set up key-based authentication, so you don’t have to type your password every time. You can even put the scp or rsync calls in your Makefile…

Comments (2)

So I used WinSCP to Keep a Remote Directory Up-to-Date

Mononofu reminded me I hadn’t talked about how to keep remote directories in sync. This is the windows version. For a Linux version, see my post on sshfs.

So, to work on files locally on Windows, but have them automatically copied to a remote directory, use WinSCP.

  1. Download WinSCP 4.17 and install it
  2. Run WinSCP
  3. Enter info to connect to the remote host (like your iphone)Session parameters
  4. On your first connect, WinSCP won’t recognize the key of the remote system, so just accept it. If you see this prompt later, it either means your remote system got a new key (e.g., reflashed the phone and re-jailbroke it), or somebody could be trying to intercept your communications. Prompt to accept remote host key
  5. Change directories to the local and remote directories you want to keep synced. Change directories
  6. Choose Commands | Keep Remote Directory up to Date (Ctrl-U). Keep Remote Directory up to Date (Ctrl-U)
  7. Choose options for synchronization, and do a full synchronization to get things started. Watch for changes
  8. Make changes to the files on your local machine. Update local files
  9. WinSCP notices the changes and pushes them to the remote machine. Updating files
  10. The directories are kept in sync. Directories synced

Comments (5)

So I wonder which is more open? G1 or iPhone

At first blush, the G1 is obviously more open than the iPhone – open source platform, open SDK from day 1, and you can install software from anywhere just by selecting a menu option.

But this software runs in a Java sandbox. You don’t appear to have access to the operating system outside the sandbox.

And I have a jailbroken iPhone. I can ssh into my phone. I can use the phone without a SIM card (G1 goes into “emergency calls only” mode). I can modify startup scripts. I can write applications to do anything on the phone. I can change anything I want to on the phone, as a Simple Matter Of Programming. Is the G1 that open? Not the Android platform – the actual, G1 device in my hands…

Of course, as a platform, Android is much more open than iPhone OS. But the actual device? So far, I’m saying a jailbroken iPhone…

Leave a Comment

So I Found Ways to Develop for iPhone

To develop for the iPhone, you have a few choices:

Web applications

Advantages:

  • choose your tools, choose your development platform
  • can make it available to non-iPhone users
  • requires connectivity

Disadvantages:

  • requires a hosting provider
  • limited to safari interface (i.e., tap, rotate, two-finger scroll, pinch zooming, no accelerometer, little iphone glitz)

Toolkits available:

Additional tools/techniques:

  • Web clip bookmark icon create an icon for use in the home screen (hit + in Safari, then “Add to home screen”)
  • Data links allow you to encapsulate webapp and state in the URL. Provides a mechanism to save a “bookmarklet” (“webclip”) that encapsulates the application. If we can also sync back to the online application, that would complete the round-trip.
  • iPhone in Action book has discussion of tradeoffs of web vs native applications

Native applications via the Apple SDK

Advantages:

  • best tools available, including the simulator
  • access to all documented iPhone SDK features
  • publish your application in the AppStore
  • lots of books published or being written

Disadvantages:

  • iPhone only
  • Limitations on application functionality from iPhone SDK agreement (no interpreters, no plugins, …)
  • Requires Apple approval of application for listing in AppStore
  • Requires signing a non-disclosure agreement (NDA)NDA lifted!
  • requires Mac OS X as development platform

Toolkits available:

Native applications via the open source tools

Advantages:

  • no NDA to sign
  • develop on your platform of choice
  • full access to anything the community has discovered
  • (possibly more than the documented SDK)
  • you can even develop ON the iPhone

Disadvantages

Toolkits available:

So, there you have it. Three options.

What will you do?

Comments (1)

So I Doubt We’ll Get Flash or Java on the iPhone

…at least, not in their current forms.

There’s been some buzz about Flash coming to the iPhone. The problem is, that the problem is not technical – for both Flash and Java.

The Backstory

First some history:

  • Apple (Steve Jobs) has said that Flash is too big and slow on the iPhone, and that Flash Lite is too cut down, and thus not useful
  • Jobs also says that “Java’s not worth building in. Nobody uses Java anymore. It’s this big heavyweight ball and chain.” NY Times
  • Adobe has been pushing to get Flash on the iPhone, saying “it works”, etc.
  • Sun committed to provide Java on iPhone with the SDK, but when they saw the SDK restrictions, they had to backpedal to provide Java on the iPhone “if at all possible.”
  • Apple didn’t want to provide a native apps SDK – keeping all app development in-house.
  • Apple only provided a native apps SDK when it became clear that the jailbreak apps were wildly popular, completely outside Apple’s control, and thus threatening to take control of the iPhone platform away from Apple
  • Apple provided the SDK with very stringent restrictions – both the NDA, which has since been reluctantly lifted, and strict limitations on the applications developed with the SDK – including requirements that applications do not call any non-SDK APIs and do not download executable code or provide any interpreters. This last restriction is aimed directly at technologies like Flash and Java that execute code from third parties.

Apple the Monopolist

This pattern makes it clear that Apple is very intent on keeping control of the applications provided on the iPhone platform. They have some legitimate reasons for this (i.e., protecting their brand, protecting the user experience, protecting the cell network of their carrier partners), but I think the dominant reason is just protecting their very profitable monopoly.

Apple has a monopoly on the distribution of iPhone applications (barring the jailbreak apps), and they are determined to retain that. This monopoly is what allows them to do that other protection – of brand, experience, and network. It also is what allows them to charge every application developer 30% of revenue plus $99 per year. And what allows them to prevent applications that compete with iTunes, another big money maker. And also what allows them to limit iPhone development to being done on Apple hardware, another big money maker.

I’m quite confident that both Sun and Adobe have been working the back channels to convince Apple to allow Java and Flash on the iPhone, but that Apple will not budge.

What Will Work

I see three things that can get Apple to change their position:

  • Widespread public outcry for the other technologies. This seems to be what Adobe and Sun would be hoping for. However, Apple doesn’t really listen to customers. “Uncle Steve knows best.” The only leverage Apple customers have is their dollars, hence the next two possibilities.
  • Widespread adoption of a competing platform – namely, Google’s Android. This could be viewed as the ultimate loss for Apple – thousands, millions of potential customers going with a competing platform – but Apple has played the elite-user-friendly-minority-platform-where-we-have-a-monopoly role before, and I think they’ll be willing to do it again on the iPhone if that’s what it takes to retain control.
  • Widespread defection of users and developers to the open jailbreak technologies. This is what got the SDK and the degree of openness we have now. If Apple feels it is going to lose control of the iPhone platform, Apple releases partial control – first the SDK, then lifting the NDA, next… What? How can Apple retain control of the platform and give users and developers Flash or Java?

Apple-Friendly Flash and Java

So, how can Apple retain control of the platform but allow users and developers Flash and/or Java?

Well, they could allow Java as just another language to produce SDK applications sold through the AppStore. AlcheMo translates compiled JavaME applications to C++ code that is then compiled on the SDK. The resulting application can only run on the iPhone after going through Apple’s AppStore vetting process.

Flash? Frankly, the web’s model of flash widgets embedded in web pages isn’t going to fly on the iPhone. It just doesn’t have enough memory to support that use model. Flash Lite? Does anybody think that’s enough? Steve Jobs said there’s a “missing product in the middle.”

How about Adobe Air, letting users run Flash applications on the iPhone “desktop”? Well, if Adobe produces a version that makes these apps standalone, without the ability to download additional code to run, we have the “product in the middle” that Steve indicated could be worthwhile – and that let’s Apple preserve it’s control over the platform.

When users and developers defect to other platforms, and Adobe and Sun deliver versions of Flash and Java that let Apple control the applications delivered to the iPhone, Apple will let it happen.

kb

Comments (2)

So I Want an iPhone SDK Development Book

…but thanks to Apple’s recently lifted NDA, they aren’t available yet. But without the NDA, more should be coming soon.

Here are the ones I’ve found on Amazon (these are my affiliate links):

iPhone Open Application Development: Write Native Applications Using the Open Source Tool Chain, 2nd Edition, by Jonathon Zdziarski. This is the one I pre-ordered. The author was one of the original iPhone jailbreakers. The first edition sold out quickly, so this is the updated follow-up. This is the book to get if you want to be able to exploit the full capability of the iPhone, including APIs that Apple doesn’t document – but if your primary target is the Apple AppStore, you may need to rely on the SDK documents or on another book. Note the First Edition PDF version is still available.
 
iPhone SDK Development, by Bill Dudney, Chris Adamson, Marcel Molina. The Pragmatic Programmers’ take on the iPhone. I’m really intrigued by this one, too. This appears to be a good comprehensive treatment of SDK development, and coming from the Pragmatic Programmers, it should be quite practically oriented. This book was delayed because of the Apple NDA, but is currently available in beta as a PDF and the source code is also available for use in your projects, but not for training material, books, articles, etc.
 
iPhone in Action, by Christopher Allen and Shannon Appelcline. The publisher provides Early Access chapters. This book will cover both web and SDK development. Chapter 2 in the early access provides a detailed description of the tradeoffs of web, SDK, and various hybrid development strategies. I’m more inclined to go with a focused SDK book.
 
iPhone SDK Application Development: Building Applications for the AppStore, by Jonathan Zdziarski. Jonathan Zdziarski comes in from the cold – here’s his book for the AppStore. I expect this book will make a great companion to his Open Application Development book, but it won’t be available until 2/15/2009. I do wonder if Jonathon will run afoul of the SDK agreement’s restriction on circumventing Apple security measures…
 
The iPhone Developer’s Cookbook: Building Applications with the iPhone SDK, by Erica Sadun. To be released “as soon as Apple lifts the NDA on the iPhone SDK.” We’ll see when it becomes available, as Apple announced they were lifting the NDA (but haven’t posted the new agreement) 10/2/2008. Now available! This book sounds more like a collection of snippets to me, rather than a comprehensive look at the SDK. It also talks about tools to reverse engineer non-SDK frameworks, which could be interesting. Source code for the examples is available.
 
Beginning iPhone Development: Exploring the iPhone SDK, by Dave Mark, Jeff LaMarche. One of the well-regarded Apress Beginning… series, this will likely be a well-edited, comprehensive book.
 
 
iPhone SDK Programming, by M.A. Ali. A 512-page book from John Wiley and Sons, in English. That’s about all we know about it at this point, especially because a search for the ISBN on Wiley and Sons returns nothing.

Comments (1)

So I Don’t Need to Agree

…to the Apple iPhone SDK NDA.

Apple has lifted the NDA. Kudos to Apple for lifting it, shame on them for writing it and taking so long.

From Apple: http://developer.apple.com/iphone/program/

To Our Developers

We have decided to drop the non-disclosure agreement (NDA) for released iPhone software.

We put the NDA in place because the iPhone OS includes many Apple inventions and innovations that we would like to protect, so that others don’t steal our work. It has happened before. While we have filed for hundreds of patents on iPhone technology, the NDA added yet another level of protection. We put it in place as one more way to help protect the iPhone from being ripped off by others.

However, the NDA has created too much of a burden on developers, authors and others interested in helping further the iPhone’s success, so we are dropping it for released software. Developers will receive a new agreement without an NDA covering released software within a week or so. Please note that unreleased software and features will remain under NDA until they are released.

Thanks to everyone who provided us constructive feedback on this matter.

Apple responds to criticism and lifts NDA: 8 months
T-Mobile responds to criticism and lifts 1GB/month cap: 1 day

But definitely good to have the NDA gone…

And I wondered “how these iPhone SDK Books pass legal muster? Special license from Apple? How does one get such a special license?”

Ars Technica explained that various books were on hold – either waiting to be printed, or waiting to be written, because of the NDA.

So, one less obstacle to iPhone development – now to just get clarification of the AppStore criteria…

Comments (4)

So I Made My iPhone Say Hello, World…

…with the open source toolchain. It was a real pain until I decided to focus on the easy way. Then it wasn’t hard at all.

For reference, the hard way is on iphone-dev. I spent most of a frustrating, unsuccessful day with that page and its thousands of comments, especially extracting the SDK from the 1GB XCode binaries – you want version 2.5, not a newer version, and use PowerISO to extract it. For what it’s worth, there looks to be an easier way for Cygwin on Windows.

The Easy Way

But the really easy way is to install the development tools on your iPhone.

This requires:

  • a “jailbroken” phone – so you can install open software on it.

    I used Windows QuickPwn and it was easy. Works with the 2.1 firmware, too…

  • a Wi-Fi connection – and get the IP address of your iPhone:
    • open the iPhone Settings application
    • tap Wi-Fi
    • tap the (>) button to the right of your active connection
    • note the IP Address – probably something like 192.168.1.101, which I use below
  • an SSH client of your choice – Linux and Mac come with ssh clients.

    Windows users can download PuTTY or use the Cygwin Unix layer on top of Windows. Developers running Windows may also want to grab WinSCP for its “Keep Remote Directory Up To Date” feature (more on that in another post).

After the Jailbreak

After your phone is jailbroken, open the Cydia application. It is like the AppStore, but for open software.

Tap “Featured Applications”, then flick to the bottom, and tap OpenSSH, then tap Install, tap Confirm.

When the installation completes, go back to Cydia, tap Search in the bottom-right, and type toolchain. Tap iPhone 2.0 Toolchain, then Install then Confirm. This is a pretty big iPhone application – over 40MB expanded! So, while your iPhone is working on that, let’s go back to the desktop machine.

You should now be able to use ssh (or PuTTY…) from your desktop computer to connect to your iphone, using root as the user, your iPhone’s IP address for the host, and alpine for the password. If you’re using a graphical SSH client like PuTTY, follow its prompts. On Mac/Linux/Cygwin, open a terminal, and type:

      ssh root@192.168.1.101
      root@192.168.1.101's password:              [type alpine]

The first time you connect, it may take about 30 seconds, then you should then see a Unix command-line prompt from the iPhone, and it will end with a “#” – which means you are the “root” or administrative user. You’re the boss – congratulations!

First thing you should do as boss is make sure nobody else can be boss – change your password! (No, really, change it now – here’s how…)

    passwd
    Changing password for root.
    New password:               
    Retype new password:        

Don’t forget this password. :-D If you do, you’ll probably have to jailbreak the phone again to reset it.

After the Toolchain is Installed

OK, so you can ssh into your iPhone, and you’ve installed the toolchain (that installation has completed on your phone, right?).

So, on your desktop with the ssh window into your iPhone, type:

    echo 'main() { printf("Hello, iPhone!\n"); }' > hello.c
    gcc hello.c -o hello
    ldid -S hello
    ./hello

And your phone should say:

    Hello, iPhone!

When I first did this, it was late at night, and I forgot the ldid -S hello, so instead of “Hello, World”, I got:

    # ./hello
    Killed

The iPhone will only run “signed” code, and since ./hello was not signed, the iPhone killed it. The “ldid -S PROGRAM” signs the program for you. Turns out the iPhone doesn’t care what signature is on the file, just that it is marked with a signature…

So there you go: a usable toolchain on your iPhone, waiting for you to write the next great iPhone program. For real development, you’ll want to use your desktop development environment and something like sshfs, rsync, or WinSCP to copy the files to the iPhone as you edit them, but more on that later… Updated: More is now available for Windows/WinSCP and Linux/sshfs

Comments (55)

So I Just Saw a New iPhone Book

…coming from O’Reilly – the next version of the Open Source Application Development book. Looks like this is the one to get:

iPhone Open Application Development: Write Native Applications Using the Open Source Tool Chain

And Amazon (above) has it for $26.39 preorder – lots better than the $39 direct from O’Reilly.

Leave a Comment