Skip to content

Commit 78ffa3f

Browse files
authored
Merge pull request #90 from TiagoBrasN/lower-deployment-target
Lower deployment target
2 parents 581650c + 7f6f14f commit 78ffa3f

15 files changed

Lines changed: 188 additions & 42 deletions

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "nodes-ios/TranslationManager" "3.1.1"
1+
github "nodes-ios/TranslationManager" "3.1.3"

NStackSDK.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'NStackSDK'
11-
s.version = '5.1.4'
11+
s.version = '5.1.5'
1212
s.summary = 'NStackSDK is the companion software development kit to the NStack backend.'
1313

1414
# This description is used to generate tags and improve search results.
@@ -25,11 +25,11 @@ Pod::Spec.new do |s|
2525
s.author = { "Nodes Agency - iOS" => "ios@nodes.dk" }
2626
s.source = { :git => 'https://github.com/nstack-io/nstack-ios-sdk', :tag => s.version.to_s }
2727

28-
s.ios.deployment_target = "11"
28+
s.ios.deployment_target = "9.0"
2929
s.swift_version = '5.2'
3030

3131
s.default_subspecs = "Core"
32-
s.dependency 'NLocalizationManager'
32+
s.dependency 'NLocalizationManager', '~> 3.0'
3333

3434
s.subspec 'Core' do |core|
3535
core.source_files = [ 'NStackSDK/**/*.swift']

NStackSDK.xcodeproj/project.pbxproj

Lines changed: 53 additions & 24 deletions
Large diffs are not rendered by default.

NStackSDK/Classes/NStack Manager/ConnectionManager.swift

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import Foundation
1010
#if os(macOS)
1111
import AppKit
12+
#elseif os(watchOS)
13+
import WatchKit
1214
#else
1315
import UIKit
1416
#endif
@@ -332,10 +334,36 @@ extension ConnectionManager {
332334
// MARK: - FeedbackRepository
333335
extension ConnectionManager {
334336
private func getPlatform() -> String {
337+
#if os(iOS) || os(tvOS)
335338
switch UIDevice.current.systemName.lowercased() {
336339
case "ios": return "ios"
337340
default: return "unknown"
338341
}
342+
#elseif os(macOS)
343+
return ProcessInfo.processInfo.operatingSystemVersionString.lowercased()
344+
#elseif os(watchOS)
345+
return WKInterfaceDevice.current().systemName.lowercased()
346+
#endif
347+
}
348+
349+
private func modelType() -> String {
350+
#if os(iOS) || os(tvOS)
351+
return UIDevice.current.modelType.rawValue
352+
#elseif os(macOS)
353+
return "unknown"
354+
#elseif os(watchOS)
355+
return WKInterfaceDevice.current().model
356+
#endif
357+
}
358+
359+
private func systemVersion() -> String {
360+
#if os(iOS) || os(tvOS)
361+
return UIDevice.current.systemVersion
362+
#elseif os(macOS)
363+
return "unknown"
364+
#elseif os(watchOS)
365+
return WKInterfaceDevice.current().systemVersion
366+
#endif
339367
}
340368

341369
func provideFeedback(_ feedback: Feedback, completion: @escaping Completion<Void>) {
@@ -346,19 +374,21 @@ extension ConnectionManager {
346374
urlRequest.allHTTPHeaderFields = defaultHeaders
347375
urlRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
348376

349-
let data = MultipartBuilder(boundary: boundary)
377+
let builder = MultipartBuilder(boundary: boundary)
350378
.append(name: "type", value: feedback.type.rawValue)
351379
.append(name: "platform", value: getPlatform())
352-
.append(name: "os", value: UIDevice.current.systemVersion)
353-
.append(name: "device", value: UIDevice.current.modelType.rawValue)
380+
.append(name: "os", value: systemVersion())
381+
.append(name: "device", value: modelType())
354382
.append(name: "app_version", value: feedback.appVersion)
355383
.append(name: "name", value: feedback.name)
356384
.append(name: "email", value: feedback.email)
357385
.append(name: "message", value: feedback.message)
358-
.append(name: "image", image: feedback.image, jpegQuality: 0.7)
359-
.build()
386+
387+
#if canImport(UIKit)
388+
builder.append(name: "image", image: feedback.image, jpegQuality: 0.7)
389+
#endif
360390

361-
session.uploadTask(with: urlRequest, from: data, completionHandler: { _, _, error in
391+
session.uploadTask(with: urlRequest, from: builder.build(), completionHandler: { _, _, error in
362392
if let error = error {
363393
completion(.failure(error))
364394
} else {

NStackSDK/Classes/Notify/AlertManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public class AlertManager {
104104
}
105105

106106
public var requestReview: () -> Void = {
107-
if #available(iOSApplicationExtension 10.3, *) {
107+
if #available(iOS 10.3, *) {
108108
#if os(iOS)
109109
SKStoreReviewController.requestReview()
110110
#endif

NStackSDK/Classes/Notify/StoreReviewManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import StoreKit
1111

1212
class StoreReviewManager {
1313
static func requestReview() {
14-
if #available(iOSApplicationExtension 10.3, *) {
14+
if #available(iOS 10.3, *) {
1515
SKStoreReviewController.requestReview()
1616
}
1717
}

NStackSDK/Classes/Other/Extensions.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extension String {
2525
}
2626
}
2727

28+
@available(iOS 10.0, OSX 10.12, *)
2829
extension ISO8601DateFormatter {
2930
convenience init(_ formatOptions: Options, timeZone: TimeZone = TimeZone(secondsFromGMT: 0)!) {
3031
self.init()
@@ -34,11 +35,25 @@ extension ISO8601DateFormatter {
3435
}
3536

3637
extension Formatter {
37-
static let iso8601 = ISO8601DateFormatter([.withInternetDateTime])
38+
@available(iOS 10.0, OSX 10.12, *)
39+
static let iso8601: ISO8601DateFormatter = ISO8601DateFormatter([.withInternetDateTime])
40+
41+
static let iso8601Fallback: DateFormatter = {
42+
let formatter = DateFormatter()
43+
formatter.calendar = Calendar(identifier: .iso8601)
44+
formatter.locale = Locale(identifier: "en_US_POSIX")
45+
formatter.timeZone = TimeZone(secondsFromGMT: 0)
46+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssXXXXX"
47+
return formatter
48+
}()
3849
}
3950

4051
extension Date {
4152
var iso8601: String {
42-
return DateFormatter.iso8601.string(from: self)
53+
if #available(iOS 10.0, OSX 10.12, *) {
54+
return DateFormatter.iso8601.string(from: self)
55+
} else {
56+
return DateFormatter.iso8601Fallback.string(from: self)
57+
}
4358
}
4459
}

NStackSDK/Classes/Other/MultipartBuilder.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright © 2019 Nodes ApS. All rights reserved.
77
//
88

9+
import Foundation
10+
#if canImport(UIKit)
911
import UIKit
12+
#endif
1013

1114
class MultipartBuilder {
1215
struct Part: Hashable {
@@ -23,6 +26,7 @@ class MultipartBuilder {
2326
self.boundary = boundary
2427
}
2528

29+
#if canImport(UIKit)
2630
/// Appends image field if value != nil. If there's already field with the same name,
2731
/// that field will be replaced.
2832
/// - Parameter name: field's name.
@@ -38,6 +42,8 @@ class MultipartBuilder {
3842

3943
return self
4044
}
45+
#endif
46+
4147

4248
/// Appends field if value != nil. If there's already field with the same name,
4349
/// that field will be replaced.

NStackSDK/Classes/Other/N-Meta.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private func userAgentString(environment: String) -> String {
3737
appendString += "\(UIDevice.current.modelName)"
3838
#elseif os(watchOS)
3939
appendString += "\(WKInterfaceDevice.current().systemVersion);"
40-
appendString += "\(WKInterfaceDevice.current().codable)"
40+
appendString += "\(WKInterfaceDevice.current().model)"
4141
#elseif os(macOS)
4242

4343
#endif

NStackSDK/Feedback.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright © 2019 Nodes ApS. All rights reserved.
77
//
88

9+
import Foundation
10+
#if canImport(UIKit)
911
import UIKit
12+
#endif
1013

1114
public enum FeedbackType: String {
1215
case feedback, bug
@@ -23,6 +26,8 @@ struct Feedback {
2326
var name: String?
2427
var email: String?
2528
var message: String?
29+
#if canImport(UIKit)
2630
var image: UIImage?
31+
#endif
2732
var breadcrumbs: Breadcrumbs?
2833
}

0 commit comments

Comments
 (0)