Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I know you can't include resource files into a static library (that's what frameworks do). I use another solution in my projects:</p> <p>Inside the static library "YYY" project:</p> <ul> <li>I add a "Loadable Bundle" target to my static library project (Add Target, Cocoa, Loadable Bundle)</li> <li>I add this target as a dependency of the static library target</li> </ul> <p>Inside the main project:</p> <ul> <li>Link the <code>libYYY.a</code></li> <li>Add the bundle <code>YYY.bundle</code> to the copied resource files</li> </ul> <p>This way, resource files used in the static library are not managed in the main project. Say I have a <code>foo.png</code> picture in the static library, I use</p> <pre><code>[UIImage imageNamed:@"YYY.bundle/foo.png"] </code></pre> <p>You could then get your plist like this:</p> <pre><code>NSBundle *staticLibBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"YYY" ofType:@"bundle"]]; NSString *filePath = [staticLibBundle pathForResource:@"MyClassParams" ofType:@"plist"]; NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath]; </code></pre> <hr> <p>Below, two screenshots:</p> <ul> <li><strong>left</strong>: static library project with loadable bundle target</li> <li><strong>right</strong>: showing the static library binary added to "Link Binary With Libraries" and the resource bundle added to "Copy bundle Resources".</li> </ul> <p><img src="https://i.stack.imgur.com/zi77T.png" alt="Static library project"> <img src="https://i.stack.imgur.com/Jy3jJ.png" alt="Main project"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload