From a06761f924fd16eb881309c06b28b8b7852b1677 Mon Sep 17 00:00:00 2001 From: Noah Martin Date: Fri, 11 Oct 2024 13:22:13 +0100 Subject: [PATCH] Updates (#4) --- ETDistribution.podspec | 12 ++++++++++++ Package.swift | 3 +-- {ETDistribution => Sources}/ETDistribution.swift | 5 +++-- .../Mach-O/BinaryParser.swift | 3 +-- .../Models/DistributionReleaseInfo.swift | 0 .../Models/DistributionUpdateCheckResponse.swift | 0 .../Network/URLSession+Distribute.swift | 2 +- {ETDistribution => Sources}/UserAction.swift | 0 .../UserDefaults+ETDistribution.swift | 2 +- .../ViewController/UIViewController+Distribute.swift | 0 10 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 ETDistribution.podspec rename {ETDistribution => Sources}/ETDistribution.swift (99%) rename {ETDistribution => Sources}/Mach-O/BinaryParser.swift (93%) rename {ETDistribution => Sources}/Models/DistributionReleaseInfo.swift (100%) rename {ETDistribution => Sources}/Models/DistributionUpdateCheckResponse.swift (100%) rename {ETDistribution => Sources}/Network/URLSession+Distribute.swift (98%) rename {ETDistribution => Sources}/UserAction.swift (100%) rename {ETDistribution => Sources}/UserDefaults+ETDistribution.swift (94%) rename {ETDistribution => Sources}/ViewController/UIViewController+Distribute.swift (100%) diff --git a/ETDistribution.podspec b/ETDistribution.podspec new file mode 100644 index 0000000..c4e322a --- /dev/null +++ b/ETDistribution.podspec @@ -0,0 +1,12 @@ +Pod::Spec.new do |spec| + spec.name = 'ETDistribution' + spec.version = '0.1.1' + spec.summary = 'iOS app installer.' + spec.homepage = 'https://github.com/EmergeTools/ETDistribution' + spec.license = { :type => 'MIT', :file => 'LICENSE' } + spec.author = { 'YourName' => 'youremail@example.com' } + spec.source = { :git => 'https://github.com/EmergeTools/ETDistribution.git', :tag => 'v0.1.1' } + spec.platform = :ios, '13.0' + spec.swift_version = '5.10' + spec.source_files = 'Sources/**/*.{swift,h,m}' +end diff --git a/Package.swift b/Package.swift index f2eb1ae..6403a33 100644 --- a/Package.swift +++ b/Package.swift @@ -17,8 +17,7 @@ let package = Package( targets: [ .target( name: "ETDistribution", - dependencies: [], - path: "ETDistribution" + dependencies: [] ), ] ) diff --git a/ETDistribution/ETDistribution.swift b/Sources/ETDistribution.swift similarity index 99% rename from ETDistribution/ETDistribution.swift rename to Sources/ETDistribution.swift index 2b4e022..6ec3f91 100644 --- a/ETDistribution/ETDistribution.swift +++ b/Sources/ETDistribution.swift @@ -109,7 +109,7 @@ public final class ETDistribution: NSObject { #if targetEnvironment(simulator) // Not checking for updates on the simulator return -#endif +#else guard !isDebuggerAttached() else { // Not checking for updates when the debugger is attached return @@ -136,13 +136,14 @@ public final class ETDistribution: NSObject { request.httpMethod = "GET" session.checkForUpdate(request) { [weak self] result in - var mappedResult = result.map { $0.updateInfo } + let mappedResult = result.map { $0.updateInfo } if let completion = completion { completion(mappedResult) } else if let response = try? mappedResult.get() { self?.handleResponse(response: response) } } +#endif } private func handleResponse(response: DistributionReleaseInfo) { diff --git a/ETDistribution/Mach-O/BinaryParser.swift b/Sources/Mach-O/BinaryParser.swift similarity index 93% rename from ETDistribution/Mach-O/BinaryParser.swift rename to Sources/Mach-O/BinaryParser.swift index 33241d4..83ea6b3 100644 --- a/ETDistribution/Mach-O/BinaryParser.swift +++ b/Sources/Mach-O/BinaryParser.swift @@ -24,7 +24,6 @@ struct BinaryParser { for i in 0..<_dyld_image_count() { guard let header = _dyld_get_image_header(i) else { continue } - let imageName = _dyld_get_image_name(0) let imagePath = String(cString: _dyld_get_image_name(i)) guard imagePath == executablePath else { @@ -32,7 +31,7 @@ struct BinaryParser { } var _uuid = UUID().uuid - let result = withUnsafeMutablePointer(to: &_uuid) { + let _ = withUnsafeMutablePointer(to: &_uuid) { _dyld_get_image_uuid(header, $0) } return formatUUID(_uuid) diff --git a/ETDistribution/Models/DistributionReleaseInfo.swift b/Sources/Models/DistributionReleaseInfo.swift similarity index 100% rename from ETDistribution/Models/DistributionReleaseInfo.swift rename to Sources/Models/DistributionReleaseInfo.swift diff --git a/ETDistribution/Models/DistributionUpdateCheckResponse.swift b/Sources/Models/DistributionUpdateCheckResponse.swift similarity index 100% rename from ETDistribution/Models/DistributionUpdateCheckResponse.swift rename to Sources/Models/DistributionUpdateCheckResponse.swift diff --git a/ETDistribution/Network/URLSession+Distribute.swift b/Sources/Network/URLSession+Distribute.swift similarity index 98% rename from ETDistribution/Network/URLSession+Distribute.swift rename to Sources/Network/URLSession+Distribute.swift index 68a4b55..71c9c74 100644 --- a/ETDistribution/Network/URLSession+Distribute.swift +++ b/Sources/Network/URLSession+Distribute.swift @@ -32,7 +32,7 @@ extension URLSession { return } guard (200...299).contains(httpResponse.statusCode) else { - var errorMessage = ( + let errorMessage = ( try? JSONDecoder().decode( DistributionUpdateCheckErrorResponse.self, from: data diff --git a/ETDistribution/UserAction.swift b/Sources/UserAction.swift similarity index 100% rename from ETDistribution/UserAction.swift rename to Sources/UserAction.swift diff --git a/ETDistribution/UserDefaults+ETDistribution.swift b/Sources/UserDefaults+ETDistribution.swift similarity index 94% rename from ETDistribution/UserDefaults+ETDistribution.swift rename to Sources/UserDefaults+ETDistribution.swift index fc2142f..99c9ddd 100644 --- a/ETDistribution/UserDefaults+ETDistribution.swift +++ b/Sources/UserDefaults+ETDistribution.swift @@ -24,7 +24,7 @@ extension UserDefaults { class var postponeTimeout: Date? { get { - let epoch = UserDefaults(suiteName: "com.emerge.distribution")!.double(forKey: Keys.skipedRelease) ?? 0 + let epoch = UserDefaults(suiteName: "com.emerge.distribution")!.double(forKey: Keys.skipedRelease) return Date(timeIntervalSince1970: epoch) } set { diff --git a/ETDistribution/ViewController/UIViewController+Distribute.swift b/Sources/ViewController/UIViewController+Distribute.swift similarity index 100% rename from ETDistribution/ViewController/UIViewController+Distribute.swift rename to Sources/ViewController/UIViewController+Distribute.swift