From 1779516b9deac6674de70a33673dce7efb5b4b59 Mon Sep 17 00:00:00 2001 From: Ivan Vavilov Date: Mon, 20 Nov 2023 15:14:52 -0800 Subject: [PATCH] Update podspec. Raise min target to iOS 13 --- Apexy.podspec | 8 +-- Example/Example.xcodeproj/project.pbxproj | 6 +- .../Business Logic/Service/BookService.swift | 15 +---- .../Business Logic/Service/FileService.swift | 28 +-------- .../Sources/Business Logic/ServiceLayer.swift | 14 ++--- .../Sources/Presentation/ViewController.swift | 59 +------------------ Example/Podfile.lock | 8 +-- 7 files changed, 23 insertions(+), 115 deletions(-) diff --git a/Apexy.podspec b/Apexy.podspec index 8c96b26..e0453da 100644 --- a/Apexy.podspec +++ b/Apexy.podspec @@ -7,21 +7,21 @@ Pod::Spec.new do |s| s.author = { "Alexander Ignatiev" => "ai@redmadrobot.com" } s.source = { :git => "https://github.com/RedMadRobot/apexy-ios.git", :tag => "#{s.version}" } - s.ios.deployment_target = "11.0" - s.tvos.deployment_target = "11.0" + s.ios.deployment_target = "13.0" + s.tvos.deployment_target = "13.0" s.osx.deployment_target = "10.13" s.watchos.deployment_target = "4.0" s.swift_version = "5.3" s.subspec 'Core' do |sp| - sp.source_files = "Sources/Apexy/*.swift" + sp.source_files = "Sources/Apexy/**/*.swift" end s.subspec 'Alamofire' do |sp| sp.source_files = "Sources/ApexyAlamofire/*.swift" sp.dependency "Apexy/Core" - sp.dependency "Alamofire", '~>5.0' + sp.dependency "Alamofire", '~>5.6' end s.subspec 'URLSession' do |sp| diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 7b13f54..e3271bd 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -791,7 +791,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 42LRQS6X44; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -812,7 +812,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 42LRQS6X44; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Example/Example/Sources/Business Logic/Service/BookService.swift b/Example/Example/Sources/Business Logic/Service/BookService.swift index 660a5e6..d652088 100644 --- a/Example/Example/Sources/Business Logic/Service/BookService.swift +++ b/Example/Example/Sources/Business Logic/Service/BookService.swift @@ -12,29 +12,18 @@ import ExampleAPI typealias Book = ExampleAPI.Book protocol BookService { - - @discardableResult - func fetchBooks(completion: @escaping (Result<[Book], Error>) -> Void) -> Progress - - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func fetchBooks() async throws -> [Book] } final class BookServiceImpl: BookService { - let apiClient: Client + let apiClient: ConcurrencyClient - init(apiClient: Client) { + init(apiClient: ConcurrencyClient) { self.apiClient = apiClient } - func fetchBooks(completion: @escaping (Result<[Book], Error>) -> Void) -> Progress { - let endpoint = BookListEndpoint() - return apiClient.request(endpoint, completionHandler: completion) - } - - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func fetchBooks() async throws -> [Book] { let endpoint = BookListEndpoint() return try await apiClient.request(endpoint) diff --git a/Example/Example/Sources/Business Logic/Service/FileService.swift b/Example/Example/Sources/Business Logic/Service/FileService.swift index 686a90d..d72f60a 100644 --- a/Example/Example/Sources/Business Logic/Service/FileService.swift +++ b/Example/Example/Sources/Business Logic/Service/FileService.swift @@ -10,46 +10,24 @@ import Apexy import ExampleAPI protocol FileService { - - @discardableResult - func upload(file: URL, completion: @escaping (Result) -> Void) -> Progress - - @discardableResult - func upload(stream: InputStream, size: Int, completion: @escaping (Result) -> Void) -> Progress - - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func upload(file: URL) async throws - - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func upload(stream: InputStream, size: Int) async throws } final class FileServiceImpl: FileService { - let apiClient: Client + let apiClient: ConcurrencyClient - init(apiClient: Client) { + init(apiClient: ConcurrencyClient) { self.apiClient = apiClient } - - func upload(file: URL, completion: @escaping (Result) -> Void) -> Progress { - let endpoint = FileUploadEndpoint(fileURL: file) - return apiClient.upload(endpoint, completionHandler: completion) - } - - func upload(stream: InputStream, size: Int, completion: @escaping (Result) -> Void) -> Progress { - let endpoint = StreamUploadEndpoint(stream: stream, size: size) - return apiClient.upload(endpoint, completionHandler: completion) - } - - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) + func upload(file: URL) async throws { let endpoint = FileUploadEndpoint(fileURL: file) return try await apiClient.upload(endpoint) } - @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) func upload(stream: InputStream, size: Int) async throws { let endpoint = StreamUploadEndpoint(stream: stream, size: size) return try await apiClient.upload(endpoint) diff --git a/Example/Example/Sources/Business Logic/ServiceLayer.swift b/Example/Example/Sources/Business Logic/ServiceLayer.swift index 7631679..e224fca 100644 --- a/Example/Example/Sources/Business Logic/ServiceLayer.swift +++ b/Example/Example/Sources/Business Logic/ServiceLayer.swift @@ -15,14 +15,12 @@ final class ServiceLayer { static let shared = ServiceLayer() - private(set) lazy var apiClient: Client = { - return AlamofireClient( - baseURL: URL(string: "https://library.mock-object.redmadserver.com/api/v1/")!, - configuration: .ephemeral, - responseObserver: { [weak self] request, response, data, error in - self?.validateSession(responseError: error) - }) - }() + private(set) lazy var apiClient: ConcurrencyClient = AlamofireClient( + baseURL: URL(string: "https://library.mock-object.redmadserver.com/api/v1/")!, + configuration: .ephemeral, + responseObserver: { [weak self] request, response, data, error in + self?.validateSession(responseError: error) + }) private(set) lazy var bookService: BookService = BookServiceImpl(apiClient: apiClient) diff --git a/Example/Example/Sources/Presentation/ViewController.swift b/Example/Example/Sources/Presentation/ViewController.swift index d5a7152..2a08bac 100644 --- a/Example/Example/Sources/Presentation/ViewController.swift +++ b/Example/Example/Sources/Presentation/ViewController.swift @@ -30,8 +30,6 @@ class ViewController: UIViewController { @IBAction private func performRequest() { activityView.isHidden = false - guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { performLegacyRequest(); return } - task = Task { do { let books = try await bookService.fetchBooks() @@ -43,25 +41,9 @@ class ViewController: UIViewController { } } - private func performLegacyRequest() { - progress = bookService.fetchBooks() { [weak self] result in - guard let self = self else { return } - self.activityView.isHidden = true - switch result { - case .success(let books): - self.show(books: books) - case .failure(let error): - self.show(error: error) - } - } - } - - @IBAction private func upload() { guard let file = Bundle.main.url(forResource: "Info", withExtension: "plist") else { return } activityView.isHidden = false - - guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { legacyUpload(with: file); return } task = Task { do { @@ -73,27 +55,12 @@ class ViewController: UIViewController { activityView.isHidden = true } } - - private func legacyUpload(with file: URL) { - progress = fileService.upload(file: file) { [weak self] result in - guard let self = self else { return } - self.activityView.isHidden = true - switch result { - case .success: - self.showOKUpload() - case .failure(let error): - self.show(error: error) - } - } - } - + @IBAction private func uploadStream() { let streamer = Streamer() self.streamer = streamer activityView.isHidden = false - guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { legacyUploadStream(with: streamer); return } - streamer.run() task = Task { @@ -106,30 +73,6 @@ class ViewController: UIViewController { } } - private func legacyUploadStream(with streamer: Streamer) { - progress = fileService.upload( - stream: streamer.boundStreams.input, - size: streamer.totalDataSize) { [weak self] result in - guard let self = self else { return } - self.activityView.isHidden = true - switch result { - case .success: - self.showOKUpload() - case .failure(let error): - self.show(error: error) - self.streamer = nil - } - } - streamer.run() - - observation = progress?.observe(\.fractionCompleted, options: [.new]) { [weak self] (progress, value) in - DispatchQueue.main.async { - let percent = (value.newValue ?? 0) * 100 - self?.resultLabel.text = "Progress: \(String(format: "%.0f", percent))%" - } - } - } - @IBAction private func cancel() { if #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) { (task as? Task)?.cancel() diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 397dfa8..7491936 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - Alamofire (5.4.1) + - Alamofire (5.8.1) - Apexy (1.7.4): - Apexy/Alamofire (= 1.7.4) - Apexy/Alamofire (1.7.4): - - Alamofire (~> 5.0) + - Alamofire (~> 5.6) - Apexy/Core - Apexy/Core (1.7.4) @@ -19,8 +19,8 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Alamofire: 2291f7d21ca607c491dd17642e5d40fdcda0e65c - Apexy: 5cc53ad442b280a27e03ffa39f06ce3a5412b418 + Alamofire: 3ca42e259043ee0dc5c0cdd76c4bc568b8e42af7 + Apexy: a3218097135e746fd7c9215da167521f9275df23 PODFILE CHECKSUM: f86a90e7590ccb3aa7caeceaf315abe256650c66