From 60019b9b8b53434aed317c4da7a83df267a16f37 Mon Sep 17 00:00:00 2001 From: chongin12 Date: Mon, 14 Aug 2023 16:31:46 +0900 Subject: [PATCH] =?UTF-8?q?[NON=5FISSUE]=20Bundle=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Package.swift | 7 +++---- YDS-Essential/Source/YDSBundle.swift | 15 ++++++++++++++- YDS/Source/Foundation/YDSBasicColor.swift | 9 +-------- YDS/Source/Foundation/YDSIcon.swift | 9 +-------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Package.swift b/Package.swift index 2d582565..b389f813 100644 --- a/Package.swift +++ b/Package.swift @@ -32,14 +32,14 @@ let package = Package( .product(name: "PanModal", package: "PanModal"), .product(name: "SnapKit", package: "SnapKit"), .product(name: "Parchment", package: "Parchment"), - .targetItem(name: "YDS-Essential", condition: .none) + .target(name: "YDS-Essential", condition: .none) ], path: "YDS/Source" ), .target( name: "YDS-SwiftUI", dependencies: [ - .targetItem(name: "YDS-Essential", condition: .none) + .target(name: "YDS-Essential", condition: .none) ], path: "YDS-SwiftUI/Source" ), @@ -48,8 +48,7 @@ let package = Package( dependencies: [], path: "YDS-Essential/Source", resources: [ - .process("Foundation/YDSIcon.xcassets"), - .process("Foundation/YDSBasicColor.xcassets") + .process("Foundation") ] ) ] diff --git a/YDS-Essential/Source/YDSBundle.swift b/YDS-Essential/Source/YDSBundle.swift index 6fd40d93..49bdb1b6 100644 --- a/YDS-Essential/Source/YDSBundle.swift +++ b/YDS-Essential/Source/YDSBundle.swift @@ -1,6 +1,6 @@ // // YDSBundle.swift -// YDS-SwiftUI +// YDS-Essential // // Created by 정종인 on 2023/07/30. // @@ -10,3 +10,16 @@ import Foundation public class YDSBundle { public static let bundle = Bundle(for: YDSBundle.self) } +#if SWIFT_PACKAGE +public extension Bundle { + static var ydsEssential: Bundle { + return .module + } +} +#else +public extension Bundle { + static var ydsEssential: Bundle { + return Bundle(for: YDSBundle.self) + } +} +#endif diff --git a/YDS/Source/Foundation/YDSBasicColor.swift b/YDS/Source/Foundation/YDSBasicColor.swift index 636e3507..2eaaa71e 100644 --- a/YDS/Source/Foundation/YDSBasicColor.swift +++ b/YDS/Source/Foundation/YDSBasicColor.swift @@ -705,17 +705,10 @@ internal extension UIColor { fileprivate extension UIColor { static func load(name: String) -> UIColor { -#if SWIFT_PACKAGE - guard let color = UIColor(named: name, in: .module, compatibleWith: nil) else { + guard let color = UIColor(named: name, in: .ydsEssential, compatibleWith: nil) else { assert(false, "\(name) 컬러 로드 실패") return UIColor.clear } -#else - guard let color = UIColor(named: name, in: YDSBundle.bundle, compatibleWith: nil) else { - assert(false, "\(name) 컬러 로드 실패") - return UIColor.clear - } -#endif return color } } diff --git a/YDS/Source/Foundation/YDSIcon.swift b/YDS/Source/Foundation/YDSIcon.swift index 10c194eb..f75c94eb 100644 --- a/YDS/Source/Foundation/YDSIcon.swift +++ b/YDS/Source/Foundation/YDSIcon.swift @@ -97,17 +97,10 @@ public enum YDSIcon { extension UIImage { fileprivate static func load(name: String) -> UIImage { -#if SWIFT_PACKAGE - guard let image = UIImage(named: name, in: .module, compatibleWith: nil) else { + guard let image = UIImage(named: name, in: .ydsEssential, compatibleWith: nil) else { assert(false, "\(name) 이미지 로드 실패") return UIImage() } -#else - guard let image = UIImage(named: name, in: YDSBundle.bundle, compatibleWith: nil) else { - assert(false, "\(name) 이미지 로드 실패") - return UIImage() - } -#endif image.accessibilityIdentifier = name return image }