/// 获取配置信息
///
/// - Parameter resource: 资源文件名
/// - Returns: content
func getConfiguration(resource: String) -> Any {
if let path = Bundle.main.path(forResource: resource, ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
return jsonResult
} catch {
// maybe lets throw error here
return []
}
}
return []
func appVersion() -> String {
guard let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String, let bundle = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
return ""
}
return "\(version):\(bundle)"
}
赏个喜欢😍再走啊~~~