System Save, Load and local storage do not work after compile with to iOS (webview mode)


So I tried this just now and it didn’t help.

I had Cocoon version set to ‘latest’. So first I tried setting this to specifically say: 2.1.0
Doing that added the following line to my config:

That line was not present in my config.xml previously so I thought it might have helped. But on compiling the game and testing on my Apple test device, the problem persists: localstorage data is lost on closing the app.

I tried the same thing with Cocoon version set to 2.0.0, compiled and tested the game, again with the same result.

I really need some input on this from the Cocoon devs please? @Blue_Sialia @imanolm1


I tested my game with Canvas+ and I can confirm that localstorage does work with Canvas+, but it introduces all sorts of other problems. Basically my game works best with Webview+ so I want to stick with it… I really need this problem fixed devs???


This is very important to be fixed, I’m on your side.
@imanolm1 any chances to get feedback on that matter?

Thank you!



Devs no comment on this? Can you please respond to this issue? It seems to be affecting quite a few people!
@imanolm1 @Blue_Sialia


I think I know why it didn’t work. iOS webview+ uses the wkwebview to give better performance. I found a post that says the wkwebview does not allow local files to save to local storage. Here is the link

Yes the devs here should have found this and like usual you literally have to solve everything for them to get anything to work

(iOS) Webstorage or Localstorage not work on WebView+

@j.c.durf Hey man thanks for posting that information!

So, wkwwebview by itself should not be a problem right? I have been using wkwebview in my game that was built in XDK and there is no problem with localstorage at all.

So it seems like it could be a problem with how wkwebview is deployed in WebView+ specifically?

We dont want to stop using wkwebview because we need the improved performance it provides…

@imanolm1 @Blue_Sialia What do you guys think about this? Could the link that j.c.durf posted above help you guys narrow down a cause of this problem with localstorage when using WebView+?


We need a fix for this, guys! This bug is still present.


Yes. This critical bug… Need fix


Yes this makes webview unusable for iOS. I hope @andoni.martin @imanolm1 @Blue_Sialia and @mortimergoro will have a look at this matter soon…



Lets see if we can’t help cocoon again. I told them that the problem is in wkwebview and local files link to post.

I found an issue posted on the Cordova Jira. The quote that stood out in regards to iOS local storage giving security error:

"The preference “WebKitAllowUniversalAccessFromFileURLsPreferenceKey” needs to be set to true for localStorage to work on iOS (by default this setting in WKSecurityOrigin is false):
(although it is set true here, for macOS). I don’t think we can override this by setting a NSUserDefaults preference (although I haven’t tried).
Similarly to the problem with loading local files in iOS 8 which was remedied in iOS 9 with "loadFileURL:allowingReadAccessToURL:“
… Apple will need to add a configuration setting for this. So far in the WebKit code I don’t see anything for this yet.”

here is the link to the jira local storage ios issue


found this post here that is interesting. it says local storage clears when app exits. link


this helps phonegap keep local storage even after app is reopened.


this looks like it could help get around the bug:


It looks like apple has fixed the bug in wkwebview that stopped local files from being able to access localStorage: webkit. This means that the wkwebview should allow it to work.

This means the bug is caused by either:

  • the wkwebview version currently installed in ios might not have this patch yet
  • cocoon/cordova has a bug above the wkwebview that stops local storage from working
  • last but not least Aliens hell bent on the destruction of human kind are stopping local storage on ios just for funsies


This thread is just a fun read on the matter: apple forum.


Oh good info @j.c.durf I havent tried exporting to iOS for a while, since getting stuck on this issue. Ill give it a try when I have time to see if the localStorage issue is resolved.


Im updating to ios 11 to test the local storage. we will see if apple has been hard at work.


ios 11 still doesn’t work


to get around this issue I’m using a plugin called Native Storage.


Is that plugin working for you @j.c.durf? Are you building your game in C2? Do you know if it would it be possible to use that Native Storage plugin with C2 games?