| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // O2.swift
- // O2Platform
- //
- // Created by FancyLou on 2019/9/26.
- // Copyright © 2019 zoneland. All rights reserved.
- //
- import Foundation
- struct O2 {
- public static let O2_First_ID = "(0)"
- /// EZSE: Returns app's name
- public static var appDisplayName: String? {
- if let bundleDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String {
- return bundleDisplayName
- } else if let bundleName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String {
- return bundleName
- }
-
- return nil
- }
-
- /// EZSE: Returns app's version number
- public static var appVersion: String? {
- return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
- }
-
- /// EZSE: Return app's build number
- public static var appBuild: String? {
- return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as? String
- }
-
- /// EZSE: Return app's bundle ID
- public static var appBundleID: String? {
- return Bundle.main.bundleIdentifier
- }
-
- /// EZSE: Returns both app's version and build numbers "v0.3(7)"
- public static var appVersionAndBuild: String? {
- if appVersion != nil && appBuild != nil {
- if appVersion == appBuild {
- return "v\(appVersion!)"
- } else {
- return "v\(appVersion!)(\(appBuild!))"
- }
- }
- return nil
- }
-
- /// EZSE: Return device version ""
- public static var deviceVersion: String {
- var size: Int = 0
- sysctlbyname("hw.machine", nil, &size, nil, 0)
- var machine = [CChar](repeating: 0, count: Int(size))
- sysctlbyname("hw.machine", &machine, &size, nil, 0)
- return String(cString: machine)
- }
- }
|