-
Notifications
You must be signed in to change notification settings - Fork 92
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
Add support for Swift Package Manager #362
Changes from 16 commits
fd2cb9d
e4cd60d
ca4b503
4881291
3c3b737
22ff645
b37b980
d024af6
8b2e39f
5cf1eb7
0b38696
c3e9baa
e8269bb
f571388
07c7b02
2cdb3c7
e37246c
24291c2
ea8bae4
06065a7
f780f54
a6e22e7
90b2b4d
cecfebd
d099233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ Carthage/Build | |
Carthage/Checkouts | ||
/build | ||
/documentation | ||
.build |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "Polyline", | ||
"repositoryURL": "https://github.com/raphaelmor/Polyline.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "011fbc1b0f27a3398bd0fb7c5e2cf5c62ae82717", | ||
"version": "4.2.1" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version:4.2 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "MapboxDirections", | ||
products: [ | ||
// Products define the executables and libraries produced by a package, and make them visible to other packages. | ||
.library( | ||
name: "MapboxDirections", | ||
targets: ["MapboxDirections"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
.package(url: "https://github.com/raphaelmor/Polyline.git", from: "4.2.1") | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages which this package depends on. | ||
.target( | ||
name: "MapboxDirections", | ||
dependencies: ["Polyline"]), | ||
.testTarget( | ||
name: "MapboxDirectionsTests", | ||
dependencies: ["MapboxDirections"]), | ||
] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import Foundation | ||
import CoreLocation | ||
|
||
|
||
/** | ||
A single cross street along a step. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,30 @@ import Foundation | |
/** | ||
A lane on the road approaching an intersection. | ||
*/ | ||
@objcMembers | ||
@objc(MBLane) | ||
public class Lane: NSObject, NSSecureCoding { | ||
/** | ||
The lane indications specifying the maneuvers that may be executed from the lane. | ||
*/ | ||
@objc public let indications: LaneIndication | ||
#if SWIFT_PACKAGE | ||
public let indications: LaneIndication | ||
#else | ||
@objc public let indications: MBLaneIndication | ||
#endif | ||
|
||
/** | ||
Initializes a new `Lane` using the given lane indications. | ||
*/ | ||
#if SWIFT_PACKAGE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely satisfied with this workaround, having to provide duplicated initializers.
but an Obj-C macro would not work with SPM and SPM doesn't support these macros.
|
||
public init(indications: LaneIndication) { | ||
self.indications = indications | ||
} | ||
#else | ||
@objc public init(indications: LaneIndication) { | ||
self.indications = indications | ||
} | ||
#endif | ||
|
||
internal convenience init(json: JSONDictionary) { | ||
let indications = LaneIndication(descriptions: json["indications"] as! [String]) | ||
|
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.
Huh, didn’t know about this annotation. Good find. There are still some bare
@objc
keywords in the class; are they redundant now?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.
@objc
is still needed for refinements. It's also useful for compile-time errors of unbridgeable types.Only using
@objcMembers
would fail silently if a type all of a sudden doesn't bridge to Objective-C. Haven't figured out a best practice yet, but as long as we have Obj-C bridging tests, a missing@objc
annotation is fine since it would get caught by the test at compile-time.