If you want to create your own interfaces using the interface designer when creating a static library, you will need to create a package and distribute it with your library.
In Xcode:
- File> New> Goal
- Select "Bundle" from the OS X Framework and Library section.
- Fill in the data. The package structure should be the basis.
Then you need to build your package at the same time as your framework. Add the node to the Target Dependencies assembly phase of your structure.
When you make your xibs, you make your goal with this new package that you created.
Then, when you compile your framework in the derived data directory, next to your binary, you will find your compiled package. You pass this on to third parties along with the binary framework.
So how do you reference this package in your code? On iOS, packages cannot be downloaded, and your package will indeed be in a third-party iOS application. You can create a category in NSBundle for convenient access to your collection from your code:
@interface NSBundle (mybundle) +(NSBundle *)myBundle; @end @implementation NSBundle (mybundle) static NSBundle * _myBundle; +(NSBundle *)myBundle{ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSBundle * mainBundle = [NSBundle mainBundle]; NSString * pathToMyBundle = [mainBundle pathForResource:@"myBundle" ofType:@"bundle"]; NSAssert(pathToMyBundle, @"bundle not found", nil); _myBundle = [NSBundle bundleWithPath:pathToMyBundle]; }); return _myBundle; }
You can then access your package in the xibs download code as follows:
UIViewController * controller = [[UIViewController alloc] initWithNibName:nil bundle:[NSBundle myBundle]];
Remember that if you use categories in the framework code, you will need to make sure that your infrastructure users add -ObjC (or -all_load if not using recent Xcode) "another linker flag" to their projects
source share