-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Xcode 7 Support #44
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2c0cd7f
adding new object, DeviceSpecification that is new to the API in Xcode 7
4546d1d
added device spec parsing
773a569
added missing files to ios
788a131
added throwing versions of map and filter
efa657e
Merge branch 'swift-2' into hd/tested_devices_xcode_7
59d0358
add new files to the watch framework target as well
fbd39de
added basic objects for the DeviceSpecification object: Filter and Pl…
b173a1d
codesign not
9b869da
Revert "codesign not"
d899407
parsing more things, trying to get a better understanding...
8a39af4
Merge branch 'swift-2' into hd/tested_devices_xcode_7
7f96a43
I think I cracked how to verify the server fingerprint and make the n…
ca3e2b0
- added blueprint credentials validation
8cf61bd
adopting new approach to bot creation, now with automatic blueprint v…
e8ebffd
whoops, debugging hack sneaked in
111d44f
- keep the original JSON of parsed objects
e230ecf
better default nil approach
10f2992
throws -> rethrows
270bec4
bot creation tested and works on Xcode 7! yayz.
23e2f74
not again, damn it
de6438a
pruning test data
239c6b2
project
ad1e5e2
added Carthfile and our first dependency - DVR. let's see how it goes.
f33492a
got DVR working! including nice plain text JSON saving to casettes! n…
128df49
- live tests of bot creation
96b33bf
creating bots works, i repeat, creating bots works on all 3 platforms…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or do you rather have it verbose with
if
/else
notation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in this case I prefer the longer, but simpler to understand solution. I actually prefer that most times, because the compiler reorders/optimizes the hell out of it anyway, so we can at least write readable code 😊 But thanks for the suggestion, that's a good way to write it really concisely.