美文网首页
创建 bundle 文件

创建 bundle 文件

作者: xiaofu666 | 来源:发表于2019-05-05 18:39 被阅读0次

1. 创建bundle 如图所示:

image.png
找到如图所示:
image.png
输入所创建的图片库名称
image.png

2. 点击创建好的bundle ,修改属性

(1)"Base SDK" 设置为 "Latest iOS (iOS 11.2)" (Xcode 9.2为例)
"Build Active Architecture Only" 设置为 "YES"
image.png
(2)Installation Directiotory 删除掉后面的路径
image.png
(3)Code Signing Identity 选择 Don't Code Sign
image.png
(4)"iOS Deployment Target" 设置为 iOS 8.0 (为了兼容性,最好选择最低版本)
image.png
(5)"Skip Install" 设置为 "NO"
image.png
(6)"Strip Debug Symbols During Copy" 中"Release"模式设置为 "YES"
image.png
(7) "COMBINE_HIDPI_IMAGES" 设置为 "NO"
image.png

3. 现在开始导入图片资源

(1.直接拖项目中,系统会自动导入Copy Bundle Resources里去,2.如下图加进去)
image.png

4. 选择创建的bundle 进行编译,开始生成bundle,分别选择真机和模拟器,然后各运行一遍,即可生成真机和模拟器使用的bundle:

image.png

5. 找到生成的bundle,打包上架APP的时候应使用真机模式下运行生成的Bundle,即Debug-iPhoneos 文件夹内的bundle。

image.png

6.bundle的使用,因为bundle是静态的,不进行编译的资源文件。所以,要使用bundle中的资源,就需要找到相应的资源路径。

(第一种方法)
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)];

UIImage *image = [UIImage imageNamed:@"Image.bundle/Add.png"];

[imgView setImage:image];
(第二种方法)
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 50,50)];
 
NSString *bundlePath = [[ NSBundle mainBundle] pathForResource:@"Image" ofType :@"bundle"];
 
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
 
NSString *imgPath = [bundle pathForResource:Add ofType:@"png"];
 
UIImage *image=[UIImage imageWithContentsOfFile: imgPath];
 
[imgView setImage:image];

\color{red}{注:打包的bundle给别人使用,别人在打包完上传过程中可能会极大的坑}

出现的问题

因为是和SDK一起让别的公司共用的,没想到每个App打包上传都失败了,主要有以下几种提示:
image.png image.png image.png
有很多解决办法,我用的是最简单的办法:

\color{#7B68EE}{就是删除bundle里的执行文件:}

找到工程中的Image.Bundle,右键单击后 选择 "显示包内容",找到里面的info.plist文件 ,删除掉Executable file 字段,重新打包,上传应用商店就可以了。

相关文章

  • React-Router + Webpack懒加载

    安装Bundle Loader 创建bundle.js 创建lazyLoad.js文件 使用 注意:import ...

  • 创建.bundle文件

    1、 资源文件包。我们将许多图片、XIB、文本文件组织在一起,打包成一个Bundle文件。方便在其他项目中引用包内...

  • 创建 bundle 文件

    1. 创建bundle 如图所示: 找到如图所示: 输入所创建的图片库名称 2. 点击创建好的bundle ,修改...

  • React-native IOS 资源文件打包不显示

    1.创建bundle文件夹做法:在ios目录下创建bundle文件夹,拖入xcode,勾选Greate folde...

  • iOS开发 创建Bundle及注意事项

    一、创建Bundle 方式一: 创建文件夹TestBundle,并改名为TestBundle.bundle。然后再...

  • ios创建.bundle文件

    Bundle文件可以理解为一个资源包,用于存储图片、音频、文本、nib文件等,方便在其他项目中引用包内的资源。bu...

  • iOS创建bundle文件

    选择需要加入的项目 之后需要更改运行系统Bundle 默认是 macOS 系统的需修改成 iOS 系统。 在TAR...

  • iOS之SDK的创建

    SDK的创建 SDK创建的时候一般包含.a文件以及对应的.h文件,还有bundle文件 1.iOS中.a文件的创建...

  • iOS bundle资源管理

    我们下载的很多demo 里面的资源文件都是放在bundle文件里,要怎么创建使用bundle文件呢。这边又两种方法...

  • AndroidStudio+ReactNative混合开发所遇到

    Q:如何手动创建assets目录下bundle文件 A:先在app/src/main/目录下创建assets文件夹...

网友评论

      本文标题:创建 bundle 文件

      本文链接:https://www.haomeiwen.com/subject/wdihoqtx.html