Some notes when coding with iOS 13 (Part 2)

Tram Ho

UIWebView deprecated

After the release of iOS 13.0, the UIWebView description document indicated that UIWebView only supports iOS 2.0 to 12.0. Thus, Apple has officially deprecated UIWebView. The fact that UIWebView also has many bugs and performance is much worse than WKWebView.

From now on, if you update the app using UIWebView to the App Store, you will receive an email replying the ITMS-90809 code, suggesting that UIWebView has been removed. From the following update you will have to remove UIWebView from the app.

Dear Developer, We identified one or more issues with a recent delivery for your app, "xxx". Your delivery was successful, but you may wish to correct the following issues in your next delivery: ITMS-90809: Deprecated API Usage – Apple will stop accepting submissions of apps that use UIWebView APIs. See https://developer.apple.com/documentation/uikit/uiwebview for more information. After you've corrected the issues, you can use Xcode or Application Loader to upload a new binary to App Store Connect. Best regards, The App Store Team

Solution: Use WKWebView to replace the outdated UIWebView.

UISearchDisplayController crash

Before iOS 8.0, whenever we needed to display data in table view and have a search bar, we often used a combination of UISearchDisplayController and UISearchBar .

After iOS 8.0, Apple depreciated UISearchDisplayController and replaced the above combo with UISearchController . However, since iOS 13.0, the UISearchDisplayController has been completely removed from the SDK.

If you still deliberately use it, the app will crash with the following log infomation:

Solution: Use UISearchController instead of UISearchDisplayController.

MPMoviePlayerController deprecated

The MPMoviePlayerController class in MediaPlayer.framework has been used to play videos since before iOS 9.0. This class has been deprecated since iOS 9.0 and until now iOS 13.0 has been completely removed. If used, will throw the following exception:

Solution: Use AVPlayerViewController in AVKit .

Bluetooth request permission description changed

As the title suggests, from iOS 13.0, Apple changed the field name of the bluetooth permission description in Info.plist from NSBluetoothAlwaysUsageDescription to NSBluetoothPeripheralUsageDescription .

For apps with a deployment target of iOS 13 and later, use NSBluetoothAlwaysUsageDescription instead.

Updates that do not implement correctly will receive an email warning for ITMS-90683 code:

Dear Developer, We identified one or more issues with a recent delivery for your app, "xxx". Please correct the following issues, then upload again. ITMS-90683: Missing Purpose String in Info.plist-Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSBluetoothAlwaysUsageDescription key with a user-facing purpose string explaining clearly and completely why> your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these> APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more ( https://developer.apple.com/documentation/uikit/protecting_the_user_s_privacy ). Best regards, The App Store Team

Solution: Use both NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription keys for apps that support versions prior to 13.0.

For deployment targets earlier than iOS 13, add both NSBluetoothAlwaysUsageDescription and NSBluetoothPeripheralUsageDescription to your app's Information Property List file.

CNCopyCurrentNetworkInfo usage

Starting with iOS 12.0, the funtions in CNCopyCurrentNetworkInfo need to enable Access WiFi Information Entitlement in order to obtain the correct value.

But from iOS 13.0, this becomes even more difficult when the app needs to meet one of the following conditions:

  1. Use Core Location and grant location service permission.
  2. Use NEHotspotConfiguration to configure Wi-fi network settings.
  3. Using VPN.

Apple made such changes to protect the safety of users. Because the user's geographical location can easily be tracked based on the MAC address. Similarly, bluetooth devices also have MAC addresses, so Apple adds stricter permissions to using bluetooth permissions.

Solution: According to the above requirements is the simplest and easiest, we can use CoreLocation to grant location service permission and use the CNCopyCurrentNetworkInfo funtions.

LaunchImage deprecated

Before iOS 8.0, we used to use LaunchImage to set a set of launch images for our app. In LaunchImage there are many screen sizes corresponding to different images. Whenever a device has a new screen size, just add a new image to match it. This is quite manual and with the introduction of iOS 8.0, Apple introduced the concept of LaunchScreen , you can set up the loading screen of the app via Storyboard, which is very intuitive, easy and flexible with other screen sizes. together.

However, in the section Modernizing Your UI for iOS 13 , from April 2020, all apps on the App Store must require LaunchScreen.storyboard , no longer accept LaunchImage.

Solution: Use LaunchScreen.storyboard instead of LaunchImage.

UISegmentedControl default style changed

The default style of UISegmentedControl has changed: black text on white background, instead of white text on blue background.

Changing the tint color to the tintColor property will not work. Instead, use the new property selectedSegmentTintColor .

Project created by Xcode 11 runs black screen on lower version devices

Projects created with Xcode 11 when building the app and running on iOS devices <13.0 will display a black screen. This bug occurs because Xcode 11 uses the new, default UIScene concept to manage UIWindow .

Newly created project file outside AppDelegate , there will be more SceneDelegate file.

This is to prepare for multi-process and multi-screen implementations on the new iPadOS. UIWindow will no longer be a property in AppDelegate, but UIScene. Which iOS <13.0 does not have UIScene.

Solution: In the AppDelegate header add property:

WKWebView default popup style crash

As mentioned, since iOS 13.0, the modal view's default style has changed .

If the view controller has UIModalPresentationPageSheetstyle and uses WKWebView to browse to the photos library with HTML:

When clicking the select image button, the app will crash with the log:

The cause of this crash is because when you tap the button to browse the image, the system will present a UIDocumentMenuViewController with the default UIModalPresentationPopover style from a current UIViewController of the non-full screen type. So, need to define sourceView and sourceRect like barButtonItem on iPad.

Solution: Method 1: Set sourceView, sourceRect when present:

Method 2: Present full-screen view controller:

Source article: https://juejin.im/post/5d8af88ef265da5b6e0a23ac

Share the news now

Source : Viblo