How to include resources in iphone static library?

2019-05-07 15:07发布

问题:

I'd like to include files, data and images in a static library API so the users won't need to include them manually in their project. I see that there isn't obvious way to do it but is there some hack or workaround to achieve this goal ?

回答1:

You can try to use xxd with the -i command line parameter and use a wrapper function/method that feeds the data into a NSData

- (UIImage*)getMyImage
{
    return [UIImage imageWithData:[NSData dataWithBytes:file_ext 
                                                 length:file_ext_len]];
}


回答2:

So after referencing the frameworks programming guide, @codeflakes pointed out that dynamic frameworks aren't possible on iPhone OS. I found this link which looks like it has a static lib that includes a few resources. I downloaded the PlausibleDatabase lib referenced there and did see a couple items in a Resources directory. I think the static lib has to build it's own pseudo-bundle structure to get at those things.