[AC-1602] iOS8: WebView not able to access files in applicationDataDirectory anymore
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2014-09-23T23:02:32.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | ios |
Reporter | Michael Gangolf |
Assignee | Steven Scott |
Created | 2014-09-23T19:21:42.000+0000 |
Updated | 2016-03-08T07:38:04.000+0000 |
Description
QA Thread: http://developer.appcelerator.com/question/177846/ios8---filesystem-changes-applicationdatadirectory-vs-webview
my app used to work like this (up to iOS7):
a webview is loading a local webpage. Some json files are copied to applicationDataDirectory and if the user makes an "internal update" newer files get pulled from the internet into the applicationDataDirectory. The webview now opens the json files from there to have the newest files. For this I've just added '../Documents' in front of the files (inside the webpage local js files). That was working fine. But in iOS8 it looks like the content is in two seperate folders now:
webview:
../Library/Developer/CoreSimulator/Devices/30.../data/Containers/Bundle/Application/E83.../Documents/file.json
applicationDataDirectory:
../Library/Developer/CoreSimulator/Devices/30.../data/Containers/Data/Application/F97../Documents/file.json
notice that it is now "Data" instead of "Bundle" and even a different ID. So how can I get from the webview folder to the writeable folder now?
Even if I copy a index.html to applicationDataDirectory and try to set the webview url to that file it won't open.
Passing the applicationDataDirectory into the webview page and setting the filepath via javascript won't load the file
Some more infos about the problem:
Apple Doc: https://developer.apple.com/library/ios/technotes/tn2406/_index.html
Tech Republica: http://www.techrepublic.com/article/why-ios-8-could-break-your-hybrid-mobile-app/
Stackoverflow Thread: http://stackoverflow.com/questions/25794747/xcode-6-ios-8-simulator-data-and-bundle-folder-script
Blog post: http://hetzel.net/2014-09-18/ios-8-folder-structure/
Can't reproduce
Can't reproduce this issue. See below for code used to try to reproduce this issue. If this issue persists, please provide example code that we can use to reproduce the issue. *Steps to followed* 1. Create the 4 files below in theResources
directory of your app 2. Launch the app and clickload
(see a blue background...the css loaded) 3. Click theClick Me!
button (see an alert dialog...the js file loaded)Thank you for the testcase. That worked! Is it still possible to access the test.css/test.js file inside the applicationDataDirectory when the index.html is inside the Ressource folder? Or do I have to copy all files from Ressource to applicationDataDirectory first? On iOS7 you could just add "../Documents" before locally referenced files.
Not a problem. No, the folders have actually been moved which is why your workaround stopped working. You would have to figure out what the relative path is and use that, but Apple says that you should not do that [here](https://developer.apple.com/library/ios/technotes/tn2406/_index.html).
Even if you ignore what Apple says and could get it to work, there is no guarantee that it won't break again in the future. Copying all of the files over is definitely the way to do it.