views:

895

answers:

3

I've an open source project (gdal) that I want to compile and run as part of an iPhone app. I had been expecting to use NSTask but I see now that it was removed in OS 3.0. I've also seen elsewhere that running external applications, though this would be a resource in my app's bundle, is not allowed.

Has anyone else found a way to run commandline tools within their iPhone applications?

A: 

Jailbreak......

Ramin
+3  A: 

It wasn't removed in 3.0, it was never there. There is no way to run separate processes on the iPhone. GDAL appears to be under an MIT style license and has a library interface, so directly linking it into an iPhone app shouldn't have any legal or technical issues.

Louis Gerbarg
Thanks Louis, Is it the same process as linking into a one of the Apple-supplied frameworks? libgdal.a is about 40mb, considerably larger than the rest of my project, so I was hoping to just use the executable gdalinfo (about 5mb) but that doesn't look like something I can directly link to.I know there aren't a lot of opensource iPhone apps but if you happen to know any that do link in code other than Apple's frameworks, I'd be really interested in seeing how it is done.
Craig
Well, obviously the amount of code needed for the functionality you want must be less than 40 megabytes. Whether you can effectively carve it out is a separate issue. Also, I would think that 40 megs means it is unstripped and has all the debug symbols (which can be quite large). How much does it shrink if you strip it?
Louis Gerbarg
I think I'm going to have to ask a lot more questions on this site. I'm not sure how to go about stripping the debug symbols. It was compiled using "build_for_iphoneos" a script written by Christopher Stawarz, perhaps there are some notes on what flags I need to set.In the meantime I'll try importing it like a framework and seeing what functions I can run on the full 40mb version.
Craig
A: 

NSTask is available in ios 4, ios 3 and possibly all of them. To use NStask I had to copy the NStask header file from my mac to my project folder. Also Apple will most likely not allow an app that uses NStask in the appstore. Cydia would probably be the best place to distribute your app

romejoe
Did you test this on a device? If you just tested in the simulator, it would have used the Mac OS X source, as NSTask.m, the most necessary file, would be missing.
jrtc27
I believe I tested it on a device but I can't remember
romejoe