Skip to content

Commit

Permalink
Update podspec. Raise min target to iOS 13
Browse files Browse the repository at this point in the history
  • Loading branch information
vani2 committed Nov 20, 2023
1 parent d17c1a5 commit 1779516
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 115 deletions.
8 changes: 4 additions & 4 deletions Apexy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ Pod::Spec.new do |s|
s.author = { "Alexander Ignatiev" => "[email protected]" }
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|
Expand Down
6 changes: 3 additions & 3 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
15 changes: 2 additions & 13 deletions Example/Example/Sources/Business Logic/Service/BookService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 3 additions & 25 deletions Example/Example/Sources/Business Logic/Service/FileService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,24 @@ import Apexy
import ExampleAPI

protocol FileService {

@discardableResult
func upload(file: URL, completion: @escaping (Result<Void, Error>) -> Void) -> Progress

@discardableResult
func upload(stream: InputStream, size: Int, completion: @escaping (Result<Void, Error>) -> 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, Error>) -> Void) -> Progress {
let endpoint = FileUploadEndpoint(fileURL: file)
return apiClient.upload(endpoint, completionHandler: completion)
}

func upload(stream: InputStream, size: Int, completion: @escaping (Result<Void, Error>) -> 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)
Expand Down
14 changes: 6 additions & 8 deletions Example/Example/Sources/Business Logic/ServiceLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
59 changes: 1 addition & 58 deletions Example/Example/Sources/Presentation/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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<Void, Never>)?.cancel()
Expand Down
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -19,8 +19,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
Alamofire: 2291f7d21ca607c491dd17642e5d40fdcda0e65c
Apexy: 5cc53ad442b280a27e03ffa39f06ce3a5412b418
Alamofire: 3ca42e259043ee0dc5c0cdd76c4bc568b8e42af7
Apexy: a3218097135e746fd7c9215da167521f9275df23

PODFILE CHECKSUM: f86a90e7590ccb3aa7caeceaf315abe256650c66

Expand Down

0 comments on commit 1779516

Please sign in to comment.