如何在Xcode中为iPhone应用程序创建自己的软件包 [英] How to create my own bundle in Xcode, for iPhone application

查看:183
本文介绍了如何在Xcode中为iPhone应用程序创建自己的软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如, Facebook 已经开发了一个使用框架的iPhone应用软件包。同样,我也想创建一个可以重用于许多应用程序的软件包。



我的问题是:




  • 应该采取什么步骤为任何类型的应用程序创建捆绑包?

  • 创建捆绑包时应该注意什么? >


提前感谢分享您的知识。

解决方案

首先,由于您的问题是iPhone的标签,您只能在iPhone上的软件包中添加代码。所以基本上你只能使用包来打包图片和声音文件以及其他静态数据。



当您在XCode中创建一个新项目时,有一个选项可以使定位一个bundle(在Framework& Library下),但资产束只是一个带有.bundle后缀的目录。我用这个小脚本生成了我:

 #!/ bin / bash 
echo构建资产包。
如果[-d ./MyAssets.bundle];然后
rm ./MyAssets.bundle/*
else
mkdir ./MyAssets.bundle
fi
find ./assets -type f -print0 | xargs -0 -J%cp%./MyAssets.bundle

(我不是黑客黑客,所以这可能会以无数的方式得到改进。建议欢迎!)



这需要一个文件夹层次结构,并将它(我将层次结构)放大到一个名为MyAssets的单个目录。束。在导入软件包的项目中,我将从单独的构建阶段触发此脚本,以便自动跟踪更改。



如果您想了解如何创建框架包,这有点复杂(你必须遵守某些惯例,并包括信息在plists),但对于iPhone捆绑,这几乎是你需要知道和做的所有。


I am having some difficulty creating a bundle for my application, and placing files in the bundle.

For example, Facebook has developed a bundle for iPhone applications using their framework. In the same way, I also want to create a bundle which can be reused for many applications.

My questions are:

  • what steps should I follow to create a bundle for any kind of application?
  • what should be taken care while creating a bundle?

Thanks in advance for sharing your knowledge.

解决方案

First of all, since your question is tagged iPhone, you can only include code in your bundles on the iPhone. So basically you can only use bundles to package up pictures and sound files and other static data.

When you create a new project in XCode, there is an option to make the target a bundle (under Framework & Library), but an assets bundle is just a directory with a .bundle suffix. I generate mine with this little script:

#!/bin/bash
echo "Building assets bundle."
if [ -d ./MyAssets.bundle ]; then
   rm ./MyAssets.bundle/*
else
   mkdir ./MyAssets.bundle
fi
find ./assets -type f -print0 | xargs -0 -J% cp % ./MyAssets.bundle

(I'm no bash hacker, so this can probably be improved in countless ways. Suggestions welcome!)

This takes a folder hierarchy and flattens it (I detest hierarchies) into a single directory which is named MyAssets.bundle. I trigger this script from a separate build phase when in projects that import the bundle, so that changes are automatically tracked.

If you want to learn how to create framework bundles, it's a bit more complicated (you have to follow certain conventions and include info in plists), but for iPhone bundles, this is pretty much all you will need to know and do.

这篇关于如何在Xcode中为iPhone应用程序创建自己的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆