Skip to content

Commit

Permalink
Make the project compile with Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed Mar 3, 2019
1 parent e5d49a1 commit 1a8772d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Bond.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Bond"
s.version = "7.2.0"
s.version = "7.2.1"
s.summary = "A Swift binding framework"

s.description = <<-DESC
Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.11"
s.tvos.deployment_target = "9.0"
s.source = { :git => "https://github.com/SwiftBond/Bond.git", :tag => "7.2.0" }
s.source = { :git => "https://github.com/SwiftBond/Bond.git", :tag => "7.2.1" }
s.source_files = "Sources/**/*.{h,m,swift}", "Supporting Files/Bond.h"
s.ios.exclude_files = "Sources/Bond/AppKit"
s.tvos.exclude_files = "Sources/Bond/AppKit"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Bond/Data Structures/TreeArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Foundation
public protocol TreeArrayProtocol: ArrayBasedTreeNode {
associatedtype ChildValue
init()
subscript(indexPath: IndexPath) -> ChildNode { get set }
subscript(indexPath: Index) -> ChildNode { get set }

This comment has been minimized.

Copy link
@srdanrasic

srdanrasic Mar 3, 2019

Author Contributor

Covariance issue. subscript(indexPath: Index) is also defined in one of the ancestry protocols.

}

/// A tree array represents a valueless root node of a tree structure where children are of TreeNode<ChileValue> type.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Bond/Observable Collections/ChangesetContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extension MutableChangesetContainerProtocol {
}
}

extension ChangesetContainerProtocol where Changeset.Collection: Collection {

This comment has been minimized.

Copy link
@srdanrasic

srdanrasic Mar 3, 2019

Author Contributor

In Swift 4.2 Collection is resolved as Swift.Collection, but Swift 5 resolves it as Collection that is a typealias to Changeset.Collection defined in ChangesetContainerProtocol.

extension ChangesetContainerProtocol where Changeset.Collection: Swift.Collection {

/// Returns `true` if underlying collection is empty, `false` otherwise.
public var isEmpty: Bool {
Expand All @@ -118,7 +118,7 @@ extension ChangesetContainerProtocol where Changeset.Collection: Collection {
}
}

extension ChangesetContainerProtocol where Changeset.Collection: Collection, Changeset.Collection.Index == Int {
extension ChangesetContainerProtocol where Changeset.Collection: Swift.Collection, Changeset.Collection.Index == Int {

/// Underlying array.
public var array: Collection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ extension OrderedCollectionDiff where Index == IndexPath {
return AnyOrderedCollectionOperation.simulate(patch: patch.map { $0.asAnyOrderedCollectionOperation }, on: $0)
}

let updates = zip(self.updates, updatesInFinalCollection).map { (pair) -> OrderedCollectionOperation<C.ChildNode, C.Index> in
return .update(at: pair.0, newElement: collection[pair.1!])

This comment has been minimized.

Copy link
@srdanrasic

srdanrasic Mar 3, 2019

Author Contributor

For some reason Swift 4.2 makes the second type in the tuple optional, but only if we don't pull the zipped collection into a variable.

let zipped = zip(self.updates, updatesInFinalCollection)
let updates = zipped.map { (pair) -> OrderedCollectionOperation<C.ChildNode, C.Index> in
return .update(at: pair.0, newElement: collection[pair.1])
}

return updates + patch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ extension OrderedCollectionDiff where Index: Strideable {
return AnyOrderedCollectionOperation.simulate(patch: patch.map { $0.asAnyOrderedCollectionOperation }, on: $0)
}

let updates = zip(self.updates, updatesInFinalCollection).map { (pair) -> OrderedCollectionOperation<C.Element, C.Index> in
return .update(at: pair.0, newElement: collection[pair.1!])
let zipped = zip(self.updates, updatesInFinalCollection)
let updates = zipped.map { (pair) -> OrderedCollectionOperation<C.Element, C.Index> in
return .update(at: pair.0, newElement: collection[pair.1])
}

return updates + patch
Expand Down
2 changes: 1 addition & 1 deletion Supporting Files/Bond-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>7.2.0</string>
<string>7.2.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 1a8772d

Please sign in to comment.