Bundle

public extension Bundle

An extension for Bundle to enable easy & correct referencing of the Bundle for a framework, when a resource is needed from within the framework vs main (or other framework) bundle.

  • A computed property representing the bundle for the framework. Accessing this property automatically determines the type of dependency manager used, either SwiftPM or Cocoapods.

    Precondition

    Your project incorporates the framework using either SwiftPM or Cocoapods.

    Warning

    If your project does not use SwiftPM or Cocoapods to import the framework, this property will return nil and some bundles resources may fail to load.

    Declaration

    Swift

    static var framework: Bundle?
  • spm

    A computed property representing the correctBundle when the framework is imported using Swift Package Manager.

    Precondition

    Your project incorporates the framework using Cocoapods.

    Warning

    If your project does not use SwiftPM for the framework, this will return nil and some bundles resources may fail to load.

    Declaration

    Swift

    static let spm: Bundle?
  • pod

    A computed property representing the correct Bundle when the framework is imported using Cocoapods.

    Precondition

    Your project incorporates the framework using Cocoapods.

    Warning

    If your project does not use Cocoapods for the framework, this will return nil and some bundle resources may fail to load.

    Declaration

    Swift

    static let pod: Bundle?
  • An accessor function for acessing resourceBundles within a Cococapod framework.

    Precondition

    Your project incorporates the framework using Cocoapods, and the framework uses resourceBundles within the framework podspec.

    Warning

    If your project does not use Cocoapods for the framework or resourceBundles, this will return nil and some bundle resources may fail to load.

    Declaration

    Swift

    static func podResourceBundle(_ name: String) -> Bundle?