Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private func sharedFolderURL() -> URL {
- if let simulatorSharedDir = ProcessInfo().environment["SIMULATOR_SHARED_RESOURCES_DIRECTORY"] {
- // running on the simulator. We'll write to ~/Library/Caches
- let simulatorHomeDirURL = URL(fileURLWithPath: simulatorSharedDir)
- let cachesDirURL = simulatorHomeDirURL.appendingPathComponent("Library/Caches")
- XCTAssertTrue(FileManager.default.isWritableFile(atPath: cachesDirURL.path), "Cannot write to simulator Caches directory")
- let sharedFolderURL = cachesDirURL.appendingPathComponent("Secrets")
- XCTAssertNoThrow( try FileManager.default.createDirectory(at: sharedFolderURL, withIntermediateDirectories: true, attributes: nil), "Failed to create shared folder \(sharedFolderURL.lastPathComponent) in simulator Caches directory at \(cachesDirURL)")
- return sharedFolderURL
- }
- else {
- // running on the device. We'll write to the AppGroup folder
- guard let appGroupURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: AppGroupName) else {
- XCTFail("Failed to get URL for app group \(AppGroupName). Check your entitlements.")
- fatalError()
- }
- return appGroupURL
- }
- }
Add Comment
Please, Sign In to add comment