RNDeviceName

用于获取 Apple 设备型号名称的 Swift 微型库。

从 Apple 设备获取市场营销名称,例如 “iPhone 13 mini”。

安装

CocoaPods

CocoaPods 要使用 CocoaPods 将 RNDeviceName 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

pod 'RNDeviceName'

Swift Package Manager

Swift Package Manager 一旦您设置好 Swift 包管理器,

  1. RNDeviceName 添加到您的 Package.swiftdependencies 值中。
dependencies: [
    .package(url: "https://github.com/souzainf3/RNDeviceName.git", .upToNextMajor(from: "1.1.0")) // set you tag or branch
]
  1. 打开 Swift Package Manager,复制 https://github.com/souzainf3/RNDeviceName 到搜索栏。对于版本,您可以使用标签或 master 分支。

手动

  1. Sources 文件夹拖到您的项目中

用法

UIDevice 扩展

UIDevice.current.marketingName // such as `iPhone 13 mini`

Device 类

Device.current.marketingName // such as `iPhone 13 mini`

参考

设备型号列表,需要使用 SQLite 查看 traits 数据库

在线 SQLite 查看器 https://inloop.github.io/sqlite-viewer/```

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/standalone/device_traits.db
/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/usr/standalone/device_traits.db
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/usr/standalone/device_traits.db