IOS updated again!! All kinds of adaptation, compatibility of the workload suddenly came over, Mid-Autumn festival holiday I believe that many iOS developers are considering the completion of the new system compatibility as soon as possible. The iOS 10 Compatibility Notes blog post on wechat has been widely forwarded and read, which already contains the main compatibility points and solutions. The headache is the change of UILabel, which will bring some physical labor. In fact, apple has only standardized a lot of parts, which may be troublesome if it is not used in a standard way. Since the author is developing a Hybrid App, I would like to talk about the compatibility problems of Hybrid

1. Parameter type changes in UIWebViewDelegate callback methods

– (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error; The nullable modifier of the error parameter was removed from the original API. Unfortunately, if Xcode7 is simply removed, it will fail to compile, so we can only add a macro of the system version to determine.

2. Keychain causes the program to crash

The compiler failed to compile the program and crashed. The program crashed in the keychain store. The solution is to add “keychain Entitlements” as follows:




keychai entitlements

3. JSBridge that I have been using is not working anymore

Students who develop Hybrid App should know that tags are the key to communication between JS and native. In general, bridge.js will add and delete tags with the following codes:

var iFrame = document.createElement("IFRAME");  
iFrame.setAttribute("src","JSBridge://ActionId=" + id);    
document.documentElement.appendChild(iFrame);    
iFrame.parentNode.removeChild(iFrame);Copy the code

Then the UIWebView callback method – (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest (NSURLRequest *) request navigationType:(UIWebViewNavigationType)navigationType; To parse the ActionId value in the captured SRC attribute, but unfortunately on devices bundled with Xcode8 to iOS 10, the URL in the request parameter in UIWebView’s callback method is empty. The root cause of this problem is that the SRC attribute added dynamically does not conform to the URL format specification. The correct URL format specification should be ://host? Add a custom host string and the code changes as follows:

iFrame.setAttribute("src","JSBridge://customeHost? ActionId=" + id);Copy the code

I believe that the current problems are only part of the problem, and I hope we can discuss and study new problems together