今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

Add iOS 10.x simulator to Xcode 12.x.

Adding iOS 10.x Simulator to Xcode 12.x#

Background#

Yesterday, I encountered a problem where a webpage would display a white screen on an iOS 10.3.1 device. However, I didn't have a 10.x version device on hand, so I wanted to install a simulator to try to reproduce the issue.

However, I found that the Xcode version on my computer was 12.5.1, which no longer supports downloading the iOS 10.3.1 simulator.

Steps#

Download iOS 10.3.1 Simulator#

After searching, I found that Xcode 12.4 still supports downloading the iOS 10.3.1 simulator. So I went to the Xcode download website, downloaded Xcode 12.4, and then opened Xcode preferences with CMD + ,. In the Components tab, I found and downloaded the iOS 10.3.1 Simulator, as shown in the following image.

wecom20210715-161409.png

Add iOS 10.3.1 Simulator#

To add a simulator, select Xcode, go to the top menu, choose Window -> Device and Simulators, select Simulators, and click the "+" button in the bottom left corner to add a simulator, as shown in the following image.

screen shot 2021-07-15 at 16.19.20.png

You may notice that even after downloading the iOS 10.3.1 simulator, you still can't add it. You downloaded it, but you can't add it.

x5ltb.png

So I continued to search and finally came across the only article that tells the truth, Running Lower Version iOS Simulators in Xcode 12. According to the article, the map file in the runtime version framework of the simulator sets the upper limit of the corresponding Mac OS system for each version, which prevents it from being added.

The solution is to modify the CFBundleIdentifier in the simulator's Info.plist to bypass the map file.

The specific method is very simple. Close the simulator and Xcode. For example, if I want to force the execution of the 10.3 simulator, I edit /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.3.simruntime/Contents/Info.plist and change CFBundleIdentifier from com.apple.CoreSimulator.SimRuntime.iOS-10-3 to com.apple.CoreSimulator.SimRuntime.iOS-10-3-1. By adding a -1 at the end, the function that checks the version restriction cannot find the bundle name, and then you can open Xcode and add it!

My practical experience:

  1. Modifying the Plist can be done by copying it out, making the changes, and then copying it back to replace the original.
  2. After modification, the 10.3 simulator can indeed be added and operated normally on macOS 11.4.
  3. Even if the modification is successful and the 10.3 simulator is added, it cannot be run on macOS 12.0 beta, also known as macOS Monterey.

Reference#

Running Lower Version iOS Simulators in Xcode 12

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.