8000 Merge pull request #57 from uber/swift-2 · uber-archive/jetstream-ios@96612c9 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 96612c9

Browse files
committed
Merge pull request #57 from uber/swift-2
Migrates Swift 1.2 to Swift 2.0. Drops objectice-c tests.
2 parents 05053e4 + fd0c380 commit 96612c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+531
-769
lines changed

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
language: objective-c
2-
xcode_project: Jetstream.xcodeproj
3-
xcode_scheme: Jetstream
4-
osx_image: xcode6.4
5-
xcode_sdk: iphonesimulator8.4
2+
osx_image: xcode7
3+
env:
4+
global:
5+
- LC_CTYPE=en_US.UTF-8
6+
- LANG=en_US.UTF-8
7+
matrix:
8+
- DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="Jetstream" SDK=iphonesimulator9.0
9+
- DESTINATION="OS=8.2,name=iPhone 5" SCHEME="Jetstream" SDK=iphonesimulator9.0
10+
- DESTINATION="OS=8.3,name=iPhone 5S" SCHEME="Jetstream" SDK=iphonesimulator9.0
11+
- DESTINATION="OS=8.4,name=iPhone 6" SCHEME="Jetstream" SDK=iphonesimulator9.0
12+
- DESTINATION="OS=9.0,name=iPhone 6 Plus" SCHEME="Jetstream" SDK=iphonesimulator9.0
13+
script:
14+
- set -o pipefail
15+
- xcodebuild -version
16+
- xcodebuild -project Jetstream.xcodeproj -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION"
17+
-configuration Debug ONLY_ACTIVE_ARCH=NO test | xcpretty -c
618
notifications:
719
email: false

Jetstream.xcodeproj/project.pbxproj

Lines changed: 62 additions & 121 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
61F6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "499A46737AADA8ADEDD865B9136486BDAC17B88E",
3+
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4+
5+
},
6+
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7+
"B0A9AE164019F593FB4F8C022EFEE89AEB1CB357" : 0,
8+
"499A46737AADA8ADEDD865B9136486BDAC17B88E" : 0,
9+
"C86D95FCAEB1FEA0694B5D4AC7241D7E5F42F31D" : 0
10+
},
11+
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "2D7C7C02-3538-4805-885F-10F89FAD08C6",
12+
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
13+
"B0A9AE164019F593FB4F8C022EFEE89AEB1CB357" : "jetstream-iosJetstream\/Signals",
14+
"499A46737AADA8ADEDD865B9136486BDAC17B88E" : "jetstream-ios",
15+
"C86D95FCAEB1FEA0694B5D4AC7241D7E5F42F31D" : "jetstream-iosJetstream\/Starscream"
16+
},
17+
"DVTSourceControlWorkspaceBlueprintNameKey" : "Jetstream",
18+
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
19+
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Jetstream.xcodeproj",
20+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
21+
{
22+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:uber\/jetstream-ios.git",
23+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
24+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "499A46737AADA8ADEDD865B9136486BDAC17B88E"
25+
},
26+
{
27+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/artman\/Signals.git",
28+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
29+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "B0A9AE164019F593FB4F8C022EFEE89AEB1CB357"
30+
},
31+
{
32+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/daltoniam\/Starscream.git",
33+
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
34+
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C86D95FCAEB1FEA0694B5D4AC7241D7E5F42F31D"
35+
}
36+
]
37+
}

Jetstream.xcodeproj/xcshareddata/xcschemes/Jetstream.xcscheme

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0610"
3+
LastUpgradeVersion = "0700"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -37,10 +37,10 @@
3737
</BuildActionEntries>
3838
</BuildAction>
3939
<TestAction
40+
buildConfiguration = "Debug"
4041
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4142
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
42-
shouldUseLaunchSchemeArgsEnv = "YES"
43-
buildConfiguration = "Debug">
43+
shouldUseLaunchSchemeArgsEnv = "YES">
4444
<Testables>
4545
<TestableReference
4646
skipped = "NO">
@@ -62,15 +62,18 @@
6262
ReferencedContainer = "container:Jetstream.xcodeproj">
6363
</BuildableReference>
6464
</MacroExpansion>
65+
<AdditionalOptions>
66+
</AdditionalOptions>
6567
</TestAction>
6668
<LaunchAction
69+
buildConfiguration = "Debug"
6770
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
6871
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
6972
launchStyle = "0"
7073
useCustomWorkingDirectory = "NO"
71-
buildConfiguration = "Debug"
7274
ignoresPersistentStateOnLaunch = "NO"
7375
debugDocumentVersioning = "YES"
76+
debugServiceExtension = "internal"
7477
allowLocationSimulation = "YES">
7578
<MacroExpansion>
7679
<BuildableReference
@@ -85,10 +88,10 @@
8588
</AdditionalOptions>
8689
</LaunchAction>
8790
<ProfileAction
91+
buildConfiguration = "Release"
8892
shouldUseLaunchSchemeArgsEnv = "YES"
8993
savedToolIdentifier = ""
9094
useCustomWorkingDirectory = "NO"
91-
buildConfiguration = "Release"
9295
debugDocumentVersioning = "YES">
9396
<MacroExpansion>
9497
<BuildableReference

Jetstream/ChangeSet.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public enum ChangeSetState {
3131
case Reverted
3232
}
3333

34-
@objc public class ChangeSet: Equatable {
34+
public class ChangeSet: Equatable {
3535
/// A signal that fires whenever the state of the change set changes.
3636
public let onStateChange = Signal<ChangeSetState>()
3737
public let onCompletion = Signal<Void>()
@@ -62,7 +62,7 @@ public enum ChangeSetState {
6262

6363
var pendingChangeSets: [ChangeSet] {
6464
if let definiteChangeSetQueue = changeSetQueue {
65-
if let index = find(definiteChangeSetQueue.changeSets, self) {
65+
if let index = definiteChangeSetQueue.changeSets.indexOf(self) {
6666
return [ChangeSet](definiteChangeSetQueue.changeSets[index + 1..<definiteChangeSetQueue.count])
6767
}
6868
}
@@ -71,10 +71,10 @@ public enum ChangeSetState {
7171

7272
/// Constructs the ChangeSet.
7373
///
74-
/// :param: syncFragments An array of sync fragments that make up the ChangeSet.
75-
/// :param: procedure Name of procedure if a ChangeSet is performing one.
76-
/// :param: atomic Whether the ChangeSet should be applied atomically (either all fragments are applied sucessfully or none are applied successfully).
77-
/// :param: scope The scope of the change set.
74+
/// - parameter syncFragments: An array of sync fragments that make up the ChangeSet.
75+
/// - parameter procedure: Name of procedure if a ChangeSet is performing one.
76+
/// - parameter atomic: Whether the ChangeSet should be applied atomically (either all fragments are applied sucessfully or none are applied successfully).
77+
/// - parameter scope: The scope of the change set.
7878
public init(syncFragments: [SyncFragment], procedure: String?, atomic: Bool, scope: Scope) {
7979
self.syncFragments = syncFragments
8080
self.procedure = procedure
@@ -115,8 +115,8 @@ public enum ChangeSetState {
115115
}
116116

117117
for (uuid, syncFragment) in addedObjects {
118-
if find(attachedObjectUUIDs, uuid) == nil {
119-
if let index = find(self.syncFragments, syncFragment) {
118+
if attachedObjectUUIDs.indexOf(uuid) == nil {
119+
if let index = self.syncFragments.indexOf(syncFragment) {
120120
self.syncFragments.removeAtIndex(index)
121121
}
122122
}
@@ -138,10 +138,10 @@ public enum ChangeSetState {
138138
/// Invokes a callback whenever the ChangeSet has completed synchronizing with the Jetstream server. For this to occur, the scope of the ChangeSet
139139
/// needs to have a Client that transmits the ChangeSet to a Jetstream server.
140140
///
141-
/// :param: observer A listener to attach to the event.
142-
/// :param: callback A closure that gets executed whenever any property or collection on the object has changed. The closure will be called
141+
/// - parameter observer: A listener to attach to the event.
142+
/// - parameter callback: A closure that gets executed whenever any property or collection on the object has changed. The closure will be called
143143
/// with an optional error argument, which describes what went wrong applying the ChangeSet on the Jetstream server.
144-
/// :returns: A function that cancels the observation when invoked.
144+
/// - returns: A function that cancels the observation when invoked.
145145
public func observeCompletion(observer: AnyObject, callback: (error: NSError?) -> Void) -> CancelObserver {
146146
// If already completed or failed then fire immediately
147147
if state != .Syncing {
@@ -176,7 +176,7 @@ public enum ChangeSetState {
176176
// MARK: - Internal Interface
177177
func rebaseOnChangeSet(changeSet: ChangeSet) {
178178
for (rebaseModelObject, rebaseProperties) in changeSet.touches {
179-
for (modelObject, properties) in touches {
179+
for (modelObject, _) in touches {
180180
if modelObject.uuid != rebaseModelObject.uuid {
181181
continue
182182
}
@@ -190,11 +190,11 @@ public enum ChangeSetState {
190190

191191
func removeTouchesFromChangeSet(changeSet: ChangeSet) {
192192
for (overrideModelObject, overrideProperties) in changeSet.touches {
193-
for (modelObject, properties) in touches {
193+
for (modelObject, _) in touches {
194194
if modelObject.uuid != overrideModelObject.uuid {
195195
continue
196196
}
197-
for (key, value) in overrideProperties {
197+
for (key, _) in overrideProperties {
198198
touches[modelObject]!.removeValueForKey(key)
199199
}
200200
if touches[modelObject]!.count == 0 {
@@ -224,7 +224,7 @@ public enum ChangeSetState {
224224
let syncFragment = self.syncFragments[index]
225225
if !reply.accepted {
226226
// TODO: Should gather up failed fragments in the errors userInfo
227-
error = errorWithUserInfo(.SyncFragmentApplyError, [NSLocalizedDescriptionKey: "Failed to apply sync fragments"])
227+
error = errorWithUserInfo(.SyncFragmentApplyError, userInfo: [NSLocalizedDescriptionKey: "Failed to apply sync fragments"])
228228

229229
if let modelObject = scope.getObjectById(syncFragment.objectUUID) {
230230
if syncFragment.type != .Change || syncFragment.properties == nil {
@@ -273,7 +273,7 @@ public enum ChangeSetState {
273273

274274
onError.fire(errorWithUserInfo(
275275
.SyncFragmentApplyError,
276-
[NSLocalizedDescriptionKey: "Failed to apply change set"]))
276+
userInfo: [NSLocalizedDescriptionKey: "Failed to apply change set"]))
277277
}
278278

279279
func setProperty(key: String, onModelObject modelObject: ModelObject, toValue value: AnyObject) {

Jetstream/ChangeSetQueue.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class ChangeSetQueue {
4343

4444
// MARK: - Private interface
4545
func addChangeSet(changeSet: ChangeSet) {
46-
assert(find(changeSets, changeSet) == nil, "ChangeSet already in queue")
46+
assert(changeSets.indexOf(changeSet) == nil, "ChangeSet already in queue")
4747

4848
changeSet.changeSetQueue = self
4949
changeSets.append(changeSet)
@@ -55,7 +55,7 @@ public class ChangeSetQueue {
5555
if state == .Completed {
5656
definiteSelf.removeChangeSet(changeSet)
5757
} else if state == .Reverted {
58-
if let index = find(definiteSelf.changeSets, changeSet) {
58+
if let index = definiteSelf.changeSets.indexOf(changeSet) {
5959
if index < definiteSelf.changeSets.count - 1 {
6060
definiteSelf.changeSets[index+1].rebaseOnChangeSet(definiteSelf.changeSets[0])
6161
}
@@ -67,7 +67,7 @@ public class ChangeSetQueue {
6767
}
6868

6969
func removeChangeSet(changeSet: ChangeSet) {
70-
if let index = find(changeSets, changeSet) {
70+
if let index = changeSets.indexOf(changeSet) {
7171
changeSets.removeAtIndex(index)
7272
onChangeSetRemoved.fire(changeSet)
7373
}

Jetstream/Client.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public typealias TransportAdapterFactory = () -> TransportAdapter
8888

8989
/// Constructs a client.
9090
///
91-
/// :param: transportAdapterFactory The factory used to create a transport adapter to connect to a Jetstream server.
92-
/// :param: restartSessionOnFatalError Whether to restart a session on a fatal session or transport error.
91+
/// - parameter transportAdapterFactory: The factory used to create a transport adapter to connect to a Jetstream server.
92+
/// - parameter restartSessionOnFatalError: Whether to restart a session on a fatal session or transport error.
9393
public init(transportAdapterFactory: TransportAdapterFactory, restartSessionOnFatalError: Bool = true) {
9494
self.transportAdapterFactory = transportAdapterFactory
9595
self.transport = Transport(adapter: transportAdapterFactory())
@@ -106,7 +106,7 @@ public typealias TransportAdapterFactory = () -> TransportAdapter
106106

107107
/// Starts connecting the client to the server with params to supply to server when creating a session.
108108
///
109-
/// :param: sessionCreateParams The params that should be sent along with the session create request.
109+
/// - parameter sessionCreateParams: The params that should be sent along with the session create request.
110110
public func connectWithSessionCreateParams(sessionCreateParams: [String: AnyObject]) {
111111
self.sessionCreateParams C7C4 = sessionCreateParams
112112
connect()
@@ -197,7 +197,7 @@ public typealias TransportAdapterFactory = () -> TransportAdapter
197197
func reinitializeTransportAndRestartSession() {
198198
var scopesAndFetchParams = [ScopesWithFetchParams]()
199199
if let scopesByIndex = session?.scopes {
200-
scopesAndFetchParams = scopesByIndex.values.array
200+
scopesAndFetchParams = Array(scopesByIndex.values)
201201
}
202202

203203
session?.close()
@@ -207,7 +207,7 @@ public typealias TransportAdapterFactory = () -> TransportAdapter
207207
if let this = self {
208208
for (scope, params) in scopesAndFetchParams {
209209
session.fetch(scope, params: params) { error in
210-
if let definiteError = error {
210+
if let error = error {
211211
this.logger.error("Received error refetching scope '\(scope.name)': \(error)")
212212
}
213213
}

Jetstream/Constraint.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public class Constraint {
6969

7070
/// Validates that a set of constraints matches a set of SyncFragments.
7171
///
72-
/// :param: constraints The constraints to apply.
73-
/// :param: syncFragments The sync fragments to apply the constraints on.
72+
/// - parameter constraints: The constraints to apply.
73+
/// - parameter syncFragments: The sync fragments to apply the constraints on.
7474
public class func matchesAllConstraints(constraints: [Constraint], syncFragments: [SyncFragment]) -> Bool {
7575
var unmatchedFragments = syncFragments
7676

@@ -84,10 +84,10 @@ public class Constraint {
8484

8585
/// Constructs the Constraint.
8686
///
87-
/// :param: type The type of SyncFragment to target for constraint.
88-
/// :param: clsName The model class name to target for constraint.
89-
/// :param: properties The property values that must match for this constraint to pass.
90-
/// :param: allowAdditionalProperties Whether to allow additional properties than specified to pass the constraint.
87+
/// - parameter type: The type of SyncFragment to target for constraint.
88+
/// - parameter clsName: The model class name to target for constraint.
89+
/// - parameter properties: The property values that must match for this constraint to pass.
90+
/// - parameter allowAdditionalProperties: Whether to allow additional properties than specified to pass the constraint.
9191
public init(type: SyncFragmentType, clsName: String, properties: [String: AnyObject] = [String: AnyObject](), allowAdditionalProperties: Bool = true) {
9292
self.type = type
9393
self.clsName = clsName
@@ -97,7 +97,7 @@ public class Constraint {
9797

9898
/// Validates that the constraint matches a SyncFragment.
9999
///
100-
/// :param: syncFragment The sync fragment to validate the constraint matches.
100+
/// - parameter syncFragment: The sync fragment to validate the constraint matches.
101101
public func matches(syncFragment: SyncFragment) -> Bool {
102102
if type != syncFragment.type || syncFragment.clsName == nil || clsName != syncFragment.clsName! {
103103
// Does not match constraint type and class
@@ -132,7 +132,7 @@ public class Constraint {
132132
if let value: AnyObject = fragmentProperties[constraintKey] {
133133
if let propertyInfo = propertyInfos[constraintKey] {
134134
// Check value matches constraint
135-
if let hasNewValueConstraintValue = constraintValue as? HasNewValuePropertyConstraint {
135+
if let _ = constraintValue as? HasNewValuePropertyConstraint {
136136
// Allow all cases where constraintValue is HasNewValuePropertyConstraint
137137
} else if let arrayConstraintValue = constraintValue as? ArrayPropertyConstraint {
138138
// Apply an array constraint value
@@ -163,8 +163,8 @@ public class Constraint {
163163
if constraintValue === NSNull() && value === NSNull() {
164164
// Allow case where constraint is nil and explicit nil matches
165165
} else {
166-
let constraintModelValue = convertAnyObjectToModelValue(constraintValue, propertyInfo.valueType)
167-
let fragmentModelValue = convertAnyObjectToModelValue(value, propertyInfo.valueType)
166+
let constraintModelValue = convertAnyObjectToModelValue(constraintValue, type: propertyInfo.valueType)
167+
let fragmentModelValue = convertAnyObjectToModelValue(value, type: propertyInfo.valueType)
168168
if constraintModelValue == nil || fragmentModelValue == nil {
169169
return false
170170
} else if !constraintModelValue!.equalTo(fragmentModelValue!) {

Jetstream/Functions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ func errorFromDictionary(code: ErrorCode, error: [NSString: AnyObject]) -> NSErr
6161
if let errorType = error["type"] as? String {
6262
userInfo[NSLocalizedFailureReasonErrorKey] = errorType
6363
}
64-
return errorWithUserInfo(code, userInfo)
64+
return errorWithUserInfo(code, userInfo: userInfo)
6565
}

Jetstream/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>com.ubercab.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

0 commit comments

Comments
 (0)
0