Hello, dear friends,

Today, when I uploaded IPA to Appstore for pre-review, I received an email, only to know that Apple will stop accepting apps using UIWebView API in April 2020. Therefore, you may receive emails with similar contents when uploading the APP, as shown in the picture:

Here it should be emphasized that although the online app will receive this reminder email, it will not affect the release of the app (the premise of app approval). If it is the first time online, that impact is big, direct rejection. So we should solve this problem completely and not leave technical debt.

I. Introduction to the environment

Our project is a React-native project. I will first describe the software and hardware environment that the project relies on:

React-native: '0.50.0' node: '10.16.3' JDK: '1.8.0_73' MACOS: '10.14.6' Xcode: '11.3' androidStudio: '3.5' vscode: '1.38.0' Global installation: react-native CLI, yarnCopy the code

Two, problem investigation:

Run grep -r UIWebView in the root directory. Detect components and SDKS that use UIWebView.

Iii. Selected Schemes:

Use react-native WebView: ‘8.0.0’ to replace the webView component in the code.

yarn add react-native-webview --save  
react-native link react-native-webview     
import { WebView } from 'react-native-webview';
Copy the code

After the replacement, I found that the project depends on the SDK, because the version is a little old, it still depends on UIWebview. At this time, download the latest SDK and replace it directly.

Four, encountered pit:

Ios simulator Could not find iPhone * simulator

Find projects node_modules/react - native/local cli/runIOS/findMatchingSimulator js 1, the if (version. IndexOf (' iOS)! == 0) is replaced by if (! Version. includes("iOS")) 2, if(simulator. Availability! =='(available)') replace with if(simulator. IsAvailable! Run the react-native run-ios --simulator="iPhone *Copy the code

If you don’t want to specify an emulator, you can set up an iPhone-6 emulator in Xcode. You can then run react-native run-ios directly.

(2) Config. h error when run react-native run-ios.

CD node_modules/react-native/third-party/glog-0.3.4 Run.. /.. /scripts/ios-configure-glog.shCopy the code

PCH was compiled with Module cache path

The problem is a cache cache collision caused by the copy project

Delete the ios/build file and rebuild rm -rf ios/buildCopy the code

(4) Compatibility problem of Android project. If you use Android X in your project, you can ignore this problem.

Androidx: androidX: androidX: androidX: androidX

     import android.support.annotation.RequiresApi;
     import android.support.v4.content.ContextCompat;
     import android.support.v4.content.FileProvider;
Copy the code

(5) the android project DexArchiveMergerException: Unable to merge dex problem

Add defaultConfig {multiDexEnabled true} to gradle of main project add Google ()Copy the code

Conclusion:

Because every project depends on different software and hardware environments. If you encounter other problems after following the above plan, you can leave a message. We worked on it together.