From 7d35c798c6da3ccb8766ce055ca9cfa4b27e225e Mon Sep 17 00:00:00 2001 From: Koichi Yokota Date: Thu, 29 Sep 2022 22:54:45 +0900 Subject: [PATCH] Update platform versions (#55) * Update platform versions * Replace new API about `FileHandle` --- CHANGELOG.md | 1 + Configurations/Common.xcconfig | 8 ++--- Package.resolved | 4 +-- Package.swift | 4 +-- Puppy.podspec | 8 ++--- Puppy.xcodeproj/project.pbxproj | 18 +++++------ .../xcshareddata/swiftpm/Package.resolved | 24 +++++++------- Sources/Puppy/FileLogger.swift | 32 ++++--------------- Sources/Puppy/FileRotationLogger.swift | 2 +- Tests/PuppyTests/FileLoggerTests.swift | 6 ++-- 10 files changed, 44 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e136fdb..e7c1cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [x.y.z](https://github.com/sushichop/Puppy/releases/tag/x.y.z) (yyyy-mm-dd) - Disable bitcode. [#54](https://github.com/sushichop/Puppy/pull/54) +- Update platform versions. [#55](https://github.com/sushichop/Puppy/pull/55) ## [0.5.1](https://github.com/sushichop/Puppy/releases/tag/0.5.1) (2022-09-24) diff --git a/Configurations/Common.xcconfig b/Configurations/Common.xcconfig index f46fa2c..3b00efb 100644 --- a/Configurations/Common.xcconfig +++ b/Configurations/Common.xcconfig @@ -12,10 +12,10 @@ CODE_SIGN_IDENTITY = DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = NO SUPPORTS_MACCATALYST = YES -MACOSX_DEPLOYMENT_TARGET = 10.12 -IPHONEOS_DEPLOYMENT_TARGET = 10.0 -TVOS_DEPLOYMENT_TARGET = 10.0 -WATCHOS_DEPLOYMENT_TARGET = 3.0 +MACOSX_DEPLOYMENT_TARGET = 11.0 +IPHONEOS_DEPLOYMENT_TARGET = 14.0 +TVOS_DEPLOYMENT_TARGET = 14.0 +WATCHOS_DEPLOYMENT_TARGET = 7.0 SWIFT_VERSION = 5.0 diff --git a/Package.resolved b/Package.resolved index e4dd439..8ae875f 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/apple/swift-log.git", "state": { "branch": null, - "revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", - "version": "1.4.2" + "revision": "6fe203dc33195667ce1759bf0182975e4653ba1c", + "version": "1.4.4" } } ] diff --git a/Package.swift b/Package.swift index ce71072..03361b1 100644 --- a/Package.swift +++ b/Package.swift @@ -6,13 +6,13 @@ import PackageDescription let package = Package( name: "Puppy", platforms: [ - .macOS(.v10_12), .iOS(.v10), .tvOS(.v10), .watchOS(.v3), + .macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7), ], products: [ .library(name: "Puppy", targets: ["Puppy"]), ], dependencies: [ - .package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"), + .package(url: "https://github.com/apple/swift-log.git", from: "1.4.4"), ], targets: [ .target(name: "CPuppy", diff --git a/Puppy.podspec b/Puppy.podspec index 637f029..303dbee 100644 --- a/Puppy.podspec +++ b/Puppy.podspec @@ -6,10 +6,10 @@ Pod::Spec.new do |s| s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Koichi Yokota" => "sushifarm2012@gmail.com" } - s.osx.deployment_target = "10.12" - s.ios.deployment_target = "10.0" - s.tvos.deployment_target = "10.0" - s.watchos.deployment_target = "3.0" + s.osx.deployment_target = "11.0" + s.ios.deployment_target = "14.0" + s.tvos.deployment_target = "14.0" + s.watchos.deployment_target = "7.0" s.source = { :git => "https://github.com/sushichop/Puppy.git", :tag => "#{s.version}" } diff --git a/Puppy.xcodeproj/project.pbxproj b/Puppy.xcodeproj/project.pbxproj index 883348a..ba26d88 100644 --- a/Puppy.xcodeproj/project.pbxproj +++ b/Puppy.xcodeproj/project.pbxproj @@ -30,7 +30,7 @@ C7695BB42533303900E0CA22 /* MockLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7695BB32533303900E0CA22 /* MockLogger.swift */; }; C7695BC2253332DF00E0CA22 /* BaseLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7695BC1253332DF00E0CA22 /* BaseLoggerTests.swift */; }; C789CB8E27A81146001C7589 /* CPuppy.c in Sources */ = {isa = PBXBuildFile; fileRef = C712BB0B266F31C80016A768 /* CPuppy.c */; }; - C7C3C7AF26D51D6E00856A45 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = C7C3C7AE26D51D6E00856A45 /* Logging */; }; + C7AF2C2928E4AA4200B49E90 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = C7AF2C2828E4AA4200B49E90 /* Logging */; }; C7ED71A8252DBEC70065B955 /* Puppy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7ED719E252DBEC70065B955 /* Puppy.framework */; }; C7ED71FC252DC0C50065B955 /* FileRotationLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7ED71F0252DC0C50065B955 /* FileRotationLogger.swift */; }; C7ED71FD252DC0C50065B955 /* SystemLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7ED71F1252DC0C50065B955 /* SystemLogger.swift */; }; @@ -140,7 +140,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - C7C3C7AF26D51D6E00856A45 /* Logging in Frameworks */, + C7AF2C2928E4AA4200B49E90 /* Logging in Frameworks */, C74F94C826778428003A88BE /* CPuppy.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -379,7 +379,7 @@ ); name = Puppy; packageProductDependencies = ( - C7C3C7AE26D51D6E00856A45 /* Logging */, + C7AF2C2828E4AA4200B49E90 /* Logging */, ); productName = Puppy; productReference = C7ED719E252DBEC70065B955 /* Puppy.framework */; @@ -440,7 +440,7 @@ ); mainGroup = C7ED7194252DBEC70065B955; packageReferences = ( - C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */, + C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */, ); productRefGroup = C7ED719F252DBEC70065B955 /* Products */; projectDirPath = ""; @@ -893,20 +893,20 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */ = { + C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/apple/swift-log.git"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 1.4.2; + kind = upToNextMinorVersion; + minimumVersion = 1.4.4; }; }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - C7C3C7AE26D51D6E00856A45 /* Logging */ = { + C7AF2C2828E4AA4200B49E90 /* Logging */ = { isa = XCSwiftPackageProductDependency; - package = C7C3C7AD26D51D6E00856A45 /* XCRemoteSwiftPackageReference "swift-log" */; + package = C7AF2C2728E4AA4200B49E90 /* XCRemoteSwiftPackageReference "swift-log" */; productName = Logging; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Puppy.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Puppy.xcworkspace/xcshareddata/swiftpm/Package.resolved index e4dd439..81b1835 100644 --- a/Puppy.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Puppy.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,16 +1,14 @@ { - "object": { - "pins": [ - { - "package": "swift-log", - "repositoryURL": "https://github.com/apple/swift-log.git", - "state": { - "branch": null, - "revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", - "version": "1.4.2" - } + "pins" : [ + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c", + "version" : "1.4.4" } - ] - }, - "version": 1 + } + ], + "version" : 2 } diff --git a/Sources/Puppy/FileLogger.swift b/Sources/Puppy/FileLogger.swift index 58c3645..fca5ead 100644 --- a/Sources/Puppy/FileLogger.swift +++ b/Sources/Puppy/FileLogger.swift @@ -33,13 +33,13 @@ public class FileLogger: BaseLogger { public override func log(_ level: LogLevel, string: String) { do { - _ = try fileHandle?.seekToEndCompatible() + _ = try fileHandle?.seekToEnd() if let data = (string + "\r\n").data(using: .utf8) { // swiftlint:disable force_try - try! fileHandle?.writeCompatible(contentsOf: data) + try! fileHandle?.write(contentsOf: data) // swiftlint:enable force_try if flushMode == .always { - fileHandle?.synchronizeFile() + try? fileHandle?.synchronize() } } } catch { @@ -70,13 +70,13 @@ public class FileLogger: BaseLogger { public func flush() { queue!.sync { - fileHandle?.synchronizeFile() + try? fileHandle?.synchronize() } } public func flush(completion: @escaping () -> Void) { queue!.async { - self.fileHandle?.synchronizeFile() + try? self.fileHandle?.synchronize() completion() } } @@ -113,8 +113,8 @@ public class FileLogger: BaseLogger { func closeFile() { if fileHandle != nil { - fileHandle.synchronizeFile() - fileHandle.closeFile() + try? fileHandle.synchronize() + try? fileHandle.close() fileHandle = nil } } @@ -134,21 +134,3 @@ public class FileLogger: BaseLogger { } } } - -extension FileHandle { - func seekToEndCompatible() throws -> UInt64 { - if #available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *) { - return try seekToEnd() - } else { - return seekToEndOfFile() - } - } - - func writeCompatible(contentsOf data: Data) throws { - if #available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *) { - try write(contentsOf: data) - } else { - write(data) - } - } -} diff --git a/Sources/Puppy/FileRotationLogger.swift b/Sources/Puppy/FileRotationLogger.swift index 9ed1998..8b1c665 100644 --- a/Sources/Puppy/FileRotationLogger.swift +++ b/Sources/Puppy/FileRotationLogger.swift @@ -25,7 +25,7 @@ public class FileRotationLogger: FileLogger { } private func rotateFiles() { - guard let size = try? fileHandle.seekToEndCompatible(), size > maxFileSize else { return } + guard let size = try? fileHandle.seekToEnd(), size > maxFileSize else { return } closeFile() // Rotates old archived files. diff --git a/Tests/PuppyTests/FileLoggerTests.swift b/Tests/PuppyTests/FileLoggerTests.swift index 4b51cce..4c04f77 100644 --- a/Tests/PuppyTests/FileLoggerTests.swift +++ b/Tests/PuppyTests/FileLoggerTests.swift @@ -239,15 +239,15 @@ final class FileLoggerTests: XCTestCase { } func testFlushFile() throws { - let flushFileURL = URL(fileURLWithPath: "./flush.log").absoluteURL - let fileLogger = try FileLogger("com.example.yourapp.filelogger.flush", fileURL: flushFileURL, flushMode: .manual) + let fileURL = URL(fileURLWithPath: "./flush.log").absoluteURL + let fileLogger = try FileLogger("com.example.yourapp.filelogger.flush", fileURL: fileURL, flushMode: .manual) let log = Puppy() log.add(fileLogger) log.trace("flush, TRACE message using FileLogger") log.verbose("flush, VERBOSE message using FileLogger") fileLogger.flush() - _ = fileLogger.delete(flushFileURL) + _ = fileLogger.delete(fileURL) log.remove(fileLogger) }