From 2412c97e6a24bdc3093c31569ffd4aa0a0d37903 Mon Sep 17 00:00:00 2001 From: nmotod Date: Mon, 25 Sep 2023 13:20:11 +0900 Subject: [PATCH] fix(build): fix SwiftGenPlugin error on Xcode 15 @see https://github.com/SwiftGen/SwiftGenPlugin/issues/14#issuecomment-1727696732 --- Modules/Sources/Theme/Asset-Generated.swift | 206 -------------------- Modules/Sources/Theme/swiftgen.yml | 2 + 2 files changed, 2 insertions(+), 206 deletions(-) delete mode 100644 Modules/Sources/Theme/Asset-Generated.swift diff --git a/Modules/Sources/Theme/Asset-Generated.swift b/Modules/Sources/Theme/Asset-Generated.swift deleted file mode 100644 index d655e7e..0000000 --- a/Modules/Sources/Theme/Asset-Generated.swift +++ /dev/null @@ -1,206 +0,0 @@ -// swiftlint:disable all -// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen - -#if os(macOS) - import AppKit -#elseif os(iOS) - import UIKit -#elseif os(tvOS) || os(watchOS) - import UIKit -#endif -#if canImport(SwiftUI) - import SwiftUI -#endif - -// Deprecated typealiases -@available(*, deprecated, renamed: "ColorAsset.Color", message: "This typealias will be removed in SwiftGen 7.0") -public typealias AssetColorTypeAlias = ColorAsset.Color -@available(*, deprecated, renamed: "ImageAsset.Image", message: "This typealias will be removed in SwiftGen 7.0") -public typealias AssetImageTypeAlias = ImageAsset.Image - -// swiftlint:disable superfluous_disable_command file_length implicit_return - -// MARK: - Asset Catalogs - -// swiftlint:disable identifier_name line_length nesting type_body_length type_name -public enum Asset { - public enum Colors { - public static let addressBarLabelBackgroundHighlighted = ColorAsset(name: "addressBarLabel.background.highlighted") - public static let addressBarLabelBackgroundNormal = ColorAsset(name: "addressBarLabel.background.normal") - public static let addressBarLabelPlaceholder = ColorAsset(name: "addressBarLabel.placeholder") - public static let addressBarLabelTextNormal = ColorAsset(name: "addressBarLabel.text.normal") - public static let barBackground = ColorAsset(name: "bar.background") - public static let barTint = ColorAsset(name: "barTint") - public static let background = ColorAsset(name: "background") - public static let backgroundDark = ColorAsset(name: "backgroundDark") - public static let formFieldBackground = ColorAsset(name: "formFieldBackground") - public static let formFieldBackgroundFocused = ColorAsset(name: "formFieldBackground.focused") - public static let tableSeparator = ColorAsset(name: "tableSeparator") - public static let textNormal = ColorAsset(name: "text.normal") - public static let tint = ColorAsset(name: "tint") - public static let tintActive = ColorAsset(name: "tintActive") - public static let homeText = ColorAsset(name: "home.text") - public static let progressBarIndicator = ColorAsset(name: "progressBar.indicator") - public static let tabCollectionActiveIndicatorTint = ColorAsset(name: "tabCollection.activeIndicator.tint") - public static let tabGroupBarBackgroundActive = ColorAsset(name: "tabGroupBar.background.active") - public static let tabGroupBarBackgroundNormal = ColorAsset(name: "tabGroupBar.background.normal") - public static let tabGroupBarTextActive = ColorAsset(name: "tabGroupBar.text.active") - public static let tabGroupBarTextNormal = ColorAsset(name: "tabGroupBar.text.normal") - public static let tabGroupBarTopBorder = ColorAsset(name: "tabGroupBar.topBorder") - public static let tabGroupViewTitleBackgroundActive = ColorAsset(name: "tabGroupView.titleBackground.active") - public static let tabGroupViewTitleBackgroundNormal = ColorAsset(name: "tabGroupView.titleBackground.normal") - public static let tabListCellBackgroundHighlighted = ColorAsset(name: "tabListCell.background.highlighted") - public static let tabListCellBackgroundNormal = ColorAsset(name: "tabListCell.background.normal") - } - public enum Images { - public static let blade = ImageAsset(name: "Blade") - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length type_name - -// MARK: - Implementation Details - -public final class ColorAsset { - public fileprivate(set) var name: String - - #if os(macOS) - public typealias Color = NSColor - #elseif os(iOS) || os(tvOS) || os(watchOS) - public typealias Color = UIColor - #endif - - @available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *) - public private(set) lazy var color: Color = { - guard let color = Color(asset: self) else { - fatalError("Unable to load color asset named \(name).") - } - return color - }() - - #if os(iOS) || os(tvOS) - @available(iOS 11.0, tvOS 11.0, *) - public func color(compatibleWith traitCollection: UITraitCollection) -> Color { - let bundle = BundleToken.bundle - guard let color = Color(named: name, in: bundle, compatibleWith: traitCollection) else { - fatalError("Unable to load color asset named \(name).") - } - return color - } - #endif - - #if canImport(SwiftUI) - @available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) - public private(set) lazy var swiftUIColor: SwiftUI.Color = { - SwiftUI.Color(asset: self) - }() - #endif - - fileprivate init(name: String) { - self.name = name - } -} - -public extension ColorAsset.Color { - @available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *) - convenience init?(asset: ColorAsset) { - let bundle = BundleToken.bundle - #if os(iOS) || os(tvOS) - self.init(named: asset.name, in: bundle, compatibleWith: nil) - #elseif os(macOS) - self.init(named: NSColor.Name(asset.name), bundle: bundle) - #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, *) -public extension SwiftUI.Color { - init(asset: ColorAsset) { - let bundle = BundleToken.bundle - self.init(asset.name, bundle: bundle) - } -} -#endif - -public struct ImageAsset { - public fileprivate(set) var name: String - - #if os(macOS) - public typealias Image = NSImage - #elseif os(iOS) || os(tvOS) || os(watchOS) - public typealias Image = UIImage - #endif - - @available(iOS 8.0, tvOS 9.0, watchOS 2.0, macOS 10.7, *) - public var image: Image { - let bundle = BundleToken.bundle - #if os(iOS) || os(tvOS) - let image = Image(named: name, in: bundle, compatibleWith: nil) - #elseif os(macOS) - let name = NSImage.Name(self.name) - let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name) - #elseif os(watchOS) - let image = Image(named: name) - #endif - guard let result = image else { - fatalError("Unable to load image asset named \(name).") - } - return result - } - - #if os(iOS) || os(tvOS) - @available(iOS 8.0, tvOS 9.0, *) - public func image(compatibleWith traitCollection: UITraitCollection) -> 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, *) - public var swiftUIImage: SwiftUI.Image { - SwiftUI.Image(asset: self) - } - #endif -} - -public 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, *) -public 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 diff --git a/Modules/Sources/Theme/swiftgen.yml b/Modules/Sources/Theme/swiftgen.yml index c088377..83e43aa 100644 --- a/Modules/Sources/Theme/swiftgen.yml +++ b/Modules/Sources/Theme/swiftgen.yml @@ -1,3 +1,5 @@ +output_dir: ${DERIVED_SOURCES_DIR} + xcassets: inputs: - Resources/Colors.xcassets