iOS swift 获取 app 打包时间 版本 手机系统
2018-03-26 16:47
706 查看
因为提交给测试的测试包太多 出问题的包可能会混
所以加了个打包时间 和其他的一些app 和手机信息 方便测试在提BUG的时候带上
1. 在 Xcode 工程对应 Target 的 build Phases 中新增 run Scrpit Phase
2 创建 buildTime.pilst
3 创建shell脚本
#!/bin/shset -e# plist 文件地址PLIST_PATH="./iTour/BuildTime.plist"BUILD_TIME_KEY=":BuildTime"BUILD_TIME_VALUE="$(date +%Y年%m月%d日%H时%M分%S秒)"
if [ -r "${PLIST_PATH}" ]; then /usr/libexec/PlistBuddy -c "Set ${BUILD_TIME_KEY} ${BUILD_TIME_VALUE}" "${PLIST_PATH}"else /usr/libexec/PlistBuddy -c "Add ${BUILD_TIME_KEY} string ${BUILD_TIME_VALUE}" "${PLIST_PATH}" fi
4 取时间
单取个时间 挺麻烦 我就都贴上了
struct AppInfo { static let AppName = "" static let SystemType = "ios" static let ChannelSource = "App store" static let VersionName = String(describing: Bundle.main.infoDictionary!["CFBundleShortVersionString"]!) static let VersionCode = String(describing: Bundle.main.infoDictionary!["CFBundleVersion"]!) static let BundleIdentifier = Bundle.main.bundleIdentifier! static let KmilesBuildTime: String? = { if let path = Bundle.main.path(forResource: "BuildTime", ofType: "plist"), let dic = NSDictionary(contentsOfFile: path) as? [String: AnyObject], let result = dic["BuildTime"] as? String { return result } return nil }() static let IPhoneOS: String = { return UIDevice.current.systemVersion }() static let IPhoneType: String = { var systemInfo = utsname() uname(&systemInfo) let machineMirror = Mirror(reflecting: systemInfo.machine) let identifier = machineMirror.children.reduce("") { identifier, element in guard let value = element.value as? Int8, value != 0 else { return identifier } return identifier + String(UnicodeScalar(UInt8(value))) } switch identifier { case "iPod5,1": return "iPod Touch 5" case "iPod7,1": return "iPod Touch 6" case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4" case "iPhone4,1": return "iPhone 4s" case "iPhone5,1", "iPhone5,2": return "iPhone 5" case "iPhone5,3", "iPhone5,4": return "iPhone 5c" case "iPhone6,1", "iPhone6,2": return "iPhone 5s" case "iPhone7,2": return "iPhone 6" case "iPhone7,1": return "iPhone 6 Plus" case "iPhone8,1": return "iPhone 6s" case "iPhone8,2": return "iPhone 6s Plus" case "iPhone9,1": return "iPhone 7" case "iPhone9,2": return "iPhone 7 Plus" case "iPhone10,1","iPhone10,4": return "iPhone 8" case "iPhone10,2","iPhone10,5": return "iPhone 8 Plus" case "iPhone10,3","iPhone10,6": return "iPhone X" case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4":return "iPad 2" case "iPad3,1", "iPad3,2", "iPad3,3": return "iPad 3" case "iPad3,4", "iPad3,5", "iPad3,6": return "iPad 4" case "iPad4,1", "iPad4,2", "iPad4,3": return "iPad Air" case "iPad5,3", "iPad5,4": return "iPad Air 2" case "iPad2,5", "iPad2,6", "iPad2,7": return "iPad Mini" case "iPad4,4", "iPad4,5", "iPad4,6": return "iPad Mini 2" case "iPad4,7", "iPad4,8", "iPad4,9": return "iPad Mini 3" case "iPad5,1", "iPad5,2": return "iPad Mini 4" case "iPad6,7", "iPad6,8": return "iPad Pro" case "AppleTV5,3": return "Apple TV" case "i386", "x86_64": return "Simulator" default: return "Unknown" } }()}
遮住的只是我的app名字 没有影响
所以加了个打包时间 和其他的一些app 和手机信息 方便测试在提BUG的时候带上
1. 在 Xcode 工程对应 Target 的 build Phases 中新增 run Scrpit Phase
2 创建 buildTime.pilst
3 创建shell脚本
#!/bin/shset -e# plist 文件地址PLIST_PATH="./iTour/BuildTime.plist"BUILD_TIME_KEY=":BuildTime"BUILD_TIME_VALUE="$(date +%Y年%m月%d日%H时%M分%S秒)"
if [ -r "${PLIST_PATH}" ]; then /usr/libexec/PlistBuddy -c "Set ${BUILD_TIME_KEY} ${BUILD_TIME_VALUE}" "${PLIST_PATH}"else /usr/libexec/PlistBuddy -c "Add ${BUILD_TIME_KEY} string ${BUILD_TIME_VALUE}" "${PLIST_PATH}" fi
4 取时间
单取个时间 挺麻烦 我就都贴上了
struct AppInfo { static let AppName = "" static let SystemType = "ios" static let ChannelSource = "App store" static let VersionName = String(describing: Bundle.main.infoDictionary!["CFBundleShortVersionString"]!) static let VersionCode = String(describing: Bundle.main.infoDictionary!["CFBundleVersion"]!) static let BundleIdentifier = Bundle.main.bundleIdentifier! static let KmilesBuildTime: String? = { if let path = Bundle.main.path(forResource: "BuildTime", ofType: "plist"), let dic = NSDictionary(contentsOfFile: path) as? [String: AnyObject], let result = dic["BuildTime"] as? String { return result } return nil }() static let IPhoneOS: String = { return UIDevice.current.systemVersion }() static let IPhoneType: String = { var systemInfo = utsname() uname(&systemInfo) let machineMirror = Mirror(reflecting: systemInfo.machine) let identifier = machineMirror.children.reduce("") { identifier, element in guard let value = element.value as? Int8, value != 0 else { return identifier } return identifier + String(UnicodeScalar(UInt8(value))) } switch identifier { case "iPod5,1": return "iPod Touch 5" case "iPod7,1": return "iPod Touch 6" case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4" case "iPhone4,1": return "iPhone 4s" case "iPhone5,1", "iPhone5,2": return "iPhone 5" case "iPhone5,3", "iPhone5,4": return "iPhone 5c" case "iPhone6,1", "iPhone6,2": return "iPhone 5s" case "iPhone7,2": return "iPhone 6" case "iPhone7,1": return "iPhone 6 Plus" case "iPhone8,1": return "iPhone 6s" case "iPhone8,2": return "iPhone 6s Plus" case "iPhone9,1": return "iPhone 7" case "iPhone9,2": return "iPhone 7 Plus" case "iPhone10,1","iPhone10,4": return "iPhone 8" case "iPhone10,2","iPhone10,5": return "iPhone 8 Plus" case "iPhone10,3","iPhone10,6": return "iPhone X" case "iPad2,1", "iPad2,2", "iPad2,3", "iPad2,4":return "iPad 2" case "iPad3,1", "iPad3,2", "iPad3,3": return "iPad 3" case "iPad3,4", "iPad3,5", "iPad3,6": return "iPad 4" case "iPad4,1", "iPad4,2", "iPad4,3": return "iPad Air" case "iPad5,3", "iPad5,4": return "iPad Air 2" case "iPad2,5", "iPad2,6", "iPad2,7": return "iPad Mini" case "iPad4,4", "iPad4,5", "iPad4,6": return "iPad Mini 2" case "iPad4,7", "iPad4,8", "iPad4,9": return "iPad Mini 3" case "iPad5,1", "iPad5,2": return "iPad Mini 4" case "iPad6,7", "iPad6,8": return "iPad Pro" case "AppleTV5,3": return "Apple TV" case "i386", "x86_64": return "Simulator" default: return "Unknown" } }()}
遮住的只是我的app名字 没有影响
相关文章推荐
- iOS获取手机上安装的APP的名称和版本
- ios获取手机型号、系统版本、设备唯一标识符、手机运营商等
- Android获取手机型号,系统版本,App版本号等信息
- Android获取手机型号,系统版本,App版本号等信息
- ios项目有关的系统 uuid,系统版本号,手机型号,获取当前时间……
- iOS 获取当前APP名称版本手机型号
- IOS下获取时间、手机系统时区以及获取时间间隔
- 获取Android手机型号,系统版本,App版本号等信息
- iOS 获取手机型号,系统版本
- Android获取手机型号,系统版本,App版本号等信息
- iOS 获取手机型号,系统版本
- iOS 获取手机系统时间
- Android获取手机型号,系统版本,App版本号等信息
- iOS 获取手机的型号,系统版本,设备名称等
- Android获取手机型号,系统版本,App版本号等信息
- iOS 获取手机型号,系统版本
- ios获取手机型号、系统版本、设备唯一标识符、手机运营商等
- iOS_获取设备型号、手机系统版本
- iOS OC 及 Swift 获取手机型号,系统版本
- iOS 获取手机型号,系统版本