From 7534e33f272372f89ebb0b28eccc0d5fd8277267 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Sat, 11 Nov 2023 22:11:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Using=20Xcode=20generated=20asse?= =?UTF-8?q?ts=20instead=20of=20SwiftGen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iOSSampleApp.xcodeproj/project.pbxproj | 8 +- .../xcschemes/iOSSampleApp.xcscheme | 2 +- Sources/iOSSampleApp/Resources/Assets.swift | 126 ------------------ .../ViewControllers/AboutViewController.swift | 2 +- .../DetailViewController.swift | 4 +- .../ViewControllers/FeedViewController.swift | 4 +- Sources/swiftgen.yml | 8 +- 7 files changed, 10 insertions(+), 144 deletions(-) delete mode 100644 Sources/iOSSampleApp/Resources/Assets.swift diff --git a/Sources/iOSSampleApp.xcodeproj/project.pbxproj b/Sources/iOSSampleApp.xcodeproj/project.pbxproj index e0115e2..2d7650f 100644 --- a/Sources/iOSSampleApp.xcodeproj/project.pbxproj +++ b/Sources/iOSSampleApp.xcodeproj/project.pbxproj @@ -74,7 +74,6 @@ F3C5F35C2961E45000257080 /* AboutCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C5F35B2961E45000257080 /* AboutCell.swift */; }; F3C5F35E2961EADD00257080 /* UIEdgeInsets+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C5F35D2961EADD00257080 /* UIEdgeInsets+Extensions.swift */; }; F3C5F3632962C56300257080 /* FormFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C5F3622962C56300257080 /* FormFieldView.swift */; }; - F3C5F3652962CE6B00257080 /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C5F3642962CE6B00257080 /* Assets.swift */; }; F3C7CFDD2423AF4C003A961E /* URL+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C7CFDC2423AF4C003A961E /* URL+Extensions.swift */; }; F3C8DB3B214EA1B700C1A654 /* DataServiceMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C8DB3A214EA1B700C1A654 /* DataServiceMock.swift */; }; F3C8DB3D214EA1E700C1A654 /* SettingsServiceMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3C8DB3C214EA1E700C1A654 /* SettingsServiceMock.swift */; }; @@ -166,7 +165,6 @@ F3C5F35B2961E45000257080 /* AboutCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutCell.swift; sourceTree = ""; }; F3C5F35D2961EADD00257080 /* UIEdgeInsets+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIEdgeInsets+Extensions.swift"; sourceTree = ""; }; F3C5F3622962C56300257080 /* FormFieldView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldView.swift; sourceTree = ""; }; - F3C5F3642962CE6B00257080 /* Assets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = ""; }; F3C7CFDC2423AF4C003A961E /* URL+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extensions.swift"; sourceTree = ""; }; F3C8DB3A214EA1B700C1A654 /* DataServiceMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataServiceMock.swift; sourceTree = ""; }; F3C8DB3C214EA1E700C1A654 /* SettingsServiceMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsServiceMock.swift; sourceTree = ""; }; @@ -560,7 +558,6 @@ F3A813141F837EDD00A09AAB /* Resources */ = { isa = PBXGroup; children = ( - F3C5F3642962CE6B00257080 /* Assets.swift */, F3520E73206017000011EF40 /* Strings.swift */, F3D9328221628CF900EA1E91 /* sk */, F3D9328121628CF000EA1E91 /* en */, @@ -702,7 +699,7 @@ attributes = { BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1500; ORGANIZATIONNAME = "Igor Kulman"; TargetAttributes = { F3208A791F84E48100B57B0E = { @@ -867,7 +864,6 @@ F3A4B21F1FC4359A00787BCE /* AboutCoordinator.swift in Sources */, F3651D26203C1B3A0082A73A /* SettingsService.swift in Sources */, F3A812FE1F83791C00A09AAB /* UserDefaultsSettingsService.swift in Sources */, - F3C5F3652962CE6B00257080 /* Assets.swift in Sources */, F3A812B81F83740E00A09AAB /* AppDelegate.swift in Sources */, F38CD2371F83AEC70050056C /* UIScrollView+Extensions.swift in Sources */, F3651D22203C1B0D0082A73A /* DataService.swift in Sources */, @@ -1030,6 +1026,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -1091,6 +1088,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; diff --git a/Sources/iOSSampleApp.xcodeproj/xcshareddata/xcschemes/iOSSampleApp.xcscheme b/Sources/iOSSampleApp.xcodeproj/xcshareddata/xcschemes/iOSSampleApp.xcscheme index d68ff74..ae2b7be 100644 --- a/Sources/iOSSampleApp.xcodeproj/xcshareddata/xcschemes/iOSSampleApp.xcscheme +++ b/Sources/iOSSampleApp.xcodeproj/xcshareddata/xcschemes/iOSSampleApp.xcscheme @@ -1,6 +1,6 @@ Image { - let bundle = BundleToken.bundle - guard let result = Image(named: name, in: bundle, compatibleWith: traitCollection) else { - fatalError("Unable to load image asset named \(name).") - } - return result - } - #endif - - #if canImport(SwiftUI) - @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) - internal var swiftUIImage: SwiftUI.Image { - SwiftUI.Image(asset: self) - } - #endif -} - -internal extension ImageAsset.Image { - @available(iOS 8.0, tvOS 9.0, watchOS 2.0, *) - @available(macOS, deprecated, - message: "This initializer is unsafe on macOS, please use the ImageAsset.image property") - convenience init?(asset: ImageAsset) { - #if os(iOS) || os(tvOS) - let bundle = BundleToken.bundle - self.init(named: asset.name, in: bundle, compatibleWith: nil) - #elseif os(macOS) - self.init(named: NSImage.Name(asset.name)) - #elseif os(watchOS) - self.init(named: asset.name) - #endif - } -} - -#if canImport(SwiftUI) -@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) -internal extension SwiftUI.Image { - init(asset: ImageAsset) { - let bundle = BundleToken.bundle - self.init(asset.name, bundle: bundle) - } - - init(asset: ImageAsset, label: Text) { - let bundle = BundleToken.bundle - self.init(asset.name, bundle: bundle, label: label) - } - - init(decorative asset: ImageAsset) { - let bundle = BundleToken.bundle - self.init(decorative: asset.name, bundle: bundle) - } -} -#endif - -// swiftlint:disable convenience_type -private final class BundleToken { - static let bundle: Bundle = { - #if SWIFT_PACKAGE - return Bundle.module - #else - return Bundle(for: BundleToken.self) - #endif - }() -} -// swiftlint:enable convenience_type diff --git a/Sources/iOSSampleApp/Scenarios/About/ViewControllers/AboutViewController.swift b/Sources/iOSSampleApp/Scenarios/About/ViewControllers/AboutViewController.swift index d58df02..1d66478 100644 --- a/Sources/iOSSampleApp/Scenarios/About/ViewControllers/AboutViewController.swift +++ b/Sources/iOSSampleApp/Scenarios/About/ViewControllers/AboutViewController.swift @@ -43,7 +43,7 @@ final class AboutViewController: UITableViewController { } private lazy var logoImageView: UIImageView = .init() &> { - $0.image = Asset.logo.image + $0.image = .logo $0.contentMode = .scaleAspectFit $0.fixSize(width: 48, height: 48) } diff --git a/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/DetailViewController.swift b/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/DetailViewController.swift index 8400238..63e82db 100644 --- a/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/DetailViewController.swift +++ b/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/DetailViewController.swift @@ -23,12 +23,12 @@ final class DetailViewController: UIViewController { // MARK: - UI private lazy var backBarButtonItem: UIBarButtonItem = .init() &> { - $0.image = Asset.back.image + $0.image = .back $0.style = .plain } private lazy var forwardBarButtonItem: UIBarButtonItem = .init() &> { - $0.image = Asset.forward.image + $0.image = .forward $0.style = .plain } diff --git a/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/FeedViewController.swift b/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/FeedViewController.swift index dddb2f4..e688bb2 100644 --- a/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/FeedViewController.swift +++ b/Sources/iOSSampleApp/Scenarios/Feed/ViewControllers/FeedViewController.swift @@ -44,12 +44,12 @@ final class FeedViewController: UIViewController, ToastCapable { } private lazy var setupButton: UIBarButtonItem = .init() &> { - $0.image = Asset.settings.image + $0.image = .settings $0.style = .plain } private lazy var aboutButton: UIBarButtonItem = .init() &> { - $0.image = Asset.about.image + $0.image = .about $0.style = .plain $0.accessibilityIdentifier = "about" } diff --git a/Sources/swiftgen.yml b/Sources/swiftgen.yml index 1d8bbda..d2839ec 100644 --- a/Sources/swiftgen.yml +++ b/Sources/swiftgen.yml @@ -2,10 +2,4 @@ strings: inputs: iOSSampleApp/Resources/Base.lproj/Localizable.strings outputs: - templateName: structured-swift4 - output: iOSSampleApp/Resources/Strings.swift - -xcassets: - inputs: iOSSampleApp/Assets.xcassets - outputs: - templateName: swift5 - output: iOSSampleApp/Resources/Assets.swift \ No newline at end of file + output: iOSSampleApp/Resources/Strings.swift \ No newline at end of file