I'm trying to manually inject the javascript for my Backbone app into a UIWebview (in order to save the client from downloading a 1MB JS file when the app boots).
The code below works perfectly fine in DEBUG builds of the app, but as soon as build an Ad Hoc release build and test that out, the app doesn't load properly. I assume it is a JS error somewhere but I don't know how to debug a UIWebview running in a release build (the Safari dev tools only work in Debug as far as I could tell).
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Inject the JS
NSLog(@"Injecting JS 1 from disk");
NSString *path = [[NSBundle mainBundle] pathForResource:@"backbone_application" ofType:@"js"];
NSString *code = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSString *jsCode = [NSString stringWithFormat:@"var script=document.createElement('script'); script.type='text/javascript'; script.text=\"%@\"; document.head.appendChild(script);", code];
[self.webPortal stringByEvaluatingJavaScriptFromString:jsCode]
}
Any ideas on why this would be failing in RELEASE mode? Any suggestion on how to test for UIWebview javascript errors in a release build?