iOS

Easily set DeviceSupport to build new OS devices that are not eligible for Xcode

xcode-device-support-set-en

Easily set DeviceSupport to build new OS devices that are not eligible for Xcode

I think that it is common to build and develop a real machine with Xcode and real machine devices, but once occasionally, the device's OS was updated to the latest version and you can not build it with Xcode!
Isn't there a lot of iOS engineers who have experienced?

Xcode is determined by the version of the OS that can be built, and for example, Xcode12.4 can not build iOS14.5 and later devices.
This is because the Xcode does not have a file of a version of the operating system. called DeviceSupport.
If you look at the Xcode.app/content/developer/platforms/iPhoneos.platform/devicesupport/ directory, the DeviceSupport file for each version is provided as follows. xcode-device-support-set-0
There is no problem if you can download and use the new version of Xcode as described above, but for example, the team you participate in want to use the specific version of Xcode or you do not have time to download the new Xcode, you can use it by adding new DeviceSupport file of new device version.
By the way, the above capture is that of Xcode12.5, but a 14.6 file is added.
But if you want to add, you don't know where you should get this DeviceSupport file in the first place, and it is also troublesome to set this deep hierarchy every time.

So this time, I created a script that sets a specific version of DeviceSupport to the corresponding Xcode.

Download DeviceSupport and set scripts to set in the specified directory

Place the script first.

## Specify the iOS and Xcode version, download the DeviceSupport file and set it in the corresponding version Xcode ($1: iOS version, $2: Xcode version path)
function setDeviceSupport() {
  # null check of arg1
  if [ -z "$1" ]; then
    echo "arg1(iOS version number) is required! e.g. 14.6"; return
  fi
  # null check of arg2
  if [ -z "$2" ]; then
    echo "arg2(xcode version number) is required! e.g. 12.5"; return
  fi
  which svn
  # ①
  echo "Clone $1 DeviceSupport zip from https://github.com/filsv/iPhoneOSDeviceSupport"
  svn export https://github.com/filsv/iPhoneOSDeviceSupport/trunk/$1.zip
  # ②
  unzip $1.zip
  # ③
  mv -f ./$1 /Applications/Xcode$2.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
  # ④
 rm -f $1.zip
  rm -f -r __MACOSX
  echo "Set $1 Device Support file to Xcode$2!"
}

When using, set parameters as in setDeviceSupport 14.6 12.5 and run only

First download the DeviceSupport file in ①.
The list of Device files is uploaded to the following site, so download from here.


Sometimes it is not uploaded if it is a version of Xcode just released.

When downloading the file, this script uses svn (I don't know if this is the best way...)
So if you use the above script, you need to install svn in like brew install svn.

This script have unzipped the file downloaded in ②.
Moving the file to the specified directory in ③.
④ removes unnecessary files.
__MACOSX seems to be a file generated during the compression process, but it is unnecessary, so remove it.
After that, copy this script to the .zshrc file in the Mac home directory, restart the terminal or run source ~ / .zshrc.

Finally, if you restart Xcode, the change will be reflected in Xcode, so you will be able to build a real machine🎉.

The above code is uploaded to the following GitHub repository (I'm glad to add star to it☺️)

If you add the script as described above to .zshrc file, the code will expand more and more and become difficult to manage.
Therefore, as in the repository introduced in the following Mac environmental construction automation articles, I think that management will be easier to manage by each file.
The above files in GitHub is one of the Xcode-related scripts files.

In the future, not only this script but also the work I thought that it was troublesome is first scripted as much as possible, and I want to make it easy for the second time

+1

COMMENT

Your email address will not be published.

CAPTCHA