Tuesday, March 1, 2011

Adding JS code to your iPhone projects

IF you ever had a problem like this before, then there is a simple solution.

!! Warning: no rule to process file '$(PROJECT_DIR)/SomeJSFile.js' of type sourcecode.javascript for architecture i386

You can just ignore this warning, as you know that it isn't going to compile this code anyway.

But another odd thing you may think is that

NSString *path = [[NSBundle mainBundle] pathForResource:@"SomeJSFile" ofType:@"js"];

doesn't work either. It will always return nil.

Go to targets, and look under Compile sources, and drag the JS file into Copy Bundle Resources. And Bingo! Both issues resolved.

The sun is shining again.