Home > Blockchain >  Can we access the plist inside a framework target from the application?
Can we access the plist inside a framework target from the application?

Time:05-24

I have embedded a framework inside a project. I would like to keep certain congifuration specific to the framework target inside a plist withing the framework target.

Is there any way I can access the plist when running the application ? Bundle.main always return the current executable.

I would like to access the specific target and get the plist contents.

CodePudding user response:

You have to access for resources via Bundle. In your Framework define something like this:

private class BundleClass {}

extension Bundle {
    public static var myFramework: Bundle {
        Bundle(for: BundleClass.self)
    }
}

and access your resources like this:

let filePlistURL = Bundle.myFramework.url(forResource: "file", withExtension: "plist")
  • Related