Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPDATE] iOS 15 as minimal version #24

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions NGTools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
B2454D7E29102936001E7B9E /* CryptoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2454D7D29102936001E7B9E /* CryptoTests.swift */; };
B24713052911633100FBD1E9 /* CryptoBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B24713042911633100FBD1E9 /* CryptoBuilder.swift */; };
B24713092911665300FBD1E9 /* CryptoKitAES.swift in Sources */ = {isa = PBXBuildFile; fileRef = B24713082911665300FBD1E9 /* CryptoKitAES.swift */; };
B247130B2911665D00FBD1E9 /* CryptoSwiftAES.swift in Sources */ = {isa = PBXBuildFile; fileRef = B247130A2911665D00FBD1E9 /* CryptoSwiftAES.swift */; };
B247130D2911697600FBD1E9 /* CryptoKitServerEncryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B247130C2911697600FBD1E9 /* CryptoKitServerEncryptor.swift */; };
B247130F2911697F00FBD1E9 /* CryptoSwiftServerEncryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B247130E2911697F00FBD1E9 /* CryptoSwiftServerEncryptor.swift */; };
B2471311291169C600FBD1E9 /* ServerEncryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2471310291169C600FBD1E9 /* ServerEncryptor.swift */; };
B247131529116C1800FBD1E9 /* Crypto.swift in Sources */ = {isa = PBXBuildFile; fileRef = B247131429116C1800FBD1E9 /* Crypto.swift */; };
B295F3B02907729D00CB4087 /* CryptoRSA.swift in Sources */ = {isa = PBXBuildFile; fileRef = B295F3AD2907729D00CB4087 /* CryptoRSA.swift */; };
Expand Down Expand Up @@ -129,9 +127,7 @@
B2454D7D29102936001E7B9E /* CryptoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoTests.swift; sourceTree = "<group>"; };
B24713042911633100FBD1E9 /* CryptoBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoBuilder.swift; sourceTree = "<group>"; };
B24713082911665300FBD1E9 /* CryptoKitAES.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoKitAES.swift; sourceTree = "<group>"; };
B247130A2911665D00FBD1E9 /* CryptoSwiftAES.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoSwiftAES.swift; sourceTree = "<group>"; };
B247130C2911697600FBD1E9 /* CryptoKitServerEncryptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoKitServerEncryptor.swift; sourceTree = "<group>"; };
B247130E2911697F00FBD1E9 /* CryptoSwiftServerEncryptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoSwiftServerEncryptor.swift; sourceTree = "<group>"; };
B2471310291169C600FBD1E9 /* ServerEncryptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerEncryptor.swift; sourceTree = "<group>"; };
B247131429116C1800FBD1E9 /* Crypto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Crypto.swift; sourceTree = "<group>"; };
B295F3AD2907729D00CB4087 /* CryptoRSA.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptoRSA.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -293,23 +289,13 @@
path = CryptoKit;
sourceTree = "<group>";
};
B26DB2032911B0BF0074D4B0 /* CryptoSwift */ = {
isa = PBXGroup;
children = (
B247130E2911697F00FBD1E9 /* CryptoSwiftServerEncryptor.swift */,
B247130A2911665D00FBD1E9 /* CryptoSwiftAES.swift */,
);
path = CryptoSwift;
sourceTree = "<group>";
};
B295F3B1290772A200CB4087 /* Crypto */ = {
isa = PBXGroup;
children = (
B247131429116C1800FBD1E9 /* Crypto.swift */,
B24713042911633100FBD1E9 /* CryptoBuilder.swift */,
B2471310291169C600FBD1E9 /* ServerEncryptor.swift */,
B26DB2022911B0B50074D4B0 /* CryptoKit */,
B26DB2032911B0BF0074D4B0 /* CryptoSwift */,
B295F3AD2907729D00CB4087 /* CryptoRSA.swift */,
A42157D726EA34CA008C21D2 /* Data+Extensions.swift */,
);
Expand Down Expand Up @@ -438,7 +424,6 @@
files = (
A42157E926EA34CA008C21D2 /* Reachability.swift in Sources */,
A421580326EA350F008C21D2 /* Array+Extensions.swift in Sources */,
B247130F2911697F00FBD1E9 /* CryptoSwiftServerEncryptor.swift in Sources */,
A421580A26EA350F008C21D2 /* Calendar+Extensions.swift in Sources */,
A42157E826EA34CA008C21D2 /* UserDefaultsPersistanceStrategy.swift in Sources */,
A42157E326EA34CA008C21D2 /* AnyDecodable.swift in Sources */,
Expand Down Expand Up @@ -477,7 +462,6 @@
A4C75F5027BED96E00F752A3 /* MigrationRunner.swift in Sources */,
A421580C26EA350F008C21D2 /* NSDirectionalEdgeInsets+Extensions.swift in Sources */,
A494C0B927C40EC700EA0C37 /* MigrationTaskState.swift in Sources */,
B247130B2911665D00FBD1E9 /* CryptoSwiftAES.swift in Sources */,
B295F3B02907729D00CB4087 /* CryptoRSA.swift in Sources */,
A4F8E82B2A86BD350058F809 /* Defaults.swift in Sources */,
A42157E126EA34CA008C21D2 /* stringify.swift in Sources */,
Expand Down Expand Up @@ -563,7 +547,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 = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -622,7 +606,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 = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -651,6 +635,7 @@
);
INFOPLIST_FILE = Sources/NGTools/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -684,6 +669,7 @@
);
INFOPLIST_FILE = Sources/NGTools/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// swift-tools-version:5.3
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "NGTools",
platforms: [.iOS(.v11)],
platforms: [.iOS(.v15)],
products: [
.library(
name: "NGTools",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import UIKit

@available(iOS 11.0, *)
public extension NSDirectionalEdgeInsets {

init(_ value: CGFloat) {
Expand Down
7 changes: 1 addition & 6 deletions Sources/NGTools/Extensions/ProcessInfo+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@
import Foundation

public extension ProcessInfo {

@objc var isAppRunningOnMac: Bool {
guard #available(iOS 14.0, *) else { return false }

return isiOSAppOnMac
}
@objc var isAppRunningOnMac: Bool { isiOSAppOnMac }
}
6 changes: 1 addition & 5 deletions Sources/NGTools/Extensions/UIFont+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import UIKit
public extension UIFont {

var dynamicTypeFont: UIFont {
if #available(iOS 11.0, *) {
return UIFontMetrics.default.scaledFont(for: self)
} else {
return self
}
return UIFontMetrics.default.scaledFont(for: self)
}

static func customFont(for fontName: String?, size: CGFloat, fallbackFont: UIFont = UIFont.systemFont(ofSize: UIFont.systemFontSize)) -> UIFont {
Expand Down
6 changes: 1 addition & 5 deletions Sources/NGTools/Utils/Crypto/CryptoBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import Foundation

struct CryptoBuilder {
static func build() -> ServerEncryptor {
if #available(iOS 13.0, *) {
return CryptoKitServerEncryptor()
} else {
return CryptoSwiftServerEncryptor()
}
return CryptoKitServerEncryptor()
}
}
1 change: 0 additions & 1 deletion Sources/NGTools/Utils/Crypto/CryptoKit/CryptoKitAES.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Foundation
import CryptoKit

@available(iOS 13.0, *)
struct CryptoKitAES {

static func getAESKey(_ keyData: Data) -> SymmetricKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Foundation
import CryptoKit

@available(iOS 13.0, *)
struct CryptoKitServerEncryptor: ServerEncryptor {

func encryptForAuthenticationServer(_ text: String, rsaPublicKey: String) throws -> String {
Expand Down
35 changes: 0 additions & 35 deletions Sources/NGTools/Utils/Crypto/CryptoSwift/CryptoSwiftAES.swift

This file was deleted.

This file was deleted.

14 changes: 2 additions & 12 deletions Sources/NGTools/Utils/Storage/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ extension Defaults: CodableStorage {
return nil
}
} catch {
if #available(iOS 14.0, *) {
Logger.main.error("Error retreiving object: \(error)")
} else {
print("Error retreiving object: \(error)")
}
Logger.main.error("Error retreiving object: \(error)")
return nil
}

Expand All @@ -63,11 +59,7 @@ extension Defaults: CodableStorage {
backingStore?.set(data, forKey: key.name)
}
} catch {
if #available(iOS 14.0, *) {
Logger.main.error("Error storing object: \(error)")
} else {
print("Error storing object: \(error)")
}
Logger.main.error("Error storing object: \(error)")
}
}

Expand Down Expand Up @@ -113,8 +105,6 @@ private extension Key {
}

// MARK: - Private
@available(iOS 14.0, *)
private extension Logger {

static let main = Logger(subsystem: "com.nuglif.ngtools", category: "Defaults")
}
25 changes: 0 additions & 25 deletions Tests/NGToolsTests/CryptoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,7 @@ final class CryptoTests: XCTestCase {
let base64KeyData = "xuklFcMMklVs3uOwsaOGLzgVpZyjhgm8Ffm9Qf27JZc="
let base64IVData = "4lKdApKttNHlw4p/nwKEVw=="

func testCryptoSwiftAESEncryption() {
do {
guard let keyData = Data(base64Encoded: base64KeyData), let ivData = Data(base64Encoded: base64IVData) else {
XCTFail("Failed to create data")
return
}

let encodedData = try CryptoSwiftAES.encrypt(message, aesKey: keyData, iv: ivData)
let encodedDataBase64 = encodedData.cipherText.base64EncodedString()
let expectedValue = "mU4TsQ24Ug=="

XCTAssertEqual(encodedDataBase64, expectedValue, "Unexpected encrypted data")

let decodedData = try CryptoSwiftAES.decrypt(encodedData.cipherText, aesKey: keyData, iv: ivData, tag: encodedData.tag)
XCTAssertEqual(String(data: decodedData, encoding: .utf8), message)

} catch Crypto.CryptoError.aesEncryptionError {
XCTFail("Failed to encrypt message")
} catch {
XCTFail("Failed to decrypt message")
}
}

func testCryptoKitAESEncryption() {
guard #available(iOS 13, *) else { return }

do {
guard let keyData = Data(base64Encoded: base64KeyData) else {
XCTFail("Failed to create data")
Expand Down