Is there any way to know which bundle corresponds to a source code file?
What I'm trying to accomplish is the following:
I have a source.swift/source.m file, inside of a Framework X. This file has a function, for instance: if it were in Swift -> whoIsMyEnclosingBundle() -> NSBundle
.
What I need for this function to work properly is for me to be able to load, for instance, my Storyboards inside that framework.
I would like to make this function general, so NO hardcoding of the bundle's name
I think you're looking for +[NSBundle bundleForClass:]
.
If you're not inside a class, then you could use +bundleWithIdentifier:
(this does mean you need to know the identifier ahead of time). The documentation recommends that method for frameworks that need their own bundle.