Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions IONFileViewerLib/IONFLVWManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading