适用于iOS和OS X应用程序的库?

问题描述:

有一段时间我现在通过创建2D游戏编程工具包/库来消磨业余时间。它是用Objective C编写的,由一个OpenGL渲染系统和一大堆AI,物理代码,一堆专门的容器和其他游戏相关的东西组成。除了基于OpenGL的View机制(显然)之外,大部分代码都应该可以轻松移植到iOS,因为它只使用 Foundation Framework ,该框架似乎在iOS上实现。到目前为止,我只使用Cocoa NSOpenGLView测试各种组件,但现在我想创建一个OS X / iOS库。

For a while now I have been killing spare time by creating a 2D game programming toolkit/library. It is written in Objective C, and consists of an OpenGL rendering system and a whole bunch of AI, physics code, a bunch of specialized containers and other game related stuff. Apart from the OpenGL based View mechanism (obviously), most of this code should be easily portable to iOS since it only uses the Foundation Framework and that framework appears to be implemented on iOS. So far I have only been testing the various components using a Cocoa NSOpenGLView but now I want to create a OS X/iOS library.

我的问题是:

创建可以集成到iOS或OS X应用程序中的Objective-C库的最佳策略是什么?

Xcode'新建项目'对话框仅提供:

The Xcode 'New Project' dialog offers only:

iPhone OS ;图书馆:

- Cocoa Touch静态库。

iPhone OS; Library:
- Cocoa Touch Static Library.

Mac OS X ,框架和图书馆:

- Cocoa Framework

- Cocoa Library

- Bundle

- BSD C Library

- STL C ++ Library

- JNI库

Mac OS X, Framework and Library:
- Cocoa Framework
- Cocoa Library
- Bundle
- BSD C Library
- STL C++ Library
- JNI Library

乍一看,这些似乎都不是用于创建可以集成到OS X或iOS应用程序中的库。

At first glance none of these seems to be intended for creating a library that can be integrated into either OS X or iOS applications.

好吧,我终于找到了正确的Google搜索词集,所以要回答我自己的问题(DOH!),它似乎可以共享代码,至少在iPhone应用程序之间,也可能在某些限制内分享iPhone和OS X应用程序。您必须创建一个静态库并使用跨项目引用:

Well, I finally found the correct set of Google search terms, so to answer my own question (DOH!), it seems to be possible to share code, at least between iPhone apps and possibly also iPhone and OS X apps within certain limits. You have to create a 'static library' and use 'cross-project references':

http://www.clintharris.net/2009/iphone-app-shared-libraries/

http://www.amateurinmotion.com/articles /2009/02/08/creating-a-static-library-for-iphone.html

http://zetetic.net/blog/2010/02/15 / building-static-libraries-to-share-code-on-iphone-and-mac-os-x-projects /

http://weston-fl.com/blog/?p=808

尚未对此进行测试,但看起来很有希望。

Haven't tested any of this yet but it looks promising.