iPhone开发:iOS Framework制作研究








2,通过hack  bundle





这种方法这里也有详细介绍 http://db-in.com/blog/2011/05/creating-universal-framework-to-iphone-ios/




而code google上的pldatabase framework是可以象SDK自己的framework一样,一个framework同时运行在模拟器和真机上的




pldatabase framework 也只是产生2个静态库(.a)然后通过lipo合并起来,但是这已经很好了。

Lipo Binary 中的脚本如下:


lipo \
"${BUILD_DIR}/${CONFIGURATION}-iphoneos/libPlausibleDatabase-iPhoneOS.a" \
"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/libPlausibleDatabase-iPhoneSimulator.a" \
-create -output "${FRAMEWORK}/Versions/Current/${PRODUCT_NAME}"

cd "${FRAMEWORK}" && ln -sf "Versions/Current/${PRODUCT_NAME}" ./

看来上面的方法没有产生真正意义上Framework,所谓的Framework不是hack bundle就是 hack static lib

至于第二种方法为什么可以实现,因为Framework其实也是一个bundle (a structured directory),

可以参照apple的官方说明 http://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/Framework.html


What are Frameworks?

framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package. Multiple applications can use all of these resources simultaneously. The system loads them into memory as needed and shares the one copy of the resource among all applications whenever possible.

A framework is also a bundle and its contents can be accessed using Core Foundation Bundle Services or the Cocoa NSBundle class. However, unlike most bundles, a framework bundle does not appear in the Finder as an opaque file. A framework bundle is a standard directory that the user can navigate. This makes it easier for developers to browse the framework contents and view any included documentation and header files.

Frameworks serve the same purpose as static and dynamic shared libraries, that is, they provide a library of routines that can be called by an application to perform a specific task. For example, the Application Kit and Foundation frameworks provide the programmatic interfaces for the Cocoa classes and methods. Frameworks offer the following advantages over static-linked libraries and other types of dynamic shared libraries:

  • Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources.

  • Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation.

  • Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs.

  • Only one copy of a framework’s read-only resources reside physically in-memory at any given time, regardless of how many processes are using those resources. This sharing of resources reduces the memory footprint of the system and helps improve performance.

Note: Frameworks are not required to provide a programmatic interface and can include only resource files. However, such a use is not common.

The Darwin layer contains many static and dynamic libraries but otherwise, most Mac OS X interfaces are packaged as frameworks. Some key frameworks—including Carbon, Cocoa, Application Services, and Core Services—provide convenient groupings of several smaller but related frameworks. These framework groups are called umbrella frameworks and they act as an abstraction layer between a technology and the subframeworks that implement that technology.

In addition to using the system frameworks, you can create your own frameworks and use them privately for your own applications or make them publicly available to other developers. Private frameworks are appropriate for code modules you want to use in your own applications but do not want other developers to use. Public frameworks are intended for use by other developers and usually include headers and documentation defining the framework’s public interface.

个人分类: iphone开发
想对作者说点什么? 我来说一句