如何为 iPhone 打包 SDK(静态库 + xibs)?
我正在为客户端创建一个 SDK,其中包含预定义的视图控制器。打包所有内容(静态库、.xib(s) 和 .png(s))以便于使用的推荐方法是什么?
我使用过的 SDK(例如 Pinch Media)在仅提供 .h 和 .a 文件方面做得很好,这些文件仅公开用户可访问的功能并隐藏其他所有内容。当我阅读 Apple 的文档时,框架是理想的选择,但在 iPhoneOS 上是不允许的。
一些关键要求:
- 不要公开源或对象 内部结构。
- 易于使用设置。
- 在设备和模拟器上工作。
谢谢!
I am creating an SDK for a client that includes predefined view controllers. What is the recommended way to package everything (static lib, .xib(s), and .png(s)) for easy use?
SDKs that I've used (e.g. Pinch Media) do a good job of just providing a .h and .a file that expose only user accessible functionality and hiding everything else. As I read Apple's documentation, a framework would be ideal but is not permitted on iPhoneOS.
Some key requirements:
- Don't expose source or object
internals. - Be easy to use & set up.
- Work on both the device and simulator.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
框架是理想的,但正如你所说,iPhone 上不允许使用框架。我认为最终您需要提供至少 3 个文件:头文件、静态库和资源包。
头文件只包含您想要公开的所有 API。如果您有多个类,您可能需要提供多个标头。
对于静态库,我建议像平常一样为每个架构(设备和模拟器)编译它,然后使用 lipo 将它们组合起来,如下所示(根据需要替换路径):
使用捆绑包,您可以在 Xcode 中创建一个新目标来创建捆绑包,但实际上它只是一个文件夹。您还需要让您的 SDK 知道如何加载捆绑包并获取资源。但是,您无法从捆绑包中加载可执行代码;这就是框架无法在 iPhone 上运行的原因。
Frameworks would be ideal, but as you said, aren't allowed on the iPhone. I think in the end you'll need to provide at least 3 files: a header file, a static library, and a resource bundle.
The header file would simply have all the API's you do want to expose. If you have multiple classes you may want to provide multiple headers.
For the static library I recommend compiling it like normal for each architecture (Device and Simulator), and then use lipo to combine them like so (replacing paths as necessary):
With the bundle you can make a new target in Xcode to create a bundle, but really it's just a folder. You would also need to make you're SDK know how to load the bundle, and get to the resources. You can't load executable code from the bundle however; that is the reason frameworks don't work on the iPhone.