美文网首页
iOS 项目将图片打包成Bundle资源文件

iOS 项目将图片打包成Bundle资源文件

作者: 陶小亮 | 来源:发表于2021-07-05 11:33 被阅读0次
    创建bundle文件,如下图,点击弹框,选择MacOS下面的Framwork & Library ,点击Bundle,输入Bundle的名字,然后点击完成
    image
    点击创建好的bundle,修改属性 分别修改以下属性
    • "Base SDK" 设置为 "iOS "

    • "Build Active Architecture Only" 设置为 "YES"

    • Installation Directiotory 删除掉后面的路径 (这里注意是把所有的路劲删掉即可)

    • Code Signing Identity 选择 Don't Code Sign (这里可能要手动输入下)

    • "iOS Deployment Target" 设置为 iOS 9.0 (也可以选择你项目中最低支持的版本)

    • "Skip Install" 设置为 "NO"

    +"Strip Debug Symbols During Copy" 中"Release"模式设置为 "YES"

    • "COMBINE_HIDPI_IMAGES" 设置为 "NO"
    image
    设置完以上的属性后,将你需要的图片拖拽到Bundle文件夹中(这里注意勾选项)
    image image
    最后一步选择创建的bundle进行编译:模拟器和真机都编译一遍后,在Products中就会有
    image image
    有网友说,打包的时候会出现
    
        ERROR ITMS-90171: "Invalid Bundle Structure - The binary file 'lhby.app/Test.bundle/Test' is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at...
    
    

    或者

    
        ERROR ITMS-90535: "Unexpected CFBundleExecutable Key. The bundle at 'Payload/dianlan2.app/EaseUIResource.bundle' does not contain a bundle executable. If this bundle intentionally does not contain an executable, consider removing the CFBundleExecutable key from its Info.plist and using a CFBundlePackageType of BNDL. If this bundle is part of a third-party framework, consider contacting the developer of the framework for an update to address this issue."
    
    

    或者

    
        ERROR ITMS-90034: "Missing or invalid signature. The bundle 'ABC.Test' at bundle path     'Payload/lhby.app/Test.bundle' is not signed using an Apple submission certificate."
    
    

    网上也有很多的解决办法,这里提供一种解决方法,就是删除bundle里的执行文件:找到工程中的xxx.Bundle,右键单击后 选择 "显示包内容",找到里面黑色的可执行文件xxx,删除掉,然后找到里面的info.plist文件 ,删除掉Executable file 字段,重新打包,上传应用商店就可以了。

    写在最后

    这里是我用swift写的获取图片的方式,如果有不严谨的地方,请各位大佬指出,笔者在这里不胜感激。

    
        //TODO:
    
        //TODO:    获取图片
    
        privatefunczl_getImgNameWith(imgName:String?, imgType:String?)->UIImage?{
    
            letimgPath =Bundle.main.path(forResource:"project_Img", ofType:"bundle")
    
            ifletImgPath = imgPath {
    
                letimgBundle =Bundle.init(path: ImgPath)
    
                letimg_string = imgBundle?.path(forResource: imgName, ofType: imgType)
    
                ifletimgString = img_string {
    
                    letimg =UIImage(contentsOfFile: imgString)
    
                    returnimg
    
                }
    
                print("img_string为空")
    
                returnnil
    
            }else{
    
                print("imgPath为空")
    
                returnnil
    
            }
    
        }
    
    

    感谢您的阅读,希望能给你提供帮助

    相关文章

      网友评论

          本文标题:iOS 项目将图片打包成Bundle资源文件

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