-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from czechboy0/hd/tested_devices_xcode_7
WIP: Xcode 7 Support
- Loading branch information
Showing
36 changed files
with
1,742 additions
and
1,437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github "czechboy0/DVR" "2742bb80be229da51b1c923c3d3e6eaadc129b8e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github "czechboy0/DVR" "2742bb80be229da51b1c923c3d3e6eaadc129b8e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192 changes: 192 additions & 0 deletions
192
XcodeServerSDK/Server Entities/DeviceSpecification.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
// | ||
// DeviceSpecification.swift | ||
// XcodeServerSDK | ||
// | ||
// Created by Honza Dvorsky on 24/06/2015. | ||
// Copyright © 2015 Honza Dvorsky. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public class DevicePlatform : XcodeServerEntity { | ||
|
||
let displayName: String | ||
let version: String | ||
|
||
public enum PlatformType: String { | ||
case Unknown = "unknown" | ||
case iOS = "com.apple.platform.iphoneos" | ||
case OSX = "com.apple.platform.macosx" | ||
case watchOS = "com.apple.platform.watchos" | ||
} | ||
|
||
public enum SimulatorType: String { | ||
case iPhone = "com.apple.platform.iphonesimulator" | ||
case Watch = "com.apple.platform.watchsimulator" | ||
} | ||
|
||
let type: PlatformType | ||
let simulatorType: SimulatorType? | ||
|
||
public required init(json: NSDictionary) { | ||
|
||
self.displayName = json.stringForKey("displayName") | ||
self.version = json.stringForKey("version") | ||
self.type = PlatformType(rawValue: json.optionalStringForKey("identifier") ?? "") ?? .Unknown | ||
self.simulatorType = SimulatorType(rawValue: json.optionalStringForKey("simulatorIdentifier") ?? "") | ||
|
||
super.init(json: json) | ||
} | ||
|
||
//for just informing the intention - iOS or WatchOS or OS X - and we'll fetch the real ones and replace this placeholder with a fetched one. | ||
public init(type: PlatformType) { | ||
self.type = type | ||
self.displayName = "" | ||
self.version = "" | ||
self.simulatorType = nil | ||
|
||
super.init() | ||
} | ||
|
||
public class func OSX() -> DevicePlatform { | ||
return DevicePlatform(type: DevicePlatform.PlatformType.OSX) | ||
} | ||
|
||
public class func iOS() -> DevicePlatform { | ||
return DevicePlatform(type: DevicePlatform.PlatformType.iOS) | ||
} | ||
|
||
public class func watchOS() -> DevicePlatform { | ||
return DevicePlatform(type: DevicePlatform.PlatformType.watchOS) | ||
} | ||
|
||
public override func dictionarify() -> NSDictionary { | ||
|
||
//in this case we want everything the way we parsed it. | ||
if let original = self.originalJSON { | ||
return original | ||
} | ||
|
||
let dictionary = NSMutableDictionary() | ||
|
||
dictionary["displayName"] = self.displayName | ||
dictionary["version"] = self.version | ||
dictionary["identifier"] = self.type.rawValue | ||
dictionary.optionallyAddValueForKey(self.simulatorType?.rawValue, key: "simulatorIdentifier") | ||
|
||
return dictionary | ||
} | ||
} | ||
|
||
public class DeviceFilter : XcodeServerEntity { | ||
|
||
var platform: DevicePlatform | ||
|
||
public enum FilterType: Int { | ||
case AllAvailableDevicesAndSimulators = 0 | ||
case AllDevices = 1 | ||
case AllSimulators = 2 | ||
case SelectedDevicesAndSimulators = 3 | ||
} | ||
|
||
let filterType: FilterType | ||
|
||
public enum ArchitectureType: Int { | ||
case Unknown = -1 | ||
case iOS_Like = 0 //also watchOS | ||
case OSX_Like = 1 | ||
} | ||
|
||
let architectureType: ArchitectureType //TODO: ditto, find out more. | ||
|
||
public required init(json: NSDictionary) { | ||
|
||
self.platform = DevicePlatform(json: json.dictionaryForKey("platform")) | ||
self.filterType = FilterType(rawValue: json.intForKey("filterType")) ?? .AllAvailableDevicesAndSimulators | ||
self.architectureType = ArchitectureType(rawValue: json.optionalIntForKey("architectureType") ?? -1) ?? .Unknown | ||
|
||
super.init(json: json) | ||
} | ||
|
||
public init(platform: DevicePlatform, filterType: FilterType, architectureType: ArchitectureType) { | ||
self.platform = platform | ||
self.filterType = filterType | ||
self.architectureType = architectureType | ||
|
||
super.init() | ||
} | ||
|
||
public override func dictionarify() -> NSDictionary { | ||
|
||
return [ | ||
"filterType": self.filterType.rawValue, | ||
"architectureType": self.architectureType.rawValue, | ||
"platform": self.platform.dictionarify() | ||
] | ||
} | ||
} | ||
|
||
public class DeviceSpecification : XcodeServerEntity { | ||
|
||
public let deviceIdentifiers: [String] | ||
public let filters: [DeviceFilter] | ||
|
||
public required init(json: NSDictionary) { | ||
|
||
self.deviceIdentifiers = json.arrayForKey("deviceIdentifiers") | ||
self.filters = XcodeServerArray(json.arrayForKey("filters")) | ||
|
||
super.init(json: json) | ||
} | ||
|
||
public init(filters: [DeviceFilter], deviceIdentifiers: [String]) { | ||
self.deviceIdentifiers = deviceIdentifiers | ||
self.filters = filters | ||
|
||
super.init() | ||
} | ||
|
||
/** | ||
Initializes a new DeviceSpecification object with only a list of tested device ids. | ||
This is a convenience initializer for compatibility with old Xcode 6 bots that are still hanging around on old servers. | ||
*/ | ||
public init(testingDeviceIDs: [String]) { | ||
|
||
self.deviceIdentifiers = testingDeviceIDs | ||
self.filters = [] | ||
|
||
super.init() | ||
} | ||
|
||
public override func dictionarify() -> NSDictionary { | ||
|
||
return [ | ||
"deviceIdentifiers": self.deviceIdentifiers, | ||
"filters": self.filters.map({ $0.dictionarify() }) | ||
] | ||
} | ||
|
||
// MARK: Convenience methods | ||
|
||
public class func OSX() -> DeviceSpecification { | ||
let platform = DevicePlatform.OSX() | ||
let filter = DeviceFilter(platform: platform, filterType: .AllAvailableDevicesAndSimulators, architectureType: .OSX_Like) | ||
let spec = DeviceSpecification(filters: [filter], deviceIdentifiers: []) | ||
return spec | ||
} | ||
|
||
public class func iOS(filterType: DeviceFilter.FilterType, deviceIdentifiers: [String]) -> DeviceSpecification { | ||
let platform = DevicePlatform.iOS() | ||
let filter = DeviceFilter(platform: platform, filterType: filterType, architectureType: .iOS_Like) | ||
let spec = DeviceSpecification(filters: [filter], deviceIdentifiers: deviceIdentifiers) | ||
return spec | ||
} | ||
|
||
public class func watchOS() -> DeviceSpecification { | ||
let platform = DevicePlatform.watchOS() | ||
let filter = DeviceFilter(platform: platform, filterType: .AllAvailableDevicesAndSimulators, architectureType: .iOS_Like) | ||
let spec = DeviceSpecification(filters: [filter], deviceIdentifiers: []) | ||
return spec | ||
} | ||
} | ||
|
Oops, something went wrong.