版本 2
库已从零开始完全重写。此版本仍然提供 Deviice
结构,但已标记为已弃用,将在未来版本中删除。现在,所有的魔法都是通过 Device
类完成的。
用法
代码中所有类、方法和属性的文档。为了给出一个大致的想法,事情是这样的工作的。
let device = Device.init() // This instantiate a `Device` object based on the current device.
print(device.model.marketingName) // This prints "iPhone 12 Pro" in case it is running on an iPhone 12 Pro
还有可能获取正在模拟的 Mac 上的实际设备。
let device = Device.init()
print(device.model.marketingName) // This will print "Simulator"
print(device.actualModel.marketingName) // This will print "iPhone 12 Pro" in case you're simulating an iPhone 12 Pro
在第一个版本中,无法获取特定设备的连接类型。这可能会稍后添加。
要求
此库在 iOS 12 或更高版本上运行。
安装
设备可通过Swift包管理器和CocoaPods获取。
Swift包管理器
您可以通过Swift包管理器,使用此url https://github.com/andrealufino/Deviice
添加此库。
CocoaPods
要安装它,只需将以下行添加到您的Podfile
pod "Deviice"
作者
Andrea Mario Lufino,andrealufino.com。感谢所有贡献者。
许可证
Deviice遵循MIT许可证。有关更多信息,请参阅LICENSE文件。