Luminous为您提供了许多有关系统的信息以及许多方便的方法,可以在iOS平台上快速获取有用的数据
发光
例
若要运行示例项目,请克隆存储库,然后首先从示例目录运行。pod install
要求
- iOS 8+
- 斯威夫特 5
- Xcode 10
安装
Luminous可通过CocoaPods和Swift Package Manager获得。
可可豆荚
要安装它,只需将以下行添加到您的 Podfile 中:
pod "Luminous"
然后在您想要使用库的任何位置使用。import Luminous
Swift Package Manager
要将 Luminous 添加到您的 Xcode 项目中,请选择 File -> Swift Packages -> Add Package Depedancy。输入网址。选中使用分支选项并输入 。https://github.com/andrealufino/Luminous
master
手动地
Download the project and drag all the files present in into your project. The library depends from the Deviice framework. Download it and do the same with it (dragging ).Luminous -> Luminous -> Sources
Deviice.swift
Dependencies
Luminous has only 1 dependency : Deviice which is my other library useful to know on which device your app is running on, plus some nice information.
Migration to version 2
In version 2, I’ve changed some things and added others. An important change has been made to the structure of the library, useful for who wants to contribute to the project and to who wants to fork it. I created a specific file () for every substruct.extension
Changed
LMBatteryState
has been renamed toBatteryState
LMSizeScale
has been renamed toMeasureUnit
Luminous.Carrier.allowsVOIP
has been renamed toisVoipAllowed
Luminous.Hardware.physicalMemory(withScale: _)
now returns a and no more aDouble
Float
- All the structs are now accessible using as I removed the middleware struct since it became useless
Luminous.
System
NSLocale
is no more used in the library. I switched toLocale
Disk
substruct now has a new method to return the , and that takes a parameter as input. The old vars that returned and percentage have been deprecated and will be removed in the next versiontotalSpace
freeSpace
usedSpace
MeasureUnit
String
Added
Audio
(thanks to GregOriol)currentAudioOutputVolume
secondaryAudioShouldBeSilencedHint
SystemVersion
(from version 2.1.0) : this has been added under the struct and represents the system versionHardware
What is Luminous?
Luminous is the son of ALSystemUtilities library which is no longer maintained (it still is my best library on github). I got ideas from that one and I wrote everything from scratch in Swift adding some new feature and designing it in a different way thanks to the differences between Objective-C and Swift.
Luminous is a big library that I like to consider an “Helper Library”. It provides a lot of information about the system and has some features that can speed up significantly the development process.
It is composed by 3 parts : – system information ( Luminous.System.
)– utils (some handy method like the email check) – custom app configuration
Luminous is no more composed by 3 parts as I think that a library has to serve one and one only purpose. I removed the Utils and AppConfiguration structs. I’m sorry for any kind of inconvenience this could cause to everyone is using it, but I think that it’s the right choice.
System information
Here I provide tons of information about the system and you can access them using the notation .Luminous.
There are 11 different substructs here from which you can get information :
Network
isConnectedViaWiFi
isConnectedViaCellular
SSID
(deprecated on iOS 13)
Locale
currentLanguage
currentTimeZone
currentTimeZoneName
currentCountry
currentCurrency
currentCurrencySymbol
usesMetricSystem
decimalSeparator
Carrier
name
ISOCountryCode
mobileCountryCode
networkCountryCode
(deprecated, use instead)mobileNetworkCode
mobileNetworkCode
allowsVOIP
Hardware
SystemVersion
structprocessorsNumber
activeProcessorsNumber
physicalMemory
systemName
systemVersion
(this is a struct from version 2.1.0, no more aSystemVersion
String
)bootTime
isLowPowerModeEnabled
Screen
brightness
isScreenMirrored
nativeBounds
nativeScale
bounds
scale
snapshotOfCurrentView
Device
current
(returns a Deviice object)identifierForVendor
orientation
Accessory
count
connectedAccessoriesNames
connectedAccessories
Sensors
isAccelerometerAvailable
isGyroAvailable
isMagnetometerAvailable
isDeviceMotionAvailable
Audio
currentAudioOutputVolume
secondaryAudioShouldBeSilencedHint
Disk
totalSpace
freeSpace
usedSpace
totalSpaceInBytes
freeSpaceInBytes
usedSpaceInBytes
freeSpaceInPercentage
usedSpaceInPercentage
Battery
level
state
Application
version
build
completeAppVersion
clipboardString
Why Luminous?
I’m sure you’re asking yourself “Why this library is called Luminous?”. Well, stop think about it. The reason is simple : I like the word “Luminous”, it gives me a unique feeling of something that is bright and awesome! So, I chose to call this lib in that way! But you can think that “Luminous is because this library will light up your way of development speeding up it and giving you more time for yourself”, this is more philosophical.
Help
Any suggestion would be really appreciated. The library is designed using structs and static functions, but I’m still not sure of this choice. I’m struggling if the best is to use static functions or static vars, so this is the first point you can help me with.
Author
Andrea Mario Lufino, [email protected].
License
Luminous is available under the MIT license. See the LICENSE file for more info.