Skip to content

Commit b227969

Browse files
committed
fix deployment target
1 parent 6d82a4c commit b227969

File tree

8 files changed

+80
-58
lines changed

8 files changed

+80
-58
lines changed

.swiftformat

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# file options
2+
3+
--symlinks ignore
4+
--swiftversion 5.1
5+
6+
# rules
7+
--enable isEmpty
8+
--disable andOperator
9+
--disable wrapMultilineStatementBraces
10+
--ifdef no-indent
11+
12+
# format options
13+
14+
--closingparen same-line
15+
--commas inline
16+
--comments indent
17+
--decimalgrouping 3,5
18+
--exponentcase lowercase
19+
--exponentgrouping disabled
20+
--fractiongrouping disabled
21+
--importgrouping testable-top
22+
--operatorfunc no-space
23+
--nospaceoperators ..<, ...
24+
--selfrequired validate
25+
--self insert
26+
--stripunusedargs closure-only
27+
--wraparguments after-first
28+
--wrapcollections after-first
29+
--wrapparameters after-first
30+
--disable redundantReturn
31+
32+
# excludes
33+
34+
--exclude Pods, Package.swift

AppStoreManager.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
1010
spec.source = { :git => "https://github.com/knottx/AppStoreManager.git", :tag => "#{spec.version}" }
1111

1212
spec.swift_version = "5.1"
13-
spec.ios.deployment_target = "10.0"
13+
spec.ios.deployment_target = "11.0"
1414
spec.source_files = "Sources/AppStoreManager/**/*.swift"
1515
spec.requires_arc = true
1616

AppStoreManager.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 50;
6+
objectVersion = 52;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -176,7 +176,7 @@
176176
};
177177
};
178178
buildConfigurationList = 1A38DD8B25A7F907003F396E /* Build configuration list for PBXProject "AppStoreManager" */;
179-
compatibilityVersion = "Xcode 9.3";
179+
compatibilityVersion = "Xcode 11.0";
180180
developmentRegion = en;
181181
hasScannedForEncodings = 0;
182182
knownRegions = (
@@ -293,7 +293,7 @@
293293
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294294
GCC_WARN_UNUSED_FUNCTION = YES;
295295
GCC_WARN_UNUSED_VARIABLE = YES;
296-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
296+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
297297
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
298298
MTL_FAST_MATH = YES;
299299
ONLY_ACTIVE_ARCH = YES;
@@ -351,7 +351,7 @@
351351
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
352352
GCC_WARN_UNUSED_FUNCTION = YES;
353353
GCC_WARN_UNUSED_VARIABLE = YES;
354-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
354+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
355355
MTL_ENABLE_DEBUG_INFO = NO;
356356
MTL_FAST_MATH = YES;
357357
SDKROOT = iphoneos;
@@ -375,7 +375,7 @@
375375
DYLIB_INSTALL_NAME_BASE = "@rpath";
376376
INFOPLIST_FILE = Sources/AppStoreManager/Info.plist;
377377
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
378-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
378+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
379379
LD_RUNPATH_SEARCH_PATHS = (
380380
"$(inherited)",
381381
"@executable_path/Frameworks",
@@ -404,7 +404,7 @@
404404
DYLIB_INSTALL_NAME_BASE = "@rpath";
405405
INFOPLIST_FILE = Sources/AppStoreManager/Info.plist;
406406
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
407-
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
407+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
408408
LD_RUNPATH_SEARCH_PATHS = (
409409
"$(inherited)",
410410
"@executable_path/Frameworks",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ AppStoreManager.shared.configureAlert(updateButtonTitle: <String?>, skipButtonTi
6464

6565
## 📋 Requirements
6666

67-
* iOS 10.0+
67+
* iOS 11.0+
6868
* Xcode 11+
6969
* Swift 5.1+

Sources/AppStoreManager/AppStoreManager.swift

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,46 @@ public enum VersionCheckType: Int {
1515
case weekly = 7
1616
}
1717

18-
struct AppStoreDefaults {
18+
enum AppStoreDefaults {
1919
static let storedVersionCheckDate = "storedVersionCheckDate"
2020
static let storedSkippedVersion = "storedSkippedVersion"
2121
}
2222

2323
public class AppStoreManager {
24-
2524
public static let shared = AppStoreManager()
26-
25+
2726
var title: String = AppStoreManagerConstant.alertTitle
2827
var message: String? = AppStoreManagerConstant.alertMessage
29-
28+
3029
var skipButtonTitle: String = AppStoreManagerConstant.skipButtonTitle
3130
var updateButtonTitle: String = AppStoreManagerConstant.updateButtonTitle
32-
31+
3332
var lastVersionCheckDate: Date? {
34-
didSet{
33+
didSet {
3534
UserDefaults.standard.set(self.lastVersionCheckDate, forKey: AppStoreDefaults.storedVersionCheckDate)
3635
UserDefaults.standard.synchronize()
3736
}
3837
}
39-
38+
4039
let bundleId = Bundle.main.bundleIdentifier ?? ""
41-
40+
4241
var currentInstalledVersion: String? {
4342
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
4443
}
45-
44+
4645
var appStoreResult: AppStoreResult?
47-
46+
4847
init() {
4948
self.lastVersionCheckDate = UserDefaults.standard.object(forKey: AppStoreDefaults.storedVersionCheckDate) as? Date
5049
}
51-
52-
func getStoreVersion(completion: @escaping (AppStoreResult?) -> ()) {
50+
51+
func getStoreVersion(completion: @escaping (AppStoreResult?) -> Void) {
5352
guard let url = URL(string: "https://itunes.apple.com/lookup?bundleId=\(self.bundleId)") else {
5453
completion(nil)
5554
return
5655
}
5756
let session = URLSession(configuration: .default)
58-
let task = session.dataTask(with: url) { [weak self] (data, response, error) in
57+
let task = session.dataTask(with: url) { [weak self] data, _, error in
5958
if let er = error {
6059
self?.log(er.localizedDescription)
6160
completion(nil)
@@ -67,16 +66,16 @@ public class AppStoreManager {
6766
self?.log("AppStore version: \(result.version ?? "")")
6867
self?.appStoreResult = result
6968
completion(result)
70-
}else{
69+
} else {
7170
self?.appStoreResult = nil
7271
completion(nil)
7372
}
7473
}
7574
task.resume()
7675
}
77-
78-
public func checkNewVersion(_ type: VersionCheckType, isAvailable: @escaping (Bool) -> ()) {
79-
self.getStoreVersion { [weak self] (result) in
76+
77+
public func checkNewVersion(_ type: VersionCheckType, isAvailable: @escaping (Bool) -> Void) {
78+
self.getStoreVersion { [weak self] result in
8079
if let currentInstalledVersion = self?.currentInstalledVersion,
8180
let appStoreVersion = result?.version {
8281
switch currentInstalledVersion.compare(appStoreVersion, options: .numeric) {
@@ -94,24 +93,24 @@ public class AppStoreManager {
9493
if Date.days(since: lastVersionCheckDate) >= type.rawValue {
9594
self?.lastVersionCheckDate = Date()
9695
isAvailable(true)
97-
}else{
96+
} else {
9897
isAvailable(false)
9998
}
10099
}
101100
case .orderedDescending, .orderedSame:
102101
isAvailable(false)
103102
}
104-
}else{
103+
} else {
105104
isAvailable(false)
106105
}
107106
}
108107
}
109-
108+
110109
public func checkNewVersionAndShowAlert(_ type: VersionCheckType,
111110
at vc: UIViewController,
112111
canSkip: Bool,
113112
preferredStyle: UIAlertController.Style = .alert) {
114-
self.getStoreVersion { [weak self] (result) in
113+
self.getStoreVersion { [weak self] result in
115114
if let currentInstalledVersion = self?.currentInstalledVersion,
116115
let appStoreVersion = result?.version {
117116
switch currentInstalledVersion.compare(appStoreVersion, options: .numeric) {
@@ -121,31 +120,31 @@ public class AppStoreManager {
121120
case .orderedDescending, .orderedSame:
122121
break
123122
}
124-
}else{
123+
} else {
125124
self?.log("Can't get Version")
126125
}
127126
}
128127
}
129-
130-
//MARK: - Alert
131-
128+
129+
// MARK: - Alert
130+
132131
public func configureAlert(title: String?, message: String?) {
133132
self.title = title ?? AppStoreManagerConstant.alertTitle
134133
self.message = message
135134
}
136-
135+
137136
public func configureAlert(updateButtonTitle: String?, skipButtonTitle: String?) {
138137
self.updateButtonTitle = updateButtonTitle ?? AppStoreManagerConstant.updateButtonTitle
139138
self.skipButtonTitle = skipButtonTitle ?? AppStoreManagerConstant.skipButtonTitle
140139
}
141-
142-
public func showAlertUpdate(at vc:UIViewController, canSkip: Bool, preferredStyle: UIAlertController.Style = .alert) {
140+
141+
public func showAlertUpdate(at vc: UIViewController, canSkip: Bool, preferredStyle: UIAlertController.Style = .alert) {
143142
DispatchQueue.main.async { [weak self] in
144143
let alertVc = UIAlertController(title: self?.title, message: self?.message, preferredStyle: preferredStyle)
145-
let skip = UIAlertAction(title: self?.skipButtonTitle ?? AppStoreManagerConstant.skipButtonTitle, style: .cancel) { (_) in
144+
let skip = UIAlertAction(title: self?.skipButtonTitle ?? AppStoreManagerConstant.skipButtonTitle, style: .cancel) { _ in
146145
//
147146
}
148-
let update = UIAlertAction(title: self?.updateButtonTitle ?? AppStoreManagerConstant.updateButtonTitle, style: .default) { (_) in
147+
let update = UIAlertAction(title: self?.updateButtonTitle ?? AppStoreManagerConstant.updateButtonTitle, style: .default) { _ in
149148
self?.openAppStore()
150149
}
151150
alertVc.addAction(update)
@@ -155,12 +154,12 @@ public class AppStoreManager {
155154
vc.present(alertVc, animated: true, completion: nil)
156155
}
157156
}
158-
157+
159158
public func openAppStore() {
160159
if let appStoreId = self.appStoreResult?.trackId {
161160
self.openAppStore(id: appStoreId)
162-
}else{
163-
self.getStoreVersion { [weak self] (result) in
161+
} else {
162+
self.getStoreVersion { [weak self] result in
164163
guard let appStoreId = result?.trackId else {
165164
self?.log("Can't get an AppId")
166165
return
@@ -169,21 +168,19 @@ public class AppStoreManager {
169168
}
170169
}
171170
}
172-
171+
173172
func openAppStore(id appStoreId: Int) {
174173
if let url = URL(string: "https://itunes.apple.com/app/id\(appStoreId)"),
175174
UIApplication.shared.canOpenURL(url) {
176175
UIApplication.shared.open(url, options: [:], completionHandler: nil)
177-
}else{
176+
} else {
178177
self.log("Can't open AppStore")
179178
}
180179
}
181-
180+
182181
func log(_ value: String) {
183182
print("📲: [AppStore] => \(value)")
184183
}
185-
186184
}
187185

188-
189186
#endif

Sources/AppStoreManager/AppStoreManagerConstant.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,15 @@ struct AppStoreManagerConstant {
1414
static let updateButtonTitle = "Update"
1515
}
1616

17-
1817
extension Date {
19-
2018
static func days(since date: Date) -> Int {
2119
let calendar = Calendar(identifier: .gregorian)
2220
let components = calendar.dateComponents([.day], from: date, to: Date())
2321
return components.day ?? 0
2422
}
25-
2623
}
2724

28-
2925
extension String {
30-
3126
func toDate(with format: String) -> Date? {
3227
let dateFormatter = DateFormatter()
3328
dateFormatter.calendar = Calendar(identifier: .gregorian)
@@ -37,5 +32,4 @@ extension String {
3732
let date = dateFormatter.date(from: self)
3833
return date
3934
}
40-
4135
}

Sources/AppStoreManager/AppStoreManagerModels.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ struct AppStoreResult: Decodable {
1616
let trackId: Int?
1717
let version: String?
1818
let currentVersionReleaseDate: Date?
19-
19+
2020
private enum CodingKeys: String, CodingKey {
2121
case trackId
2222
case version
2323
case currentVersionReleaseDate
2424
}
25-
25+
2626
init(from decoder: Decoder) throws {
2727
let container = try decoder.container(keyedBy: CodingKeys.self)
2828
self.trackId = try? container.decodeIfPresent(Int.self, forKey: .trackId)
@@ -33,5 +33,4 @@ struct AppStoreResult: Decodable {
3333
self.currentVersionReleaseDate = nil
3434
}
3535
}
36-
3736
}

Tests/AppStoreManagerTests/AppStoreManagerTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
// Created by Visarut Tippun on 8/1/21.
66
//
77

8-
import XCTest
98
@testable import AppStoreManager
9+
import XCTest
1010

1111
class AppStoreManagerTests: XCTestCase {
12-
1312
override func setUpWithError() throws {
1413
// Put setup code here. This method is called before the invocation of each test method in the class.
1514
}
@@ -29,5 +28,4 @@ class AppStoreManagerTests: XCTestCase {
2928
// Put the code you want to measure the time of here.
3029
}
3130
}
32-
3331
}

0 commit comments

Comments
 (0)