diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 3e935af..e190457 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -19,7 +19,7 @@ jobs: run: brew link --overwrite swiftlint || brew install swiftlint - name: Set up XCode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + run: sudo xcode-select --switch /Applications/Xcode_26.0.app - name: Bundle Install run: bundle install diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml index 7dcb0c4..a081e3e 100644 --- a/.github/workflows/prepare_release.yml +++ b/.github/workflows/prepare_release.yml @@ -25,7 +25,7 @@ jobs: run: brew link --overwrite swiftlint || brew install swiftlint - name: Set up XCode - run: sudo xcode-select --switch /Applications/Xcode_15.0.app + run: sudo xcode-select --switch /Applications/Xcode_26.0.app - name: Set up Ruby uses: ruby/setup-ruby@v1 diff --git a/IONFileViewerLib/IONFLVWManager.swift b/IONFileViewerLib/IONFLVWManager.swift index 00f0ff7..bd8adf9 100644 --- a/IONFileViewerLib/IONFLVWManager.swift +++ b/IONFileViewerLib/IONFLVWManager.swift @@ -13,13 +13,7 @@ public class IONFLVWManager { extension IONFLVWManager: IONFLVWOpenDocumentManager { public func openDocumentFromLocalPath(filePath: String, completion: @escaping (() -> Void)) throws { - guard !filePath.isEmpty else { - throw IONFLVWError.emptyFilePath - } - let filePathToUse = replaceDuplicateSlashes(fromLocalPath: filePath) - guard let file = URL(string: filePathToUse) else { throw IONFLVWError.couldNotOpenDocument } - guard !file.pathExtension.isEmpty else { throw IONFLVWError.missingFileExtension } - guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePathToUse) } + let file = try prepareLocalFile(atPath: filePath) openDocumentFromLocalPath(file, completion) } @@ -59,10 +53,7 @@ extension IONFLVWManager: IONFLVWOpenDocumentManager { extension IONFLVWManager: IONFLVWPreviewMediaManager { public func previewMediaContentFromLocalPath(filePath: String) throws { - guard !filePath.isEmpty else { throw IONFLVWError.emptyFilePath } - let filePathToUse = replaceDuplicateSlashes(fromLocalPath: filePath) - guard let file = URL(string: filePathToUse) else { throw IONFLVWError.couldNotOpenDocument } - guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePathToUse) } + let file = try prepareLocalFile(atPath: filePath) previewMediaContent(file) } @@ -107,6 +98,17 @@ private extension IONFLVWManager { return resourceURL } + func prepareLocalFile(atPath filePath: String) throws -> URL { + guard !filePath.isEmpty else { throw IONFLVWError.emptyFilePath } + var filePathToUse = replaceDuplicateSlashes(fromLocalPath: filePath) + // add file:// if it doesn't exist - the document / media opening fails if the local file is not a "file://" URI. + filePathToUse = filePathToUse.hasPrefix("file://") ? filePathToUse : "file://\(filePathToUse)" + guard let file = URL(string: filePathToUse) else { throw IONFLVWError.couldNotOpenDocument } + guard !file.pathExtension.isEmpty else { throw IONFLVWError.missingFileExtension } + guard fileManager.fileExists(atPath: file.path) else { throw IONFLVWError.fileDoesNotExist(atPath: filePathToUse) } + return file + } + func replaceDuplicateSlashes(fromLocalPath path: String) -> String { // remove duplicate slashes '//', except for the ones indicating the scheme (e.g. 'file://') var pathWithoutDuplicateSeparators = path.replacingOccurrences( diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 473e9f5..daa3726 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -18,7 +18,10 @@ default_platform(:ios) platform :ios do desc "Lane to run the unit tests" lane :unit_tests do - run_tests(scheme: "IONFileViewerLib") + run_tests( + scheme: "IONFileViewerLib", + destination: "platform=iOS Simulator,name=iPhone 17,OS=26.0" + ) end desc "Code coverage"