iPhone UIWebView local resources using Javascript and handling onorientationChange

The answer can be traced from the warning I was getting in XCode:

warning: no rule to process file ‘$(PROJECT_DIR)/html/orientation.js’ of type sourcecode.javascript for architecture i386

XCode setup *.js javascript as some type of source code needed to be compiled in the application when I wanted to include it as a resource so I solved it by doing 2 things.

  1. Select .js file and in the “Detail” view unselect the bullseye column indicating it is compiled code
  2. In the “Groups & files” view expand the “Targets” tree and expand the application then go to “Copy Bundle Resources” and drag the *.js files into it

The Apple dev forums has a posted solution:

It appears that you are getting bit by
the “Xcode thinks that .js are things
to be compiled” feature. Basically,
Xcode thinks that the script should
somehow be run or compiles, so marks
it as part of the source code. Source
code, of course, is not copied into
the resources.

So you need to do two things – select
the .js file in your project, and turn
off the checkbox that indicates that
it is compiled (the “bullseye”
column). If you don’t do this, you’ll
get a warning in your build log about
being unable to compile the file
(which should be your first warning –
always try to figure out and and
correct any and all warning that
appear in your build).

Then drag it and drop it in the
target’s “Copy Bundle Resources”.

Leave a Comment