简体   繁体   English

将.caf嵌入到静态库中。

[英]embed .caf into a static library .a is it possible?

I am able to play a .caf or an .mp3 file when I place it as a resource inside my project. 将项目作为资源放置在项目中时,我可以播放.caf或.mp3文件。 like below. 像下面

NSString *mp3Path = [[NSBundle mainBundle] pathForResource:@"beep" ofType:@"caf"];
NSURL *mp3Url = [NSURL fileURLWithPath:mp3Path];
_player = [[AVAudioPlayer alloc] initWithContentsOfURL:mp3Url error:nil];
_player.numberOfLoops = 8;

[_player play];

But for some reasons, I need to generate a static library .a from my project and wish to embed this .caf or .mp3 file inside the .a library. 但是由于某些原因,我需要从我的项目中生成一个静态库.a,并希望将此.caf或.mp3文件嵌入.a库中。

is it possible at all? 有可能吗? if it is, could you tell me how? 如果是,您能告诉我如何吗? because I couldn't find any sample doing a similar thing online. 因为我找不到任何样本在网上做类似的事情。

It's not usual to include resources in a static library. 通常不会在静态库中包含资源。 Usually they are included in a .bundle file. 通常它们包含在.bundle文件中。 You can generate a framework that contains the static .a library, the bundle file and headers. 您可以生成一个包含静态.a库,捆绑文件和标头的framework

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM