Skip to content

Commit e82d1a5

Browse files
committed
Update to CascableCore 16.0
1 parent 9ae6984 commit e82d1a5

File tree

7 files changed

+114
-9
lines changed

7 files changed

+114
-9
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import PackageDescription
33

44
let package = Package(
55
name: "CascableCoreSwift",
6-
platforms: [.macOS(.v10_15), .iOS(.v13), .macCatalyst(.v15), .visionOS("1.1")],
6+
platforms: [.macOS(.v11), .iOS(.v14), .macCatalyst(.v15), .visionOS("1.1")],
77
products: [.library(name: "CascableCoreSwift", targets: ["CascableCoreSwift"])],
88
dependencies: [
9-
.package(name: "CascableCore", url: "https://github.com/Cascable/cascablecore-distribution", .exact("15.0.2"))
9+
.package(url: "https://github.com/Cascable/cascablecore-distribution", from: "16.0.0")
1010
],
1111
targets: [
12-
.target(name: "CascableCoreSwift", dependencies: ["CascableCore"]),
12+
.target(name: "CascableCoreSwift", dependencies: [.product(name: "CascableCore", package: "cascablecore-distribution")]),
1313
.testTarget(name: "CascableCoreSwiftTests", dependencies: ["CascableCoreSwift"])
1414
]
1515
)

[email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import PackageDescription
33

44
let package = Package(
55
name: "CascableCoreSwift",
6-
platforms: [.macOS(.v10_15), .iOS(.v13), .macCatalyst(.v15)],
6+
platforms: [.macOS(.v11), .iOS(.v14), .macCatalyst(.v15)],
77
products: [.library(name: "CascableCoreSwift", targets: ["CascableCoreSwift"])],
88
dependencies: [
9-
.package(name: "CascableCore", url: "https://github.com/Cascable/cascablecore-distribution", .exact("15.0.2"))
9+
.package(name: "CascableCore", url: "https://github.com/Cascable/cascablecore-distribution", .upToNextMajor(from: "16.0.0"))
1010
],
1111
targets: [
1212
.target(name: "CascableCoreSwift", dependencies: ["CascableCore"]),

Sources/CascableCoreSwift/SDK Extensions/CascableCore+Errors.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public extension Error {
3939
case .objectTooLarge: return .objectTooLarge
4040
case .encryptedConnectionsNotSupported: return .encryptedConnectionsNotSupported
4141
case .connectionAuthenticationFailed: return .connectionAuthenticationFailed
42+
case .networkChangeFailed: return .networkChangeFailed
43+
case .requiresLocationAuthorization: return .requiresLocationAuthorization
4244
@unknown default: return .generic
4345
}
4446
}

Sources/CascableCoreSwift/SDK Extensions/CascableCore+LiveView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import CascableCore
33
import Combine
44
import ObjectiveC
55

6-
extension LiveViewTerminationReason: Error {}
6+
extension LiveViewTerminationReason: @retroactive _BridgedNSError {}
7+
extension LiveViewTerminationReason: @retroactive _ObjectiveCBridgeableError {}
8+
extension LiveViewTerminationReason: @retroactive Error {}
79

810
// MARK: - Public API
911

Sources/CascableCoreSwift/SDK Extensions/CascableCore+SwiftAPITypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public extension TypedIdentifier where CommonValueType == NoCommonValues {
131131

132132
// MARK: - Extensions to CascableCore Identifiers
133133

134-
extension PropertyIdentifier: CaseIterable {
134+
extension PropertyIdentifier: @retroactive CaseIterable {
135135
static public var allCases: [PropertyIdentifier] = {
136136
return (0..<PropertyIdentifier.max.rawValue).compactMap { PropertyIdentifier(rawValue: $0) }
137137
}()
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import Foundation
2+
import CascableCore
3+
4+
public extension HotspotHelpers {
5+
6+
/// Attempt to join the given WiFi network.
7+
///
8+
/// - Note: Joining a WiFi network can take upwards of 20-30 seconds.
9+
///
10+
/// - Parameters:
11+
/// - ssid: The SSID of the network to join.
12+
/// - password: The password of the network to join.
13+
/// - promptForLocation: If the current platform requires location permission to connect to a network, pass `true`
14+
/// to automatically prompt for that permission if needed.
15+
/// - completionHandler: The completion handler to be called with the result of the operation.
16+
/// - completionQueue: The queue on which to call the completion handler.
17+
func attemptToJoinWiFiNetwork(_ ssid: String, password: String,
18+
promptingForLocationIfNeeded promptForLocation: Bool = true,
19+
completionHandler: @escaping (Result<HotspotConfiguration, Error>) -> Void,
20+
completionQueue: DispatchQueue) {
21+
22+
attemptToJoinWiFiNetwork(ssid, password: password, promptingForLocationIfNeeded: promptForLocation,
23+
completionHandler: { config, error in
24+
if let config {
25+
completionHandler(.success(config))
26+
} else if let error {
27+
completionHandler(.failure(error))
28+
} else {
29+
completionHandler(.failure(NSError(cblErrorCode: .networkChangeFailed)))
30+
}
31+
}, completionQueue: completionQueue)
32+
}
33+
34+
/// Attempt to join the given WiFi network.
35+
///
36+
/// - Note: Joining a WiFi network can take upwards of 20-30 seconds.
37+
///
38+
/// - Parameters:
39+
/// - ssid: The SSID of the network to join.
40+
/// - password: The password of the network to join.
41+
/// - promptForLocation: If the current platform requires location permission to connect to a network, pass `true`
42+
/// to automatically prompt for that permission if needed.
43+
/// - Returns: Upon successful connection, returns a `HotspotConfiguration` object describing the network.
44+
func attemptToJoinWiFiNetwork(_ ssid: String, password: String,
45+
promptingForLocationIfNeeded promptForLocation: Bool = true) async throws -> HotspotConfiguration {
46+
47+
return try await withCheckedThrowingContinuation({ continuation in
48+
attemptToJoinWiFiNetwork(ssid, password: password, promptingForLocationIfNeeded: promptForLocation,
49+
completionHandler: { result in
50+
continuation.resume(with: result)
51+
}, completionQueue: .main)
52+
})
53+
}
54+
55+
/// Attempt to join the WiFi network described by the given QR code scanning result. See `CameraQRDecoding` for details.
56+
///
57+
/// - Note: Joining a WiFi network can take upwards of 20-30 seconds.
58+
///
59+
/// - Parameters:
60+
/// - networkDetails The details of the network to join.
61+
/// - promptForLocation: If the current platform requires location permission to connect to a network, pass `true`
62+
/// to automatically prompt for that permission if needed.
63+
/// - completionHandler: The completion handler to be called with the result of the operation.
64+
/// - completionQueue: The queue on which to call the completion handler.
65+
func attemptToJoinQRCodeNetwork(_ networkDetails: CameraWiFiDetails,
66+
promptingForLocationIfNeeded promptForLocation: Bool = true,
67+
completionHandler: @escaping (Result<HotspotConfiguration, Error>) -> Void,
68+
completionQueue: DispatchQueue) {
69+
70+
attemptToJoinQRCodeNetwork(networkDetails, promptingForLocationIfNeeded: promptForLocation,
71+
completionHandler: { config, error in
72+
if let config {
73+
completionHandler(.success(config))
74+
} else if let error {
75+
completionHandler(.failure(error))
76+
} else {
77+
completionHandler(.failure(NSError(cblErrorCode: .networkChangeFailed)))
78+
}
79+
}, completionQueue: completionQueue)
80+
}
81+
82+
/// Attempt to join the WiFi network described by the given QR code scanning result. See `CameraQRDecoding` for details.
83+
///
84+
/// - Note: Joining a WiFi network can take upwards of 20-30 seconds.
85+
///
86+
/// - Parameters:
87+
/// - networkDetails The details of the network to join.
88+
/// - promptForLocation: If the current platform requires location permission to connect to a network, pass `true`
89+
/// to automatically prompt for that permission if needed.
90+
/// - Returns: Upon successful connection, returns a `HotspotConfiguration` object describing the network.
91+
func attemptToJoinQRCodeNetwork(_ networkDetails: CameraWiFiDetails,
92+
promptingForLocationIfNeeded promptForLocation: Bool = true) async throws -> HotspotConfiguration {
93+
94+
return try await withCheckedThrowingContinuation({ continuation in
95+
attemptToJoinQRCodeNetwork(networkDetails, promptingForLocationIfNeeded: promptForLocation,
96+
completionHandler: { result in
97+
continuation.resume(with: result)
98+
}, completionQueue: .main)
99+
})
100+
}
101+
}

0 commit comments

Comments
 (0)