How iOS 8 could break your hybrid mobile app

Apple paved the way for better-performing hybrid apps on the iPhone and iPad by introducing the WKWebView API in iOS 8 earlier this year.

Hybrid apps are so called because they are built using web technologies such as HTML, CSS and JavaScript but run inside a wrapper of native code, which allows installation from app stores and access to device-specific features, such as the camera.

The WKWebView API is significant as it lets hybrid apps running on iOS 8 take advantage of the same optimisations as the Safari web browser, allowing for about a 20 percent performance boost over apps using the old UIWebView API.

However, developers hoping to exploit this new API will need to work around a bug that breaks a common way for loading local files from the device.

The bug, present since iOS beta 4, prevents apps using the WKWebView from loading a file with the file://URL protocol.

This flaw means the app will not load a file URL from the app's sandbox as expected, affecting non-HTML files stored in Documents, Library, Library/Caches, tmp and app bundle.

The fault may not be immediately obvious as while the protocol works for loading files on the iOS 8 simulator used to test apps, it doesn't work on actual iOS 8 devices.

A bug report has been filed via Open Radar and remains open at the time this article was published.

What's being done to fix it?

Given the bug has been present since iOS beta 4 and Apple hasn't commented, third-party developers have been looking at workarounds to allow hybrid apps to load local assets.

Developers working on the Apache Cordova framework, which simplifies the creation of hybrid apps on smartphones and is the basis for the widely-used PhoneGap, are looking at creating a plugin to load files using a local webserver.