0

I am building an iPad application, based on HTML and I am loading the HTML from local files. In those files I need the jQuery library, so I have the js file in my project and I'll load it using stringByEvaluatingJavaScriptFromString or something like this - this is irrelevant for now.

When I use the following code the NSLog returns null:

NSString *gameFileContents = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"jquery172" ofType:@"js"] encoding:NSASCIIStringEncoding error:nil];
NSLog(@"%@",gameFileContents);

When I change only the extension of the file from .js to .json everything is fine.

NSString *gameFileContents = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"jquery172" ofType:@"json"] encoding:NSASCIIStringEncoding error:nil];
NSLog(@"%@",gameFileContents);

Are there any restrictions on the extensions of the files? I can use the file like that, but it does not seem right - I like everything to be in place.

1 Answers1

1

Xcode always shows warning like - no rule to process file '$(PROJECT_DIR)/--/.js' of type sourcecode.javascript for architecture i386 That's why it is not working.

Checkout below thread for detail discussion - iPhone UIWebView local resources using Javascript and handling onorientationChange

Community
  • 1
  • 1
rishi
  • 11,779
  • 4
  • 40
  • 59