1

Basically I want to use relative path in my html and js files that I imported to the project. It seems that xcode puts those bundle files all at the same level if I import files as group reference. So if I then get rid of all relative paths in my code it would work. But if I import them as folder reference as following links suggested none of those files will appear in Copy Bundle Resources (neither in compiled sources).

Load resources from relative path using local html in uiwebview

UIWebView doesn't load external Javascript file

Any help will be appreciated.

Community
  • 1
  • 1
JohnnL
  • 111
  • 11

2 Answers2

1

I managed to resolve my issue. What I did wrong was import the entire folder as folder reference that would expose the folder appearing in the root directory as the result. I could refer every files with that directory (e.g. root/js/abc.js) but that'd be bad.

I don't know if it's the best way to resolve but here is what I have done. I created one group and put everything else in that group except importing all sub folders as folder references. In that way all files in the root group can use relative paths without errors.

Note: all the files in the folder reference still don't appear in bundle resources and I still don't know how other people (in the links I posted) got it done.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
JohnnL
  • 111
  • 11
0

You could put your front-end files into a real folder, then add the folder to your XCode project(don't forget to check "copy if needed", not as reference).

Allen
  • 6,745
  • 5
  • 41
  • 59
  • Thanks for the reply. You mean add folder as folder reference right? As I said those files wont appear in Copy Bundle Resources. The result is then they cannot be found and used. – JohnnL Jun 16 '15 at 03:01
  • @user744641 Not as reference, I mean copy it to your project, there is a check option in the pop dialog when you do include stuff. – Allen Jun 16 '15 at 03:03
  • Did you do it by dragging it to xcode directly? Then there will be 2 options: groups or folder references. For me relative paths do not work with groups while folder references do not add those files to bundle. – JohnnL Jun 16 '15 at 03:49
  • I managed to get it work. I will post another answer in case if anyone needs it. Thanks anyway! – JohnnL Jun 16 '15 at 04:28