From 95de1c4c42019f766650da93c0d7015ddfb3bab8 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 28 Jun 2024 08:48:05 -0400 Subject: [PATCH] Update usage of resources --- Sources/Capabilities/Drawing/MediaEditorDrawing.swift | 2 +- Sources/Capabilities/Filters/MediaEditorFilters.swift | 2 +- Sources/Extensions/Bundle+mediaEditor.swift | 8 ++++++++ Sources/MediaEditorHub.swift | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Sources/Capabilities/Drawing/MediaEditorDrawing.swift b/Sources/Capabilities/Drawing/MediaEditorDrawing.swift index dd5d643..a584595 100644 --- a/Sources/Capabilities/Drawing/MediaEditorDrawing.swift +++ b/Sources/Capabilities/Drawing/MediaEditorDrawing.swift @@ -20,7 +20,7 @@ class MediaEditorDrawing: UIViewController { static func initialize() -> MediaEditorDrawing { return UIStoryboard( name: "MediaEditorDrawing", - bundle: Bundle(for: MediaEditorDrawing.self) + bundle: mediaEditorBundle(for: MediaEditorDrawing.self) ).instantiateViewController(withIdentifier: "drawingViewController") as! MediaEditorDrawing } diff --git a/Sources/Capabilities/Filters/MediaEditorFilters.swift b/Sources/Capabilities/Filters/MediaEditorFilters.swift index a0af514..7dc9b94 100644 --- a/Sources/Capabilities/Filters/MediaEditorFilters.swift +++ b/Sources/Capabilities/Filters/MediaEditorFilters.swift @@ -120,7 +120,7 @@ class MediaEditorFilters: UIViewController { static func initialize() -> MediaEditorFilters { return UIStoryboard( name: "MediaEditorFilters", - bundle: Bundle(for: MediaEditorFilters.self) + bundle: mediaEditorBundle(for: MediaEditorFilters.self) ).instantiateViewController(withIdentifier: "filtersViewController") as! MediaEditorFilters } diff --git a/Sources/Extensions/Bundle+mediaEditor.swift b/Sources/Extensions/Bundle+mediaEditor.swift index eb824fe..0b4d1bd 100644 --- a/Sources/Extensions/Bundle+mediaEditor.swift +++ b/Sources/Extensions/Bundle+mediaEditor.swift @@ -13,6 +13,14 @@ extension Bundle { } // Otherwise, the default bundle is used for resources return defaultBundle +#endif + } + + static func mediaEditorBundle(for type: AnyClass) -> Bundle? { +#if SWIFT_PACKAGE + return Bundle.module +#else + return Bundle(for: type) #endif } } diff --git a/Sources/MediaEditorHub.swift b/Sources/MediaEditorHub.swift index a9aed0c..34ccd54 100644 --- a/Sources/MediaEditorHub.swift +++ b/Sources/MediaEditorHub.swift @@ -253,7 +253,7 @@ public class MediaEditorHub: UIViewController { } static func initialize() -> MediaEditorHub { - return UIStoryboard(name: "MediaEditorHub", bundle: Bundle(for: MediaEditorHub.self)).instantiateViewController(withIdentifier: "hubViewController") as! MediaEditorHub + return UIStoryboard(name: "MediaEditorHub", bundle: .mediaEditorBundle(for: MediaEditorHub.self)).instantiateViewController(withIdentifier: "hubViewController") as! MediaEditorHub } private enum Constants {