`
61party
  • 浏览: 1097312 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

iPhone开发:iOS Framework制作研究

 
阅读更多

iOS上如何制作自己的Framework呢?(不是静态库)

请看stackoverflow上的提问:

http://stackoverflow.com/questions/4065052/how-to-build-a-framework-or-library-for-other-developers-the-secure-way


解决办法

1,通过命令行脚本

http://www.cocoanetics.com/2010/04/making-your-own-iphone-frameworks/

由cocoa的Framework演变而来

2,通过hack bundle

http://www.cocoanetics.com/2010/05/making-your-own-iphone-frameworks-in-xcode/

这种方法有热心的同学做了中文翻译

http://www.cocoachina.com/bbs/read.php?tid-75680.html

但是需要制作2个framework,分别对应于simulator和device

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


3,使用别人的模板

https://github.com/kstenerud/iOS-Universal-Framework

这个算是集大成吧。当然作者有说明,这个也是假的,并不能象SDK自带的framework那样自如使用


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

http://code.google.com/p/pldatabase/

有待研究,以后再来补充

补充:

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

Lipo Binary 中的脚本如下:

FRAMEWORK="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework"

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不是hackbundle就是hack staticlib

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

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


详见:http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WhatAreFrameworks.html%23//apple_ref/doc/uid/20002303-BBCEIJFI

What are Frameworks?

Aframeworkis 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 calledumbrella frameworksand 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.



分享到:
评论

相关推荐

    IOS应用源码之【应用】-iOS framework 制作教程【非静态包】.rar

    在iOS开发中,框架(Framework)是用于组织和共享代码的一种机制,它包含库、头文件和其他资源。本教程将重点讲解如何制作一个非静态的iOS框架,这涉及到动态库的创建,相比于静态库,动态库可以减少应用程序的大小...

    iOS Universal Framework.zip

    iOS Universal Framework 是一个专为iOS开发设计的框架,它允许开发者创建可以在iPhone、iPad以及所有兼容iOS设备上运行的单一二进制文件。这个框架基于Objective-C编程语言,利用了Xcode 4的项目模板,使得开发过程...

    ios使用cmake编译framework

    在iOS开发中,CMake是一种流行的构建系统,用于自动化编译和链接过程,尤其是在跨平台项目中,如同时需要支持iOS、Android等平台时。本文将深入探讨如何使用CMake来构建iOS平台上的Framework。 首先,理解CMake的...

    iOS制作framework静态库图文教程

    以下是制作iOS静态库Framework的步骤: 1. **创建Cocoa Touch Framework工程**: 打开Xcode,选择“File” -> “New” -> “Project”,在模板列表中选择“Cocoa Touch Framework”,然后点击“Next”,填写项目...

    iOS 10 SDK Development: Creating iPhone and iPad Apps with Swift

    From the community-driven changes in Swift 3 to the overhaul of iOS' Foundation framework to make it more "Swifty," iOS 10 and Xcode 8 mark an "all in" commitment to Swift, and this new edition ...

    IOS xcode 模拟器 iphone 10.0 sdk

    标题中的“IOS xcode 模拟器 iphone 10.0 sdk”指的是使用Apple的集成开发环境Xcode来运行和测试iOS应用的模拟器功能,针对的是iOS 10.0版本的操作系统SDK(Software Development Kit)。这个SDK包含了开发者需要...

    iphone开发常用库UIKit_Framework

    ### iPhone开发常用库UIKit_Framework知识点解析 #### 一、UIKit Framework概述 - **定义与作用:** `UIKit` 是苹果公司为iOS应用开发提供的一套核心框架,它包含了用于构建用户界面的各种类和方法。通过这个框架...

    ios开发90个实例源码苹果ios系统项目开发学习资料

    通过深入研究这90个实例源码,开发者不仅可以掌握Swift编程,还能了解到iOS开发的全貌,包括最佳实践、设计模式和性能优化策略。每个实例都是一次动手实践的机会,通过学习和复用这些代码,你将能够快速提升自己的...

    ios4-5程序

    《iOS 4-5程序开发详解》是基于gene backlin所著的《iPhone与iPad高级编程》一书的配套代码库,涵盖了iOS平台上的高级编程技术。这本书主要面向已经掌握基本iOS开发技能的开发者,旨在深入探讨iOS 4和5版本中的高级...

    framework7- for IOS

    Framework7 是一款专为iOS移动应用开发设计的前端框架,它提供了一套全面的工具集,使得开发者可以轻松创建出类似原生iOS界面的应用程序,同时保持高度的灵活性和定制性。这款框架以其简洁易用的API、丰富的组件库...

    opus-for-iOS:iOS版opus框架构建脚本

    支持OS / Archs:iphoneos:armv7,armv7s,arm64模拟器:x86_64,i386 #用法: 只需在shell中运行以下命令: git clone https://github.com/wuqiong/opus-for-iOS.git cd opus-for-iOS ./build-opus-framework....

    ios实机IJKMediaFramework支持https

    在iOS开发中,为了实现流媒体播放功能,开发者经常会选择使用第三方框架,IJKMediaFramework便是其中的一个热门选择。这个框架是由Bilibili开源的,主要用于视频播放,它集成了FFmpeg库,提供了对多种流媒体协议的...

    iPhone.UIKit.Framework

    综上所述,iPhone的UIKit Framework是iOS应用开发的关键,它为开发者提供了丰富的工具和接口,帮助构建出高效、美观且交互性强的用户界面。理解和熟练运用UIKit,是每个iOS开发者必备的技能。通过持续学习和实践,...

    iOS实例开发源码——joshvera-iPhone-Tetris-2dd7365.zip

    这个压缩包文件“joshvera-iPhone-Tetris-2dd7365.zip...通过深入研究这个开源项目,开发者不仅能提升iOS编程技能,还能学习到游戏开发的基本流程和技巧,对于想要进入游戏开发领域的程序员来说是一份宝贵的参考资料。

    一步步学IOS5编程完整版

    第一部分:Hello World!创建你的第一个iPhone App 第二部分:iOS编程基础:Hello World应用程序如何工作的? 第三部分:iOS 编程向导:创建一个简单的表视图(Table View)应用程序...第二十四部分:开发定位服务的App

    一步一步学习_iOS_6_编程(第四版)

    第四版包含如下内容(合计有700+页),增加比较多深入开发的内容: 第一部分:Hello World!创建你的第一个iPhone App 第二部分:iOS编程基础:Hello World应用程序如何工作的? 第三部分:iOS 编程向导:创建一个...

    UIKit_Framework iOS

    ### UIKit Framework iOS 知识点解析 #### 一、UIKit框架概述 - **定义与作用:** `UIKit` 是苹果公司为iOS应用开发提供的一套基础框架,它包含了用于构建用户界面的各种类库和工具。UIKit是iOS应用程序的核心,...

Global site tag (gtag.js) - Google Analytics