iOS各问题归类

iOS 创建bundle (xcode 13)

2022-04-14  本文已影响0人  若水water

bundle 资源包 是静态的,不参与项目的编译,所以不占包的大小,如果bundle里面要包含xib,那么需要创建工程的形式,将xib 序列化为静态nib。bundle 里面是不能加入二进制文件的。

image.png image.png image.png image.png image.png image.png image.png image.png image.png

分别选择真机模式,和模拟器模式进行编译,编译通过后,command + ,
点击该路径,找到bundle文件

image.png image.png image.png
    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"HLNetworkSource" ofType:@"bundle"];
    NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
    NSString *imagePath = [bundle pathForResource:@"bill_head_bg" ofType:@"png"];
    NSData *data = [NSData dataWithContentsOfFile:imagePath];
    UIImage *image = [UIImage imageWithData:data];

如果要打包上线,可能会有些问题,再针对不同的问题去解决就行。我还没有试,如果有问题,望指出。

上一篇下一篇

猜你喜欢

热点阅读