如何在 Xcode 中将兼容设备设置为仅兼容 ARKit 的设备?

How do I set compatible devices to only ARKit compatible devices in Xcode?

如何确保我在 iOS AppStore 上的应用程序仅显示对支持 ARKit 的设备的兼容性?

所需设备功能下的 info.plist 文件的密钥是 arkit

Apple documentation on plist keys (UIRequiredDeviceCapabilities).

Key: arkit

Description: Include this key if your app requires support for ARKit on the device (that is, an iOS device with an A9 or later processor).

Minimum version: iOS 11.0

对现有应用程序的一个重要警告是,Apple 不允许您在应用程序发布后限制设备。

Important: All device requirement changes must be made when you submit an update to your binary. You are permitted only to expand your device requirements. Submitting an update to your binary to restrict your device requirements is not permitted. You are unable to restrict device requirements because this action will keep customers who have previously downloaded your app from running new updates.

如果您要向现有应用程序添加 AR 功能,您可以使用 isSupported property of ARKit 来确定是否应该公开此功能。

If your app requires ARKit framework for its core functionality, then you need to open info.plist file (located inside your project's folder in macOS Finder) and under the key UIRequiredDeviceCapabilitie add a string arkit like that:

<plist version="1.0">
  <dict>
    <key>UIRequiredDeviceCapabilities</key>
      <array>
        <string>arkit</string>
      </array>
  </dict>
</plist>

But if Augmented Reality is a secondary feature of your app, then use this lines in ViewController.swift. Here's how your code should look like:

if ARWorldTrackingConfiguration.isSupported {   
     
    let configuration = ARWorldTrackingConfiguration()             // 6DOF
    configuration.planeDetection = [.horizontal, .vertical]
    sceneView.session.run(configuration) 

} else {  

    let configuration = AROrientationTrackingConfiguration()       // 3DOF
    sceneView.session.run(configuration)  
    print("This chipset does not meet the minimum requirements.")
}

兼容 ARKit 4.0 的 iPhone 列表如下(A9...A13 CPU):

  • iPhone6s
  • iPhone SE
  • iPhone 7
  • iPhone 8
  • iPhone X
  • iPhone SE2
  • iPhone11
  • ...及更高