如何为 iOS 应用程序创建 Objective-C 框架
我正在创建一些可重用于许多应用程序的通用类。
例如:共享功能 - 如果我们在项目中需要此功能,那么我们目前需要将一组类添加到该项目中并在该组文件中显示视图控制器,在此视图控制器中有按钮以及所有内容需要处理共享。
我的想法是,如果一个项目需要这样的功能,他们需要添加一个框架并调用其中的函数或在框架中显示指定的视图,即。没有向您执行该项目的人员授予代码级别访问权限。因此,如果在通用类(框架)中发现任何问题,我需要修复它并重新创建框架,并在使用该框架的所有项目中进行更改,而不影响现有项目。
我认为不仅仅是分享功能。更像是图像滑块、PDF 查看器、浏览器。覆盖流。目前我有所有这些功能的代码。但其他人需要花费太多时间来集成和使用它。如果发现任何问题,我们需要更改所有项目源类。
我在谷歌浏览了几个链接
可以我为 Cocoa Touch 应用程序开发自己的 Objective-C 框架?
http://www.cocoanetics.com/2010/04/universal-static-libraries/
我无法理解它是如何使用的,其中一些还没有完全解释它。这些链接中缺少一些内容。
提前致谢
I am in the middle of creating some generic classes that can be reusable for lot of application.
For Eg: Share Functions - if we need this functionality in a project then we currently I need to add a group of classes into that project and display the view-controller in that group of files, In this view controller there is buttons and what all need to handle sharing.
what my idea is if a project need such a functionality they need to add a framework and call a function in it or display the specified view in framework ie. no code level access given to whom you do that project. so if any issue is found in that generic classes (framework) I need to fix it and recreate the framework and change in the all project that uses this framework without affecting the existing project.
I am think not only the sharing function. More like a Image Slider, a PDF Viewer , a Browser. a Cover Flow. Currently I have code for all this Functions. But it take too much time to others to integrate it and use it. If any issue found we need to change the all project source classes.
I go through several links in google
Can I develop my own objective-C Framework for Cocoa Touch Applications?
http://www.cocoanetics.com/2010/04/universal-static-libraries/
A Guide for Creating your own Library for Cocoa(touch) development
I cannot understand how it use and some of them have not explain it fully. some missing in those links.
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
查看有关创建静态 iOS 框架的指南:
https://github.com/jverkoey/iOS-Framework
Check out this guide on creating static iOS frameworks:
https://github.com/jverkoey/iOS-Framework
我们在 Objective c 中创建了框架,工作非常完美。
按照以下简单步骤创建框架
1) 创建新框架,
在 xcode 中选择
2) 在项目中添加.h和.m文件,用于创建Framework。
3)在构建阶段在公共标头中添加文件,该文件将显示在您的框架中。
4) 单击项目名称 DemoFramework,然后选择 + 按钮
选择
5) 添加运行脚本
6) 在运行脚本中添加以下代码到聚合(marge)iPhone 和模拟器框架。
7) 现在分三步构建项目
1) 为 iPhone 设备构建。
您将看到为 iPhone 设备创建了框架,并且框架位置显示在项目的派生数据中,如下所示。
2) 构建模拟器。
您将看到为模拟器创建了框架,并且框架位置显示在项目的派生数据中,如下所示。
3)这是创建框架的最后一步,
在构建选项中选择聚合并构建应用程序,请参见下面的屏幕截图。
最后,在任何应用程序中使用此框架创建您的框架,框架位置位于派生数据中,如下所示。
希望这个简单的步骤可以帮助人们在 Objective C 中创建框架。
We created Framework in Objective c, It's work Perfect.
By Follow Below Simple Steps to create Framework
1) Create new framework as ,
In xcode select
2) Add .h and .m files in project, which is used for create Framework.
3) Add files in Public Headers in build phases, this file will display in your framework.
4) Click on project name DemoFramework then select + button then
select
5) Add Run Script
6) Add below code in Run script to Aggregate(marge)iPhone and simulator framework.
7) Now build the project in Three steps
1) Build for iPhone device .
You will see framework is created for iPhone device and framework location is show in derived data of project as below .
2) Build for simulator.
You will see framework is created for Simulator and framework location is show in derived data of project as below .
3) This is final step to create framework,
select Aggregate in build option and build the application see screen shot as below .
Finally your framework is created use this framework in any application, The Framework location is in derived data as below.
Hopes this easy steps help someone to create framework in objective C.
我猜你要问的是如何为iOS创建一个共享动态库;总而言之,就是:你不能。
唯一支持的库是静态库;因此,每当您对库进行更改时;每个使用它的应用程序都需要重新编译。
I'm guessing that what you are asking for is how to create a shared dynamic library for iOS; and the long and short of it is: You can't.
The only kind of library supported is the static library; so whenever you make changes to your library; every application that uses it needs to be recompiled.
http://accu.org/index.php/journals/1594 提供详细说明。
OCHamcrest 通过获取 OS X 版本框架的副本,并将其动态库替换为iOS 静态库。 (Xcode 4 版本即将推出。)
http://accu.org/index.php/journals/1594 offers detailed instructions.
OCHamcrest does it by taking a copy of the OS X version of the framework, and replacing its dynamic library with an iOS static library. (Xcode 4 version coming soon.)
我构建了 Xcode 4 模板来执行此操作。在这里查看我的答案:我可以为 Cocoa Touch 应用程序开发自己的 Objective-C 框架吗?
I built Xcode 4 templates to do this. See my answer here: Can I develop my own objective-C Framework for Cocoa Touch Applications?
Objective-C 消费者 -> Objective-C 动态框架
Xcode 版本 10.2.1
创建 Objective-C 框架
按照
创建 Objective-C 框架
使用 Objective-C 框架的 Objective-C 消费者
遵循
使用 Objective-C 框架的 Swift 消费者
将模块导入 Objective-C 客户端代码[module_name]
调用框架的代码[使用未声明的标识符]
[更多示例]
Objective-C consumer -> Objective-C dynamic framework
Xcode version 10.2.1
Create Objective-C framework
Follow
Create Objective-C framework
Objective-C consumer with Objective-C framework
Follow
Swift consumer with Objective-C framework
Import module to the Objective-C client code[module_name]
Call a framework's code[Use of undeclared identifier]
[More examples]