From 2c61416cf94df632bc0ed1bdcd0bfa253a86207e Mon Sep 17 00:00:00 2001 From: Tim Wise Date: Sun, 23 May 2021 12:54:19 -0700 Subject: [PATCH 1/3] Updated the computation of the temp directory for macOS and iOS. Refactored this computation to one location and propogatign across the library. The tests compute it separately, but similarly, and also have to handle the case between ///private/var/folders/... and ///var/folders/... being symlinks. --- Sources/SwiftLogFireCloud/LocalLogFile.swift | 24 +++++++---- .../SwiftLogFireCloudConfig.swift | 3 +- .../SwiftLogFireCloud/SwiftLogManager.swift | 26 ++++++++---- .../CloudLogFileManagerTests.swift | 23 ++++++---- .../LocalLogFileTests.swift | 16 +++---- .../SwiftLogFireCloudTests.swift | 8 +++- .../SwiftLogManagerTests.swift | 42 +++++++++++++------ .../TestFileSystemHelpers.swift | 24 ++++++----- 8 files changed, 108 insertions(+), 58 deletions(-) diff --git a/Sources/SwiftLogFireCloud/LocalLogFile.swift b/Sources/SwiftLogFireCloud/LocalLogFile.swift index 02289c1..ec65731 100644 --- a/Sources/SwiftLogFireCloud/LocalLogFile.swift +++ b/Sources/SwiftLogFireCloud/LocalLogFile.swift @@ -73,13 +73,13 @@ public class LocalLogFile { /// - label: The label used for the logger creating the log file /// - config: The loggers `SwiftLogFilreCloudConfig` object, for which the local log file uses the log directory and other aspects. /// - queue: The dispatch queue used for writing to the local disk. - init(label: String, config: SwiftLogFireCloudConfig, queue: DispatchQueue) { + init(label: String, config: SwiftLogFireCloudConfig, queue: DispatchQueue, tempURL: URL) { self.config = config self.label = label self.bufferSizeToGiveUp = 4 * config.localFileSizeThresholdToPushToCloud self.writeResponseQueue = queue self.fileURL = LocalLogFile.createLogFileURL( - localLogDirectoryName: config.logDirectoryName, clientDeviceID: config.uniqueIDString, label: label) + localLogDirectoryName: config.logDirectoryName, clientDeviceID: config.uniqueIDString, label: label, tempDirPath: tempURL) } deinit { @@ -91,11 +91,18 @@ public class LocalLogFile { /// - Returns: `String` representation of the log file name. private static func createLogFileName(deviceId: String?, label: String) -> String { var deviceIdForFileName = deviceId - #if os(iOS) - if deviceId == nil || deviceId?.count == 0 { + + if deviceId == nil || deviceId?.isEmpty ?? true { + #if os(iOS) deviceIdForFileName = UIDevice.current.identifierForVendor?.uuidString + #elseif os(macOS) + // this is suboptimal, as the uniquestring changes on each get so grouping by device will be problematic + // if the config is not set to something sane and unique across the consuming app. There is no equivalent + // identifierForVendor on macOS allegedly + deviceIdForFileName = ProcessInfo().globallyUniqueString + #endif } - #endif + let fileDateString = LocalLogFile.dateFormatter.string(from: Date()) let bundleString = Bundle.main.bundleIdentifier let versionNumber = @@ -132,14 +139,13 @@ public class LocalLogFile { /// - clientDeviceID: Client supplied unique identifer for the log /// - label: the SwiiftLog label specified by the client /// - Returns: `URL` representation of the log file name. - private static func createLogFileURL(localLogDirectoryName: String, clientDeviceID: String?, label: String) -> URL { - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + private static func createLogFileURL(localLogDirectoryName: String, clientDeviceID: String?, label: String, tempDirPath: URL) -> URL { if localLogDirectoryName.count != 0 { - return paths[0].appendingPathComponent(localLogDirectoryName).appendingPathComponent( + return tempDirPath.appendingPathComponent(localLogDirectoryName).appendingPathComponent( LocalLogFile.createLogFileName(deviceId: clientDeviceID, label: label)) } else { - return paths[0].appendingPathComponent(LocalLogFile.createLogFileName(deviceId: clientDeviceID, label: label)) + return tempDirPath.appendingPathComponent(LocalLogFile.createLogFileName(deviceId: clientDeviceID, label: label)) } } diff --git a/Sources/SwiftLogFireCloud/SwiftLogFireCloudConfig.swift b/Sources/SwiftLogFireCloud/SwiftLogFireCloudConfig.swift index 2a9e167..70060b8 100644 --- a/Sources/SwiftLogFireCloud/SwiftLogFireCloudConfig.swift +++ b/Sources/SwiftLogFireCloud/SwiftLogFireCloudConfig.swift @@ -42,7 +42,8 @@ public struct SwiftLogFireCloudConfig { /// An optional uniqueID string to identify the log file that is embedded in the log file name. /// - /// If omitted, the library will utlize the `UIDevice.current.identifierForVendor` to uniquely identify the logfile + /// If omitted, the library will utlize the `UIDevice.current.identifierForVendor`on iOS to uniquely identify the logfile. On macOS + /// if this is omitted the processInfo string is use, but its not constant across the process runs so aggregating log files is problematic. let uniqueIDString: String? /// Minimum required local file system space to start or continue logging. diff --git a/Sources/SwiftLogFireCloud/SwiftLogManager.swift b/Sources/SwiftLogFireCloud/SwiftLogManager.swift index 45c284f..c530a2e 100644 --- a/Sources/SwiftLogFireCloud/SwiftLogManager.swift +++ b/Sources/SwiftLogFireCloud/SwiftLogManager.swift @@ -78,8 +78,8 @@ internal class SwiftLogManager { } #if targetEnvironment(simulator) - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) - print("Log File location: \(paths[0].appendingPathComponent(config.logDirectoryName))") + let tempDirPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + print("Log File location: \(tempDirPath.appendingPathComponent(config.logDirectoryName))") #endif } @@ -123,12 +123,20 @@ internal class SwiftLogManager { } #endif + private func getLocalTempDirectory() -> URL { + #if os(iOS) + return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + #elseif os(macOS) + return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + #endif + } + /// Creates the local log file directory for the logger. If the directory already exists, this is essentially an expensive no-op. internal func createLocalLogDirectory() { - guard config.logDirectoryName.count > 0 else { return } - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + guard !config.logDirectoryName.isEmpty else { return } + let tempDirPath = getLocalTempDirectory() - let pathURL = paths[0].appendingPathComponent(config.logDirectoryName) + let pathURL = tempDirPath.appendingPathComponent(config.logDirectoryName) do { try FileManager.default.createDirectory( at: pathURL, withIntermediateDirectories: true, attributes: nil) @@ -141,9 +149,9 @@ internal class SwiftLogManager { /// Queries the local file system for the list of files currently in the local log directory. /// - Returns: Array of `LocalLogFile` objects representing the files on disk. internal func retrieveLocalLogFileListOnDisk() -> [LocalLogFile] { - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + let tempDirPath = getLocalTempDirectory() - let pathURL = paths[0].appendingPathComponent(self.config.logDirectoryName) + let pathURL = tempDirPath.appendingPathComponent(self.config.logDirectoryName) var localLogFilesOnDisk = [LocalLogFile]() do { let files = try FileManager.default.contentsOfDirectory( @@ -151,7 +159,7 @@ internal class SwiftLogManager { ) .filter { $0.pathExtension == "log" } for file in files { - let logFileOnDisk = LocalLogFile(label: label, config: config, queue: localLogQueue) + let logFileOnDisk = LocalLogFile(label: label, config: config, queue: localLogQueue, tempURL: getLocalTempDirectory()) logFileOnDisk.fileURL = file let attr = logFileOnDisk.getLocalLogFileAttributes() if let fileSize = attr.fileSize { @@ -305,7 +313,7 @@ internal class SwiftLogManager { } if self.localLogFile == nil { - self.localLogFile = LocalLogFile(label: self.label, config: self.config, queue: self.localLogQueue) + self.localLogFile = LocalLogFile(label: self.label, config: self.config, queue: self.localLogQueue, tempURL: self.getLocalTempDirectory()) } let logability = self.assessLocalLogability() diff --git a/Tests/SwiftLogFireCloudTests/CloudLogFileManagerTests.swift b/Tests/SwiftLogFireCloudTests/CloudLogFileManagerTests.swift index 21cedf0..9e90d90 100644 --- a/Tests/SwiftLogFireCloudTests/CloudLogFileManagerTests.swift +++ b/Tests/SwiftLogFireCloudTests/CloudLogFileManagerTests.swift @@ -23,6 +23,7 @@ class CloudLogFileManagerTests: XCTestCase { var cloudManager: CloudLogFileManager! var fakeClientCloudUploader: FakeClientCloudUploader! var localLogFile: LocalLogFile! + var testFileHelpers: TestFileSystemHelpers! override func setUpWithError() throws { fakeClientCloudUploader = FakeClientCloudUploader() @@ -36,9 +37,11 @@ class CloudLogFileManagerTests: XCTestCase { cloudUploader: fakeClientCloudUploader) cloudManager = CloudLogFileManager(label: "SwiftLogFireCloud", config: config) + testFileHelpers = TestFileSystemHelpers(config: config) localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) } override func tearDownWithError() throws { @@ -50,7 +53,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.lastWriteAttempt = Date(timeIntervalSinceNow: -31) let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud + 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssert(result) @@ -61,7 +65,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.lastWriteAttempt = Date(timeIntervalSinceNow: -31) let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud - 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssertFalse(result) @@ -72,7 +77,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.lastWriteAttempt = Date(timeIntervalSinceNow: -190) let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud + 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssert(result) @@ -83,7 +89,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.successiveFails = 5 let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud + 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssertFalse(result) @@ -94,7 +101,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.successiveFails = 12 let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud + 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssertFalse(result) @@ -105,7 +113,8 @@ class CloudLogFileManagerTests: XCTestCase { cloudManager.successiveFails = 12 let localLogFile = LocalLogFile(label: "SwiftLogFireCloud", config: config, - queue: DispatchQueue(label: "TestQueue")) + queue: DispatchQueue(label: "TestQueue"), + tempURL: testFileHelpers.tempDirPath) localLogFile.bytesWritten = config.localFileSizeThresholdToPushToCloud + 10 let result = cloudManager.isNowTheRightTimeToWriteToCloud(localLogFile) XCTAssert(result) diff --git a/Tests/SwiftLogFireCloudTests/LocalLogFileTests.swift b/Tests/SwiftLogFireCloudTests/LocalLogFileTests.swift index dd52555..4d64263 100644 --- a/Tests/SwiftLogFireCloudTests/LocalLogFileTests.swift +++ b/Tests/SwiftLogFireCloudTests/LocalLogFileTests.swift @@ -28,18 +28,18 @@ class LocalLogFileTests: XCTestCase { minFileSystemFreeSpace: 20, logDirectoryName: "TestLogs", cloudUploader: nil) - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + + var tempDirPath: URL! var testLogFile: LocalLogFile! var testFileSystemHelpers: TestFileSystemHelpers! let dummyLabel = "LocalLogFileDirectWriting" let localLogFileTestsQueue = DispatchQueue(label: "com.google.firebase.swiftlogfirecloud.locallogfiletests") override func setUpWithError() throws { - - testLogFile = LocalLogFile(label: dummyLabel, config: config, queue: localLogFileTestsQueue) - testFileSystemHelpers = TestFileSystemHelpers(path: paths[0], config: config) + testFileSystemHelpers = TestFileSystemHelpers( config: config) + tempDirPath = testFileSystemHelpers.tempDirPath + testLogFile = LocalLogFile(label: dummyLabel, config: config, queue: localLogFileTestsQueue, tempURL: tempDirPath) testFileSystemHelpers.createLocalLogDirectory() - } override func tearDownWithError() throws { @@ -84,7 +84,7 @@ class LocalLogFileTests: XCTestCase { } func testTrimImageIfNecessaryWithOverflowingBufferShouldResetBufferAndDeleteFiles() { - print("Test Log File location: \(paths)") + print("Test Log File location: \(String(describing: tempDirPath))") _ = testFileSystemHelpers.flood(localLogFile: testLogFile) _ = testFileSystemHelpers.flood(localLogFile: testLogFile) @@ -115,8 +115,8 @@ class LocalLogFileTests: XCTestCase { logDirectoryName: "TestLogs", cloudUploader: nil) - let testLogFile = LocalLogFile(label: dummyLabel, config: config, queue: localLogFileTestsQueue) - let testFileSystemHelpers = TestFileSystemHelpers(path: paths[0], config: config) + let testLogFile = LocalLogFile(label: dummyLabel, config: config, queue: localLogFileTestsQueue, tempURL: testFileSystemHelpers.tempDirPath) + let testFileSystemHelpers = TestFileSystemHelpers(config: config) testFileSystemHelpers.createLocalLogDirectory() for i in 1...15 { diff --git a/Tests/SwiftLogFireCloudTests/SwiftLogFireCloudTests.swift b/Tests/SwiftLogFireCloudTests/SwiftLogFireCloudTests.swift index a447395..1331e9d 100644 --- a/Tests/SwiftLogFireCloudTests/SwiftLogFireCloudTests.swift +++ b/Tests/SwiftLogFireCloudTests/SwiftLogFireCloudTests.swift @@ -38,7 +38,11 @@ final class SwiftLogFireCloudTests: XCTestCase { let fakeClientUploader = FakeClientCloudUploader() var config: SwiftLogFireCloudConfig! - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + #if os(iOS) + let tempDirPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + #elseif os(macOS) + let tempDirPath = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + #endif let swiftLogFileCloudManager = SwiftLogFileCloudManager() var testFileSystemHelpers: TestFileSystemHelpers! var handler: SwiftLogFireCloud! @@ -54,7 +58,7 @@ final class SwiftLogFireCloudTests: XCTestCase { handler = SwiftLogFireCloud(label: "TestSwiftLogFireCloud", config: config) swiftLogFileCloudManager.setLogToCloud(true) - testFileSystemHelpers = TestFileSystemHelpers(path: paths[0], config: config) + testFileSystemHelpers = TestFileSystemHelpers(config: config) testFileSystemHelpers.createLocalLogDirectory() } diff --git a/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift b/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift index c54ea3b..762544e 100644 --- a/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift +++ b/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift @@ -22,7 +22,7 @@ final class SwiftLogManagerTests: XCTestCase { var localSwiftLogManager: SwiftLogManager! var fakeCloudLogFileManager: FakeCloudLogFileManager? - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + var tempDirPath: URL! let config = SwiftLogFireCloudConfig( logToCloud: false, localFileSizeThresholdToPushToCloud: 100, localFileBufferWriteInterval: 60, uniqueID: "TestClientID", minFileSystemFreeSpace: 20, logDirectoryName: "TestLogs", @@ -40,7 +40,8 @@ final class SwiftLogManagerTests: XCTestCase { } localSwiftLogManager = SwiftLogManager( label: dummyLabel, config: config, cloudLogfileManager: fakeCloudLogFileManager) - testFileSystemHelpers = TestFileSystemHelpers(path: paths[0], config: config) + testFileSystemHelpers = TestFileSystemHelpers(config: config) + tempDirPath = testFileSystemHelpers.tempDirPath testFileSystemHelpers.createLocalLogDirectory() } @@ -87,7 +88,7 @@ final class SwiftLogManagerTests: XCTestCase { let localLogFileManager = SwiftLogManager( label: dummyLabel, config: config, cloudLogfileManager: fakeCloudLogFileManager) - localLogFileManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue) + localLogFileManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue, tempURL: testFileSystemHelpers.tempDirPath) guard let localFileURL = localLogFileManager.localLogFile?.fileURL else { XCTFail("No local file created") return @@ -113,9 +114,9 @@ final class SwiftLogManagerTests: XCTestCase { localSwiftLogManager.createLocalLogDirectory() - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) - XCTAssert(paths.count > 0) - var documentsDirectory = paths[0] + let tempDirPath = testFileSystemHelpers.tempDirPath + + var documentsDirectory = tempDirPath documentsDirectory.appendPathComponent(config.logDirectoryName) var isDir: ObjCBool = false @@ -142,7 +143,13 @@ final class SwiftLogManagerTests: XCTestCase { var logFileURLs = Set() for logFile in logFiles { + #if os(macOS) + // testFileSystemHelpers writes to file:///var/folders/... while the library writes to file:///private/var/folders + // which are symlinks, so must collapse here to validate files are written correctly irregardless of symlinks + logFileURLs.insert(logFile.fileURL.resolvingSymlinksInPath()) + #elseif os(iOS) logFileURLs.insert(logFile.fileURL) + #endif } XCTAssert(logFileURLs.contains(fileURL1)) @@ -201,9 +208,20 @@ final class SwiftLogManagerTests: XCTestCase { // the logger init is setup to not log to cloud, so it should just delete files. localLogFileManager.processStrandedFilesAtStartup { - XCTAssertTrue(fakeCloudLogFileManager.cloudPushQueue.contains(fileURL1)) - XCTAssertTrue(fakeCloudLogFileManager.cloudPushQueue.contains(fileURL2)) - XCTAssertTrue(fakeCloudLogFileManager.cloudPushQueue.count == 2) + + #if os(iOS) + let pushQueue = fakeCloudLogFileManager.cloudPushQueue + #elseif os(macOS) + var pushQueue: [URL] = [] + for url in fakeCloudLogFileManager.cloudPushQueue { + // testFileSystemHelpers writes to file:///var/folders/... while the library writes to file:///private/var/folders + // which are symlinks, so must collapse here to validate files are written correctly irregardless of symlinks + pushQueue.append(url.resolvingSymlinksInPath()) + } + #endif + XCTAssertTrue(pushQueue.contains(fileURL1)) + XCTAssertTrue(pushQueue.contains(fileURL2)) + XCTAssertTrue(pushQueue.count == 2) expectation.fulfill() } @@ -219,7 +237,7 @@ final class SwiftLogManagerTests: XCTestCase { let fakeCloudLogFileManager = FakeCloudLogFileManager() let localLogFileManager = SwiftLogManager( label: dummyLabel, config: config, cloudLogfileManager: fakeCloudLogFileManager) - localLogFileManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue) + localLogFileManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue, tempURL: testFileSystemHelpers.tempDirPath) let logability = localLogFileManager.assessLocalLogability() XCTAssert(logability == .impaired) @@ -241,7 +259,7 @@ final class SwiftLogManagerTests: XCTestCase { XCTFail() return } - localSwiftLogManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue) + localSwiftLogManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue, tempURL: testFileSystemHelpers.tempDirPath) localSwiftLogManager.lastFileWriteAttempt = Date() localSwiftLogManager.lastFileWrite = Date(timeInterval: -900, since: Date()) @@ -263,7 +281,7 @@ final class SwiftLogManagerTests: XCTestCase { XCTFail() return } - localSwiftLogManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue) + localSwiftLogManager.localLogFile = LocalLogFile(label: "test", config: config, queue: queue, tempURL: testFileSystemHelpers.tempDirPath) localSwiftLogManager.lastFileWriteAttempt = Date() localSwiftLogManager.successiveWriteFailures = 120 diff --git a/Tests/SwiftLogFireCloudTests/TestFileSystemHelpers.swift b/Tests/SwiftLogFireCloudTests/TestFileSystemHelpers.swift index 3b23b55..04893c2 100644 --- a/Tests/SwiftLogFireCloudTests/TestFileSystemHelpers.swift +++ b/Tests/SwiftLogFireCloudTests/TestFileSystemHelpers.swift @@ -21,11 +21,16 @@ import XCTest class TestFileSystemHelpers { - let path: URL + let tempDirPath: URL = { + #if os(iOS) + return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] + #elseif os(macOS) + return URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + #endif + }() let config: SwiftLogFireCloudConfig - init(path: URL, config: SwiftLogFireCloudConfig) { - self.path = path + init(config: SwiftLogFireCloudConfig) { self.config = config } @@ -52,7 +57,7 @@ class TestFileSystemHelpers { } internal func removeLogDirectory() { - var documentsDirectory = path + var documentsDirectory = tempDirPath documentsDirectory.appendPathComponent(config.logDirectoryName) var isDir: ObjCBool = false @@ -70,9 +75,8 @@ class TestFileSystemHelpers { internal func createLocalLogDirectory() { guard config.logDirectoryName.count > 0 else { return } - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) - let pathURL = paths[0].appendingPathComponent(config.logDirectoryName) + let pathURL = tempDirPath.appendingPathComponent(config.logDirectoryName) do { try FileManager.default.createDirectory( at: pathURL, withIntermediateDirectories: true, attributes: nil) @@ -85,7 +89,7 @@ class TestFileSystemHelpers { -> URL { let data = "I am test data for a about to be deleted file".data(using: .utf8) - let fileURL = path.appendingPathComponent(config.logDirectoryName).appendingPathComponent( + let fileURL = tempDirPath.appendingPathComponent(config.logDirectoryName).appendingPathComponent( fileName) do { @@ -98,7 +102,7 @@ class TestFileSystemHelpers { } internal func readDummyLogFile(fileName: String) -> String? { - let fileURL = path.appendingPathComponent(config.logDirectoryName).appendingPathComponent(fileName) + let fileURL = tempDirPath.appendingPathComponent(config.logDirectoryName).appendingPathComponent(fileName) return readDummyLogFile(url: fileURL) } @@ -123,7 +127,7 @@ class TestFileSystemHelpers { } internal func logFileDirectoryContents() -> [URL] { - let pathURL = path.appendingPathComponent(config.logDirectoryName) + let pathURL = tempDirPath.appendingPathComponent(config.logDirectoryName) do { let files = try FileManager.default.contentsOfDirectory( at: pathURL, includingPropertiesForKeys: nil) @@ -137,7 +141,7 @@ class TestFileSystemHelpers { internal func deleteAllLogFiles() { var isDir: ObjCBool = false - let directoryFileURL = path.appendingPathComponent(config.logDirectoryName) + let directoryFileURL = tempDirPath.appendingPathComponent(config.logDirectoryName) guard FileManager.default.fileExists(atPath: directoryFileURL.path, isDirectory: &isDir) else { return } From 6699d90393d2195c150b1962b6a66f59ce29b558 Mon Sep 17 00:00:00 2001 From: Tim Wise Date: Sun, 23 May 2021 21:28:26 -0700 Subject: [PATCH 2/3] Ensure AppKit is included for macOS clients. --- Sources/SwiftLogFireCloud/LocalLogFile.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftLogFireCloud/LocalLogFile.swift b/Sources/SwiftLogFireCloud/LocalLogFile.swift index ec65731..3de31ef 100644 --- a/Sources/SwiftLogFireCloud/LocalLogFile.swift +++ b/Sources/SwiftLogFireCloud/LocalLogFile.swift @@ -14,10 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -import Foundation #if canImport(UIKit) import UIKit #endif +#if canImport(AppKit) +import AppKit +#endif enum LocalLogFileError : Error { case distpatchIOErrorNo(Int) From d3aaae99ea0785036290bebadc6c82979c714368 Mon Sep 17 00:00:00 2001 From: Tim Wise Date: Sat, 5 Jun 2021 12:08:10 -0700 Subject: [PATCH 3/3] Revert "Merge branch 'master' into macosSupport-issue2" This reverts commit 28640572210c8252b64c4ece0af3ee621d4baa6f, reversing changes made to 6699d90393d2195c150b1962b6a66f59ce29b558. --- .../CloudLogFileManager.swift | 7 +- .../CloudLogFileManagerProtocol.swift | 2 +- .../SwiftLogFireCloud/SwiftLogManager.swift | 10 +- SwiftLogFireCloud.xcodeproj/project.pbxproj | 107 ++++++++++-------- .../contents.xcworkspacedata | 2 +- .../SwiftLogManagerTests.swift | 6 +- 6 files changed, 74 insertions(+), 60 deletions(-) diff --git a/Sources/SwiftLogFireCloud/CloudLogFileManager.swift b/Sources/SwiftLogFireCloud/CloudLogFileManager.swift index 16b7640..d8f99c8 100644 --- a/Sources/SwiftLogFireCloud/CloudLogFileManager.swift +++ b/Sources/SwiftLogFireCloud/CloudLogFileManager.swift @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import Foundation #if canImport(UIKit) import UIKit #endif @@ -56,7 +57,7 @@ class CloudLogFileManager: CloudLogFileManagerProtocol { pendingWriteMaxRetries = !config.isTesting ? 10 : 2 } - private func createCloundFilePathAndName(date: Date?) -> String { + private func createCloudFilePathAndName(date: Date?) -> String { var cloudFilePath = "\(self.config.logDirectoryName)" if cloudFilePath.count != 0 { cloudFilePath += "/" } @@ -82,9 +83,11 @@ class CloudLogFileManager: CloudLogFileManagerProtocol { if let deviceIDForFilename = config.uniqueIDString, deviceIDForFilename.count != 0 { cloudFilePath += "\(deviceIDForFilename)/" } else { + #if os(iOS) if let deviceID = UIDevice.current.identifierForVendor?.uuidString { cloudFilePath += "\(deviceID)/" } + #endif } cloudFilePath += "\(label)/" @@ -157,7 +160,7 @@ class CloudLogFileManager: CloudLogFileManagerProtocol { completion?() return } - let cloudFilePath = self.createCloundFilePathAndName(date: fileAttr.creationDate) + let cloudFilePath = self.createCloudFilePathAndName(date: fileAttr.creationDate) cloudUploader.uploadFile(from: localLogFile, to: cloudFilePath) { result in switch result { case .success(let logFile): diff --git a/Sources/SwiftLogFireCloud/CloudLogFileManagerProtocol.swift b/Sources/SwiftLogFireCloud/CloudLogFileManagerProtocol.swift index 1c1f5d2..ccc10e0 100644 --- a/Sources/SwiftLogFireCloud/CloudLogFileManagerProtocol.swift +++ b/Sources/SwiftLogFireCloud/CloudLogFileManagerProtocol.swift @@ -30,7 +30,7 @@ public enum CloudUploadError : Error { } /// Protocol the client object must conform to which has the Firebase Storage references and requests the upload and reports back status. -public protocol CloudFileUploaderProtocol: class { +public protocol CloudFileUploaderProtocol: AnyObject { func uploadFile(from localFile: LocalLogFile, to cloudPath: String, completion: @escaping (Result)->Void) } diff --git a/Sources/SwiftLogFireCloud/SwiftLogManager.swift b/Sources/SwiftLogFireCloud/SwiftLogManager.swift index 4a5b8c3..c530a2e 100644 --- a/Sources/SwiftLogFireCloud/SwiftLogManager.swift +++ b/Sources/SwiftLogFireCloud/SwiftLogManager.swift @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import Foundation #if canImport(UIKit) import UIKit #endif @@ -36,7 +37,10 @@ internal class SwiftLogManager { internal var successiveWriteFailures: Int = 0 private let strandedFilesDelay: TimeInterval private var impairedMessages: Data? + + #if os(iOS) private var backgroundTaskID = UIBackgroundTaskIdentifier.invalid + #endif private func startWriteTimer(interval: TimeInterval) -> Timer { return Timer.scheduledTimer( @@ -59,7 +63,7 @@ internal class SwiftLogManager { self.strandedFilesDelay = !config.isTesting ? 15 : 5 writeTimer = startWriteTimer(interval: config.localFileBufferWriteInterval) - + #if os(iOS) let notificationCenter = NotificationCenter.default notificationCenter.addObserver( self, selector: #selector(appWillResignActive), @@ -67,7 +71,7 @@ internal class SwiftLogManager { notificationCenter.addObserver( self, selector: #selector(appWillResumeActive), name: UIApplication.willEnterForegroundNotification, object: nil) - + #endif //wait 15s after startup, then attempt to push any files from previous runs up to cloud DispatchQueue.main.asyncAfter(deadline: .now() + strandedFilesDelay) { self.processStrandedFilesAtStartup() @@ -84,6 +88,7 @@ internal class SwiftLogManager { writeTimer = startWriteTimer(interval: config.localFileBufferWriteInterval) } } + #if os(iOS) @objc internal func appWillResignActive(_ application: UIApplication) { //}, _ completionForTesting: (() -> Void)? = nil) { let backgroundEntitlementStatus = UIApplication.shared.backgroundRefreshStatus switch backgroundEntitlementStatus { @@ -116,6 +121,7 @@ internal class SwiftLogManager { self.writeTimer?.invalidate() } + #endif private func getLocalTempDirectory() -> URL { #if os(iOS) diff --git a/SwiftLogFireCloud.xcodeproj/project.pbxproj b/SwiftLogFireCloud.xcodeproj/project.pbxproj index 0bcb529..3c86b9d 100644 --- a/SwiftLogFireCloud.xcodeproj/project.pbxproj +++ b/SwiftLogFireCloud.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 52; objects = { /* Begin PBXAggregateTarget section */ @@ -23,9 +23,7 @@ /* Begin PBXBuildFile section */ F65EF3BC24C2554000BBE5A8 /* CloudLogFileManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65EF3BB24C2554000BBE5A8 /* CloudLogFileManagerTests.swift */; }; F65EF3BE24C2CCA400BBE5A8 /* FakeClientCloudUploader.swift in Sources */ = {isa = PBXBuildFile; fileRef = F65EF3BD24C2CCA400BBE5A8 /* FakeClientCloudUploader.swift */; }; - OBJ_41 /* Locks.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_26 /* Locks.swift */; }; - OBJ_42 /* LogHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_27 /* LogHandler.swift */; }; - OBJ_43 /* Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_28 /* Logging.swift */; }; + F6A29CEC2643B09700B9E5E1 /* Logging in Frameworks */ = {isa = PBXBuildFile; productRef = F6A29CEB2643B09700B9E5E1 /* Logging */; }; OBJ_50 /* CloudLogFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* CloudLogFileManager.swift */; }; OBJ_51 /* CloudLogFileManagerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* CloudLogFileManagerProtocol.swift */; }; OBJ_52 /* LocalLogFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* LocalLogFile.swift */; }; @@ -42,7 +40,6 @@ OBJ_80 /* XCTestManifests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_22 /* XCTestManifests.swift */; }; OBJ_82 /* SwiftLogFireCloud.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "SwiftLogFireCloud::SwiftLogFireCloud::Product" /* SwiftLogFireCloud.framework */; }; OBJ_83 /* Logging.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "swift-log::Logging::Product" /* Logging.framework */; }; - OBJ_91 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_29 /* Package.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -90,16 +87,12 @@ OBJ_20 /* SwiftLogFireCloudTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftLogFireCloudTests.swift; sourceTree = ""; }; OBJ_21 /* TestFileSystemHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestFileSystemHelpers.swift; sourceTree = ""; }; OBJ_22 /* XCTestManifests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestManifests.swift; sourceTree = ""; }; - OBJ_26 /* Locks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Locks.swift; sourceTree = ""; }; - OBJ_27 /* LogHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogHandler.swift; sourceTree = ""; }; - OBJ_28 /* Logging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logging.swift; sourceTree = ""; }; - OBJ_29 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; name = Package.swift; path = "/Users/timothywise/development/SwiftLogFireCloud/.build/checkouts/swift-log/Package.swift"; sourceTree = ""; }; OBJ_34 /* SwiftLogFireCloudExampleApp */ = {isa = PBXFileReference; lastKnownFileType = folder; path = SwiftLogFireCloudExampleApp; sourceTree = SOURCE_ROOT; }; OBJ_35 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; OBJ_9 /* CloudLogFileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudLogFileManager.swift; sourceTree = ""; }; "SwiftLogFireCloud::SwiftLogFireCloud::Product" /* SwiftLogFireCloud.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftLogFireCloud.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - "SwiftLogFireCloud::SwiftLogFireCloudTests::Product" /* SwiftLogFireCloudTests.xctest */ = {isa = PBXFileReference; lastKnownFileType = file; path = SwiftLogFireCloudTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + "SwiftLogFireCloud::SwiftLogFireCloudTests::Product" /* SwiftLogFireCloudTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = SwiftLogFireCloudTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; "swift-log::Logging::Product" /* Logging.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Logging.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -108,6 +101,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( + F6A29CEC2643B09700B9E5E1 /* Logging in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -155,34 +149,6 @@ path = Tests/SwiftLogFireCloudTests; sourceTree = SOURCE_ROOT; }; - OBJ_23 /* Dependencies */ = { - isa = PBXGroup; - children = ( - OBJ_24 /* swift-log 1.2.0 */, - ); - name = Dependencies; - sourceTree = ""; - }; - OBJ_24 /* swift-log 1.2.0 */ = { - isa = PBXGroup; - children = ( - OBJ_25 /* Logging */, - OBJ_29 /* Package.swift */, - ); - name = "swift-log 1.2.0"; - sourceTree = SOURCE_ROOT; - }; - OBJ_25 /* Logging */ = { - isa = PBXGroup; - children = ( - OBJ_26 /* Locks.swift */, - OBJ_27 /* LogHandler.swift */, - OBJ_28 /* Logging.swift */, - ); - name = Logging; - path = ".build/checkouts/swift-log/Sources/Logging"; - sourceTree = SOURCE_ROOT; - }; OBJ_30 /* Products */ = { isa = PBXGroup; children = ( @@ -199,7 +165,6 @@ OBJ_6 /* Package.swift */, OBJ_7 /* Sources */, OBJ_15 /* Tests */, - OBJ_23 /* Dependencies */, OBJ_30 /* Products */, OBJ_34 /* SwiftLogFireCloudExampleApp */, OBJ_35 /* README.md */, @@ -292,6 +257,9 @@ dependencies = ( ); name = Logging; + packageProductDependencies = ( + F6A29CEB2643B09700B9E5E1 /* Logging */, + ); productName = Logging; productReference = "swift-log::Logging::Product" /* Logging.framework */; productType = "com.apple.product-type.framework"; @@ -327,6 +295,9 @@ en, ); mainGroup = OBJ_5; + packageReferences = ( + F6A29CEA2643B09700B9E5E1 /* XCRemoteSwiftPackageReference "swift-log" */, + ); productRefGroup = OBJ_30 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -346,9 +317,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 0; files = ( - OBJ_41 /* Locks.swift in Sources */, - OBJ_42 /* LogHandler.swift in Sources */, - OBJ_43 /* Logging.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -392,7 +360,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 0; files = ( - OBJ_91 /* Package.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -460,7 +427,10 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/Logging_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -488,7 +458,10 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/Logging_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -524,7 +497,8 @@ SDKROOT = macosx; SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE"; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; USE_HEADERMAP = NO; }; name = Release; @@ -540,7 +514,10 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/SwiftLogFireCloud_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -568,7 +545,10 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/SwiftLogFireCloud_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) $(TOOLCHAIN_DIR)/usr/lib/swift/macosx"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -627,7 +607,11 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/SwiftLogFireCloudTests_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@loader_path/../Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -652,7 +636,11 @@ HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = SwiftLogFireCloud.xcodeproj/SwiftLogFireCloudTests_Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/../Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@loader_path/../Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -750,6 +738,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + F6A29CEA2643B09700B9E5E1 /* XCRemoteSwiftPackageReference "swift-log" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-log.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.2.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + F6A29CEB2643B09700B9E5E1 /* Logging */ = { + isa = XCSwiftPackageProductDependency; + package = F6A29CEA2643B09700B9E5E1 /* XCRemoteSwiftPackageReference "swift-log" */; + productName = Logging; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = OBJ_1 /* Project object */; } diff --git a/SwiftLogFireCloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SwiftLogFireCloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata index fe1aa71..919434a 100644 --- a/SwiftLogFireCloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/SwiftLogFireCloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,4 @@ - \ No newline at end of file + diff --git a/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift b/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift index 0853b0f..762544e 100644 --- a/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift +++ b/Tests/SwiftLogFireCloudTests/SwiftLogManagerTests.swift @@ -77,6 +77,7 @@ final class SwiftLogManagerTests: XCTestCase { XCTAssertTrue(localSwiftLogManager.writeTimer?.isValid ?? false) } + #if os(iOS) func testAppWillResignActiveShouldWriteFileToCloudAndStopTimer() { let config = SwiftLogFireCloudConfig( @@ -105,6 +106,7 @@ final class SwiftLogManagerTests: XCTestCase { XCTAssert(fakeCloudLogFileManager.recentWrittenFiles.contains(localFileURL)) XCTAssertFalse(localLogFileManager.writeTimer?.isValid ?? false) } + #endif func testCreateLocalLogDirectorySuccessful() { //Setup creates the directory, remove it first @@ -412,10 +414,6 @@ final class SwiftLogManagerTests: XCTestCase { "testAppWillResumeActiveWhenTimerActiveShouldStillHaveActiveTimer", testAppWillResumeActiveWhenTimerActiveShouldStillHaveActiveTimer ), - ( - "testAppWillResignActiveShouldWriteFileToCloudAndStopTimer", - testAppWillResignActiveShouldWriteFileToCloudAndStopTimer - ), ( "testAssessLocalLogabilityWhenDiskSpaceInsufficientShouldBeImpaired", testAssessLocalLogabilityWhenDiskSpaceInsufficientShouldBeImpaired