diff --git a/.swiftlint.yml b/.swiftlint.yml index 6049cd86..b529f2a2 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,5 +1,7 @@ excluded: - Demo/Demo Ubuntu/.build + - .build + - build type_name: min_length: 4 diff --git a/Demo/Demo watchOS/ContentView.swift b/Demo/Demo watchOS/ContentView.swift index 3aa494b9..16ef8c8e 100644 --- a/Demo/Demo watchOS/ContentView.swift +++ b/Demo/Demo watchOS/ContentView.swift @@ -10,23 +10,26 @@ import SwiftUI import ID3TagEditor struct ContentView: View { - @State private var tag: ID3Tag? = nil - + @State private var tag: ID3Tag? + var body: some View { VStack { if let validTag = tag { - Image(uiImage: UIImage(data: (validTag.frames[.attachedPicture(.frontCover)] as! ID3FrameAttachedPicture).picture)!) - .resizable() - .frame(width: 50, height: 50) - Text((validTag.frames[.title] as! ID3FrameWithStringContent).content) - Text((validTag.frames[.album] as! ID3FrameWithStringContent).content) - Text((validTag.frames[.genre] as! ID3FrameGenre).description!) + if let data = (validTag.frames[.attachedPicture(.frontCover)] as? ID3FrameAttachedPicture)?.picture, + let validImage = UIImage(data: data) { + Image(uiImage: validImage) + .resizable() + .frame(width: 50, height: 50) + } + Text((validTag.frames[.title] as? ID3FrameWithStringContent)?.content ?? "") + Text((validTag.frames[.album] as? ID3FrameWithStringContent)?.content ?? "") + Text((validTag.frames[.genre] as? ID3FrameGenre)?.description ?? "") } } .padding() .onAppear { let id3TagEditor = ID3TagEditor() - tag = try! id3TagEditor.read(from: PathLoader().pathFor(name: "example", fileType: "mp3")) + tag = try? id3TagEditor.read(from: PathLoader().pathFor(name: "example", fileType: "mp3")) } } } diff --git a/Demo/Demo watchOS/Demo_watchOSApp.swift b/Demo/Demo watchOS/DemoWatchOSApp.swift similarity index 61% rename from Demo/Demo watchOS/Demo_watchOSApp.swift rename to Demo/Demo watchOS/DemoWatchOSApp.swift index 5430c615..a30f5aef 100644 --- a/Demo/Demo watchOS/Demo_watchOSApp.swift +++ b/Demo/Demo watchOS/DemoWatchOSApp.swift @@ -1,15 +1,15 @@ // -// Demo_watchOSApp.swift +// DemoWatchOSApp.swift // Demo watchOS Watch App // // Created by Fabrizio Duroni on 11.10.2024. -// Copyright © 2024 Fabrizio Duroni. All rights reserved. +// 2024 Fabrizio Duroni. // import SwiftUI @main -struct Demo_watchOS_Watch_AppApp: App { +struct DemoWatchOSApp: App { var body: some Scene { WindowGroup { ContentView() diff --git a/Scripts/swiftlint.sh b/Scripts/swiftlint.sh index 71bde7f6..30e50196 100755 --- a/Scripts/swiftlint.sh +++ b/Scripts/swiftlint.sh @@ -6,7 +6,7 @@ fi # Type a script or drag a script file from your workspace to insert its path. if which swiftlint >/dev/null; then - swiftlint + swiftlint lint --config .swiftlint.yml else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi diff --git a/Source/Create/ID3FrameCreatorsFactory.swift b/Source/Create/ID3FrameCreatorsFactory.swift index c934cd13..0edc1746 100644 --- a/Source/Create/ID3FrameCreatorsFactory.swift +++ b/Source/Create/ID3FrameCreatorsFactory.swift @@ -47,3 +47,5 @@ class ID3FrameCreatorsFactory { + ID3iTunesFrameCreatorsFactory.make() } } + +// swiftlint:enable line_length diff --git a/Source/Create/ID3RecordingTimesFrameCreatorsFactory.swift b/Source/Create/ID3RecordingTimesFrameCreatorsFactory.swift index 26f74dbd..0cbdb8d0 100644 --- a/Source/Create/ID3RecordingTimesFrameCreatorsFactory.swift +++ b/Source/Create/ID3RecordingTimesFrameCreatorsFactory.swift @@ -25,3 +25,5 @@ class ID3RecordingTimesFrameCreatorsFactory { ] } } + +// swiftlint:enable line_length diff --git a/Source/Create/ID3iTunesFrameCreatorsFactory.swift b/Source/Create/ID3iTunesFrameCreatorsFactory.swift index be1f8582..10021548 100644 --- a/Source/Create/ID3iTunesFrameCreatorsFactory.swift +++ b/Source/Create/ID3iTunesFrameCreatorsFactory.swift @@ -28,3 +28,5 @@ class ID3iTunesFrameCreatorsFactory { ] } } + +// swiftlint:enable line_length diff --git a/Source/Frame/FrameName.swift b/Source/Frame/FrameName.swift index 71f61ca4..29a77ea7 100644 --- a/Source/Frame/FrameName.swift +++ b/Source/Frame/FrameName.swift @@ -15,7 +15,7 @@ struct FrameNamesWithLocalizedContent { FrameType.comment: enumerateLocalizedFrameName(frameName: FrameName.comment) ] } - + private func enumerateLocalizedFrameName(frameName: (ID3FrameContentLanguage) -> FrameName) -> [FrameName] { return ID3FrameContentLanguage.allCases.map({ frameName($0) }) } diff --git a/Source/Frame/ID3FrameContentLanguage.swift b/Source/Frame/ID3FrameContentLanguage.swift index 4844b071..5fe0838b 100644 --- a/Source/Frame/ID3FrameContentLanguage.swift +++ b/Source/Frame/ID3FrameContentLanguage.swift @@ -1036,3 +1036,6 @@ public enum ID3FrameContentLanguage: String, Equatable, Hashable, CaseIterable { /// Invalid/Unknown language. case unknown } + +// swiftlint:enable type_body_length +// swiftlint:enable file_length diff --git a/Source/Parse/ID3FrameContentParsingOperationFactory.swift b/Source/Parse/ID3FrameContentParsingOperationFactory.swift index 52a36783..c960c314 100644 --- a/Source/Parse/ID3FrameContentParsingOperationFactory.swift +++ b/Source/Parse/ID3FrameContentParsingOperationFactory.swift @@ -52,3 +52,5 @@ class ID3FrameContentParsingOperationFactory { ] } } + +// swiftlint:enable line_length diff --git a/Source/Parse/ID3FrameStringContentParser.swift b/Source/Parse/ID3FrameStringContentParser.swift index 739670d2..625cdc46 100644 --- a/Source/Parse/ID3FrameStringContentParser.swift +++ b/Source/Parse/ID3FrameStringContentParser.swift @@ -30,7 +30,7 @@ class ID3FrameStringContentParser { let frameContent = frame.subdata(in: frameContentRangeStart..