Skip to content

Commit 403a02b

Browse files
jt9897253cbaker6
andauthored
Add compile time checks to detect Android (#90)
Co-authored-by: jt9897253 <> Co-authored-by: Corey <[email protected]>
1 parent e1137fc commit 403a02b

Some content is hidden

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

52 files changed

+131
-130
lines changed

Sources/ParseSwift/Coding/AnyEncodable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extension _AnyEncodable {
9898
}
9999
}
100100

101-
#if !os(Linux)
101+
#if !os(Linux) && !os(Android)
102102
private func encode(nsnumber: NSNumber, into container: inout SingleValueEncodingContainer) throws { // swiftlint:disable:this cyclomatic_complexity line_length
103103
switch CFNumberGetType(nsnumber) {
104104
case .charType:

Sources/ParseSwift/Internal/ParseHash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Corey Baker on 12/22/20.
66
// Copyright © 2020 Parse Community. All rights reserved.
77
//
8-
#if !os(Linux)
8+
#if !os(Linux) && !os(Android)
99
import Foundation
1010
import CommonCrypto
1111

Sources/ParseSwift/LiveQuery/LiveQuerySocket.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Corey Baker on 12/31/20.
66
// Copyright © 2020 Parse Community. All rights reserved.
77
//
8-
#if !os(Linux)
8+
#if !os(Linux) && !os(Android)
99
import Foundation
1010
#if canImport(FoundationNetworking)
1111
import FoundationNetworking

Sources/ParseSwift/LiveQuery/ParseLiveQuery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Corey Baker on 1/2/21.
66
// Copyright © 2021 Parse Community. All rights reserved.
77
//
8-
#if !os(Linux)
8+
#if !os(Linux) && !os(Android)
99
import Foundation
1010
#if canImport(FoundationNetworking)
1111
import FoundationNetworking

Sources/ParseSwift/LiveQuery/Protocols/LiveQuerySocketDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Corey Baker on 1/4/21.
66
// Copyright © 2021 Parse Community. All rights reserved.
77
//
8-
#if !os(Linux)
8+
#if !os(Linux) && !os(Android)
99
import Foundation
1010
#if canImport(FoundationNetworking)
1111
import FoundationNetworking

Sources/ParseSwift/LiveQuery/Protocols/ParseLiveQueryDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Corey Baker on 1/4/21.
66
// Copyright © 2021 Parse Community. All rights reserved.
77
//
8-
#if !os(Linux)
8+
#if !os(Linux) && !os(Android)
99
import Foundation
1010
#if canImport(FoundationNetworking)
1111
import FoundationNetworking

Sources/ParseSwift/Objects/ParseInstallation.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ extension ParseInstallation {
121121
get {
122122
guard let installationInMemory: CurrentInstallationContainer<Self> =
123123
try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentInstallation) else {
124-
#if !os(Linux)
124+
#if !os(Linux) && !os(Android)
125125
guard let installationFromKeyChain: CurrentInstallationContainer<Self> =
126126
try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentInstallation)
127127
else {
@@ -169,14 +169,14 @@ extension ParseInstallation {
169169
= try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentInstallation) else {
170170
return
171171
}
172-
#if !os(Linux)
172+
#if !os(Linux) && !os(Android)
173173
try? KeychainStore.shared.set(currentInstallationInMemory, for: ParseStorage.Keys.currentInstallation)
174174
#endif
175175
}
176176

177177
internal static func deleteCurrentContainerFromKeychain() {
178178
try? ParseStorage.shared.delete(valueFor: ParseStorage.Keys.currentInstallation)
179-
#if !os(Linux)
179+
#if !os(Linux) && !os(Android)
180180
try? KeychainStore.shared.delete(valueFor: ParseStorage.Keys.currentInstallation)
181181
#endif
182182
}
@@ -215,7 +215,6 @@ extension ParseInstallation {
215215
}
216216

217217
mutating func updateDeviceTypeFromDevice() {
218-
219218
if deviceType != ParseConstants.deviceType {
220219
deviceType = ParseConstants.deviceType
221220
}
@@ -255,7 +254,7 @@ extension ParseInstallation {
255254
guard let appInfo = Bundle.main.infoDictionary else {
256255
return
257256
}
258-
#if !os(Linux)
257+
#if !os(Linux) && !os(Android)
259258
#if TARGET_OS_MACCATALYST
260259
// If using an Xcode new enough to know about Mac Catalyst:
261260
// Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted

Sources/ParseSwift/Objects/ParseUser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extension ParseUser {
8888
get {
8989
guard let currentUserInMemory: CurrentUserContainer<Self>
9090
= try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentUser) else {
91-
#if !os(Linux)
91+
#if !os(Linux) && !os(Android)
9292
return try? KeychainStore.shared.get(valueFor: ParseStorage.Keys.currentUser)
9393
#else
9494
return nil
@@ -105,14 +105,14 @@ extension ParseUser {
105105
= try? ParseStorage.shared.get(valueFor: ParseStorage.Keys.currentUser) else {
106106
return
107107
}
108-
#if !os(Linux)
108+
#if !os(Linux) && !os(Android)
109109
try? KeychainStore.shared.set(currentUserInMemory, for: ParseStorage.Keys.currentUser)
110110
#endif
111111
}
112112

113113
internal static func deleteCurrentContainerFromKeychain() {
114114
try? ParseStorage.shared.delete(valueFor: ParseStorage.Keys.currentUser)
115-
#if !os(Linux)
115+
#if !os(Linux) && !os(Android)
116116
try? KeychainStore.shared.delete(valueFor: ParseStorage.Keys.currentUser)
117117
#endif
118118
BaseParseUser.currentUserContainer = nil

Sources/ParseSwift/ParseConstants.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ enum ParseConstants {
2626
static let deviceType = "applewatch"
2727
#elseif os(Linux)
2828
static let deviceType = "linux"
29+
#elseif os(Android)
30+
static let deviceType = "android"
2931
#endif
3032
}

Sources/ParseSwift/Protocols/Objectable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension Objectable {
5353

5454
static func createHash(_ object: Encodable) throws -> String {
5555
let encoded = try ParseCoding.parseEncoder().encode(object)
56-
#if !os(Linux)
56+
#if !os(Linux) && !os(Android)
5757
return ParseHash.md5HashFromData(encoded)
5858
#else
5959
guard let hashString = String(data: encoded, encoding: .utf8) else {

0 commit comments

Comments
 (0)