RNDeviceName
Swift 库,用于获取苹果设备型号名称。从苹果设备获取营销名称,例如 “iPhone 13 mini。”
安装
CocoaPods
CocoaPods 使用 CocoaPods 将 RNDeviceName 集成到您的 Xcode 项目中时,在您的 Podfile
中指定它
pod 'RNDeviceName'
Swift 包管理器
Swift 包管理器 在您设置 Swift 包之后,
- 将
RNDeviceName
添加到您的Package.swift
中的dependencies
值。
dependencies: [
.package(url: "https://github.com/souzainf3/RNDeviceName.git", .upToNextMajor(from: "1.0.0")) // set you tag or branch
]
- 打开 Swift 包管理器,将 https://github.com/souzainf3/RNDeviceName 复制到搜索栏。对于版本,您可以使用标签或 master 分支。
手动
- 将
Sources
文件夹拖到您的项目中
使用方法
获取苹果设备的营销名称,例如 “iPhone 13 mini”
UIDevice 扩展
UIDevice.current.marketingName // iPhone 13 Mini
设备类
Device.current.marketingName // iPhone 13 Mini
参考资料
https://support.apple.com/en-us/HT201296 (iPhone) https://support.apple.com/en-us/HT201471 (iPad) https://support.apple.com/en-us/HT200008 (AppleTV) https://www.theiphonewiki.com/wiki/Models#iPad (非官方)
- 设备模型列表,需要使用 SQLite 查看特性数据库
- 在线 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