Skip to content

Commit

Permalink
Separate SPM and ObjC prerequisites
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Apr 9, 2019
1 parent f2515a3 commit 8889ca5
Show file tree
Hide file tree
Showing 17 changed files with 292 additions and 27 deletions.
22 changes: 16 additions & 6 deletions MapboxDirections.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,13 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
352FFA1122565F25007E7C40 /* LaneIndication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaneIndication.swift; sourceTree = "<group>"; };
35828C9D217A003F00ED546E /* OfflineDirections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OfflineDirections.swift; sourceTree = "<group>"; };
35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRoadClasses.h; path = Sources/MapboxDirections/objc/MBRoadClasses.h; sourceTree = SOURCE_ROOT; };
35C0D78B22563B2A005E05A5 /* MBRouteOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRouteOptions.h; path = Sources/MapboxDirections/objc/MBRouteOptions.h; sourceTree = SOURCE_ROOT; };
35C0D78C22563B2B005E05A5 /* MBLaneIndication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBLaneIndication.h; path = Sources/MapboxDirections/objc/MBLaneIndication.h; sourceTree = SOURCE_ROOT; };
35C0D78D22563B2B005E05A5 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBRouteOptions.m; path = Sources/MapboxDirections/objc/MBRouteOptions.m; sourceTree = SOURCE_ROOT; };
35C0D78E22563B2B005E05A5 /* MBAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBAttribute.h; path = Sources/MapboxDirections/objc/MBAttribute.h; sourceTree = SOURCE_ROOT; };
35C0D78A22563B2A005E05A5 /* MBRoadClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRoadClasses.h; path = Sources/objc/MBRoadClasses.h; sourceTree = SOURCE_ROOT; };
35C0D78B22563B2A005E05A5 /* MBRouteOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBRouteOptions.h; path = Sources/objc/MBRouteOptions.h; sourceTree = SOURCE_ROOT; };
35C0D78C22563B2B005E05A5 /* MBLaneIndication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBLaneIndication.h; path = Sources/objc/MBLaneIndication.h; sourceTree = SOURCE_ROOT; };
35C0D78D22563B2B005E05A5 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MBRouteOptions.m; path = Sources/objc/MBRouteOptions.m; sourceTree = SOURCE_ROOT; };
35C0D78E22563B2B005E05A5 /* MBAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MBAttribute.h; path = Sources/objc/MBAttribute.h; sourceTree = SOURCE_ROOT; };
35D92FEF218203AA000C78CB /* 2018-10-16-Liechtenstein.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = "2018-10-16-Liechtenstein.tar"; sourceTree = "<group>"; };
35DBF004217DF0D90009D2AE /* MBCoordinateBounds.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MBCoordinateBounds.swift; sourceTree = "<group>"; };
35DBF009217E172C0009D2AE /* CLLocationCoordinate2D.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLLocationCoordinate2D.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -496,6 +497,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
352FFA1022565F17007E7C40 /* SPM */ = {
isa = PBXGroup;
children = (
352FFA1122565F25007E7C40 /* LaneIndication.swift */,
);
path = SPM;
sourceTree = "<group>";
};
35C0D78922563B1C005E05A5 /* Objective-C */ = {
isa = PBXGroup;
children = (
Expand All @@ -506,7 +515,7 @@
35C0D78D22563B2B005E05A5 /* MBRouteOptions.m */,
);
name = "Objective-C";
path = "objc-test";
path = ../objc;
sourceTree = "<group>";
};
35DBF017217F387F0009D2AE /* Offline */ = {
Expand Down Expand Up @@ -604,6 +613,7 @@
DA6C9D891CAE442B00094FBC /* MapboxDirections */ = {
isa = PBXGroup;
children = (
352FFA1022565F17007E7C40 /* SPM */,
35C0D78922563B1C005E05A5 /* Objective-C */,
8D381B681FDB1009008D5A58 /* Extensions */,
C5DAAC9E20191683001F9261 /* Match */,
Expand Down
17 changes: 16 additions & 1 deletion Sources/MapboxDirections/MBDirectionsOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public enum InstructionFormat: UInt, CustomStringConvertible {

You do not create instances of this class directly. Instead, create instances of `MatchOptions` or `RouteOptions`.
*/
@objcMembers
@objc(MBDirectionsOptions)
open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {

Expand All @@ -232,7 +233,7 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {
- parameter waypoints: An array of `Waypoint` objects representing locations that the route should visit in chronological order. The array should contain at least two waypoints (the source and destination) and at most 25 waypoints. (Some profiles, such as `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, [may have lower limits](https://docs.mapbox.com/api/navigation/#directions).)
- parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. This parameter, if set, should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. `MBDirectionsProfileIdentifierAutomobile` is used by default.
*/
@objc required public init(waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier? = nil) {
required public init(waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier? = nil) {
self.waypoints = waypoints
self.profileIdentifier = profileIdentifier ?? .automobile
}
Expand Down Expand Up @@ -300,7 +301,12 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {
guard let profileIdentifier = decoder.decodeObject(of: NSString.self, forKey: "profileIdentifier") as String? else {
return nil
}

#if SWIFT_PACKAGE
self.profileIdentifier = MBDirectionsProfileIdentifier(rawValue: profileIdentifier) ?? MBDirectionsProfileIdentifier.automobileAvoidingTraffic
#else
self.profileIdentifier = MBDirectionsProfileIdentifier(rawValue: profileIdentifier)
#endif

includesSteps = decoder.decodeBool(forKey: "includesSteps")

Expand Down Expand Up @@ -384,7 +390,12 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {

This property should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. The default value of this property is `MBDirectionsProfileIdentifierAutomobile`, which specifies driving directions.
*/
#if SWIFT_PACKAGE
open var profileIdentifier: MBDirectionsProfileIdentifier
#else
@objc open var profileIdentifier: MBDirectionsProfileIdentifier
#endif


/**
A Boolean value indicating whether `MBRouteStep` objects should be included in the response.
Expand Down Expand Up @@ -420,7 +431,11 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {

By default, no attribute options are specified. It is recommended that `routeShapeResolution` be set to `.full`.
*/
#if SWIFT_PACKAGE
open var attributeOptions: AttributeOptions = []
#else
@objc open var attributeOptions: AttributeOptions = []
#endif

/**
The locale in which the route’s instructions are written.
Expand Down
11 changes: 11 additions & 0 deletions Sources/MapboxDirections/MBLane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
#if SWIFT_PACKAGE
public let indications: LaneIndication
#else
@objc public let indications: LaneIndication
#endif

/**
Initializes a new `Lane` using the given lane indications.
*/
#if SWIFT_PACKAGE
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])
Expand Down
1 change: 1 addition & 0 deletions Sources/MapboxDirections/MBLaneIndication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Foundation

public typealias LaneIndication = MBLaneIndication


extension LaneIndication: CustomStringConvertible {
/**
Creates a lane indication from the given description strings.
Expand Down
11 changes: 5 additions & 6 deletions Sources/MapboxDirections/MBLaneIndicationComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ import Foundation
/**
A component that represents a lane representation of an instruction.
*/
@objc(MBLaneIndicationComponent)
open class LaneIndicationComponent: NSObject, ComponentRepresentable {
@objcMembers open class LaneIndicationComponent: NSObject, ComponentRepresentable {

/**
An array indicating which directions you can go from a lane (left, right, or straight).

If the value is `[LaneIndication.left", LaneIndication.straightAhead]`, the driver can go left or straight ahead from that lane. This is only set when the `component` is a `lane`.
*/
@objc public var indications: LaneIndication
public var indications: LaneIndication

/**
The boolean that indicates whether the lane can be used to complete the maneuver.

If multiple lanes are active, then they can all be used to complete the upcoming maneuver. This value is set to `false` by default.
*/
@objc public var isUsable: Bool = false
public var isUsable: Bool = false

public static var supportsSecureCoding: Bool = true

Expand All @@ -29,12 +28,12 @@ open class LaneIndicationComponent: NSObject, ComponentRepresentable {
- parameter indications: The directions to go from a lane component.
- parameter isUsable: The flag to indicate that the upcoming maneuver can be completed with a lane component.
*/
@objc public init(indications: LaneIndication, isUsable: Bool) {
public init(indications: LaneIndication, isUsable: Bool) {
self.indications = indications
self.isUsable = isUsable
}

@objc public required init?(coder decoder: NSCoder) {
public required init?(coder decoder: NSCoder) {
guard let directions = decoder.decodeObject(of: [NSArray.self, NSString.self], forKey: "indications") as? [String], let indications = LaneIndication(descriptions: directions) else {
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/MapboxDirections/MBRouteLeg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Polyline

You do not create instances of this class directly. Instead, you receive route leg objects as part of route objects when you request directions using the `Directions.calculate(_:completionHandler:)` method.
*/
@objcMembers
@objc(MBRouteLeg)
open class RouteLeg: NSObject, NSSecureCoding {

Expand Down Expand Up @@ -90,7 +91,11 @@ open class RouteLeg: NSObject, NSSecureCoding {
guard let decodedProfileIdentifier = decoder.decodeObject(of: NSString.self, forKey: "profileIdentifier") as String? else {
return nil
}
#if SWIFT_PACKAGE
profileIdentifier = MBDirectionsProfileIdentifier(rawValue: decodedProfileIdentifier) ?? MBDirectionsProfileIdentifier.automobileAvoidingTraffic
#else
profileIdentifier = MBDirectionsProfileIdentifier(rawValue: decodedProfileIdentifier)
#endif

segmentDistances = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "segmentDistances") as? [CLLocationDistance]
expectedSegmentTravelTimes = decoder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: "expectedSegmentTravelTimes") as? [TimeInterval]
Expand Down Expand Up @@ -212,7 +217,11 @@ open class RouteLeg: NSObject, NSSecureCoding {

The value of this property is `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`, depending on the `profileIdentifier` property of the original `RouteOptions` object. This property reflects the primary mode of transportation used for the route leg. Individual steps along the route leg might use different modes of transportation as necessary.
*/
#if SWIFT_PACKAGE
public let profileIdentifier: MBDirectionsProfileIdentifier
#else
@objc public let profileIdentifier: MBDirectionsProfileIdentifier
#endif

func debugQuickLookObject() -> Any? {
let coordinates = steps.reduce([], { $0 + ($1.coordinates ?? []) })
Expand Down
Loading

0 comments on commit 8889ca5

Please sign in to comment.