What i’m try to do essentially is drag a folder in and have it do what xcode will do and just copy the files and reference the elements in place in a webview.
Any help appreciated
You can add a Copy Files Build Set to the built target (in Build Settings) to copy files into the app bundle on OS X.
You’ll likely want to have your app copy these files out to a temp location from which you can load the resulting index file into an HTMLViewer.
If you copy the site file structure, everything should flow fine from the index page. Have you tried opening the index file in Safari or Chrome ?
Thanks Paul, Micheal
Thanks… ive worked out the copy settings no problem.And the html /folder structure all works fine indepentdantly in a browser. I was under the impression you cant just drag a folder in though and reference the index file in the folder?
You cannot just drag files to the project and reference them as files later. Files added to the project are essentially treated as constant strings. You’d have to write them out to individual files. Using a Copy Files Build Set is the better approach.
Okay. That explanation makes more sense.Thanks. So i would have to write the files out to a temp folder somewhere everytime the app runs ? Shame as its a large size filesystem.
You could write the files out to SpecialFolder.ApplicationData in a folder for your app. Then they would remain available between runs. New versions of the app could update the data as needed.
That would work only for files that are at the root of your site together with the index file.
For instance, you would access the index.html file as such :
dim f as folderitem = app.executablefile.parent.parent.child("Resources").child("index.html")
You have to recreate subfolders within the Resources folder through a CopyFile and indicate the name of each subfolder and directory structure. For instance, you copy all files within the images subfolder to Resources where your site uses /images
And so on. If you recreate the appropriate directory structure within Resources, then you can open index and navigate the same way you would with a browser.
The limitation is that you can only have one level of subdirectory. So if your site structure calls for several layers of subdirectories, it becomes better to copy the structure to SpecialFolder.ApplicationData. A nice way to do that can be to zip your site, and extract it at runtime to SpecialFolder.ApplicationData, using shell execute.