Path to bundle of iOS framework

后端 未结 4 1212
耶瑟儿~
耶瑟儿~ 2020-12-14 15:52

I am working on a framework for iOS, which comes with some datafiles. To load them into a Dictionary I do something like this:

public func loadP         


        
4条回答
  •  一个人的身影
    2020-12-14 16:39

    Try below code to get the custom bundle:

    let bundlePath = Bundle.main.path(forResource: "CustomBunlde", ofType: "bundle")
    let resourceBundle = Bundle.init(path: bundlePath!)
    

    Update

    If in your framework, try this:

    [[NSBundle bundleForClass:[YourClass class]] URLForResource:@"YourResourceName" withExtension:@".suffixName"];
    

提交回复
热议问题