I found the answer after searching around. Here's what I have done:
Create a new project in XCode. I think I used the view-based app.
Drag a WebView object onto your interface and resize.
Inside of your WebViewController.m (or similarly named file, depending on the name of your view), in the viewDidLoad method:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"index" ofType:@"html" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
Now any files you have added as resources to the project are available for use in your web app. I've got an index.html file including javascript and css and image files with no problems. The only limitation I've found so far is that I can't create new folders so all the files clutter up the resources folder.
Trick: make sure you've added the file as a resource in XCode or the file won't be available. I've been adding an empty file in XCode, then dragging my file on top in the finder. That's been working for me.
Note: I realize that Obj-C must not be that hard to learn. But since I already have this app existing in JS and I know it works in Safari this is a much faster dev cycle for me. Some day I'm sure I'll have to break down and learn Obj-C.
A few other resources I found helpful:
Calling Obj-C from javascript: calling objective-c from javascript
Calling javascript from Obj-C: iphone app development for web hackers
Reading files from application bundle: uiwebview
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…