Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
Add support for iOS 11 (#4)
Browse files Browse the repository at this point in the history
* Add iOS 11 support

* Set Operator Deployment Target to iOS 11.0

* Update log labels and format
  • Loading branch information
frankus authored Sep 1, 2021
1 parent c525676 commit ab6ce82
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ApptentiveKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Pod::Spec.new do |spec|
spec.license = "BSD"
spec.swift_version = "5.3"
spec.author = { 'Apptentive SDK Team' => 'https://learn.apptentive.com/article-categories/ios-native/' }
spec.platform = :ios, "12.0"
spec.platform = :ios, "11.0"
spec.source = { :git => "https://github.com/apptentive/apptentive-ios-sdk.git", :tag => spec.version }
spec.source_files = "Sources/ApptentiveKit/**/*.{h,swift}"
spec.resource_bundles = { "ApptentiveKit" => [ "Sources/ApptentiveKit/localization/*.lproj", "Sources/ApptentiveKit/Resources/Media.xcassets" ] }
Expand Down
4 changes: 2 additions & 2 deletions ApptentiveKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1366,7 +1366,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
4 changes: 2 additions & 2 deletions Operator/Operator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -585,7 +585,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down
44 changes: 41 additions & 3 deletions Sources/ApptentiveKit/ApptentiveLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,29 @@ import OSLog

/// Intended to be not exactly a drop-in replacement, but pretty close to the iOS 14 `Logger` class.
public struct ApptentiveLogger {
private let log: OSLog
private let log: OSLog?

/// Creates a logger with the specified subsystem.
init(subsystem: String) {
self.log = OSLog(subsystem: subsystem, category: .pointsOfInterest)
if #available(iOS 12.0, *) {
self.log = OSLog(subsystem: subsystem, category: .pointsOfInterest)
} else {
self.log = nil
}
}

private func log(_ message: ApptentiveLogMessage, level: LogLevel) {
if level >= self.logLevel {
os_log(level.logType, log: self.log, "%@", message.description)
if #available(iOS 12.0, *) {
guard let log = self.log else {
assertionFailure("Expected log to be available in iOS 12+")
return
}

os_log(level.logType, log: log, "%@", message.description)
} else {
print("\(level.label)/Apptentive: \(message.description)")
}
}
}

Expand Down Expand Up @@ -257,4 +270,29 @@ public enum LogLevel: Int, Comparable {
public static func < (lhs: LogLevel, rhs: LogLevel) -> Bool {
return lhs.rawValue < rhs.rawValue
}

var label: String {
switch self {
case .debug:
return "D"

case .info:
return "I"

case .notice:
return "N"

case .warning:
return "W"

case .error:
return "E"

case .critical:
return "C"

case .fault:
return "F"
}
}
}

0 comments on commit ab6ce82

Please sign in to comment.