第三方库如何在Objective-C和Xcode中工作? [英] How do third-party libraries work in Objective-C and Xcode?

查看:100
本文介绍了第三方库如何在Objective-C和Xcode中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对Objective-C和Xcode来说还很新(两周),我正尝试添加我的第一个外部"库,名为

Pretty new (2 weeks) into Objective-C and Xcode, and I'm trying to add my first "external" library, namey restkit, to read some JSON from an external server.

但是,从我的理解来看,看看他们的入门"指南,您只需下载一个包含源代码的软件包,然后将其链接并以某种方式将其构建为您自己的构建的一部分... (指南在这里),特别是第4点很有趣)

However, looking at their "getting started" guide, from what I understand you just download a package with the sourcecode and link it in and build it as part of your own build somehow... (the guide is here), expecially point 4 is interesting)

我是一位多年的Java开发人员,我尝试将它与它的工作方式进行比较,并使用您无法更改的已编译,打包的jar文件. jarfile与这有何关系?据我所知,您可以随意进入并更改任何第三方文件.

I am a many-years Java developer and I try to compare it to how it works there, with compiled, packaged jar-files that you can't alter. How do jarfiles relate to this? From what I can see, you can just go in and change any of the third-party files as you see fit.

如果有人可以帮助我理解这一点,我将不胜感激.

If someone could help me grasp this I'd appreciate it.

推荐答案

外部代码可以是:

动态库(.dlyb),可以作为框架分发并安装在计算机上.但请注意,您无法在iPhone上安装框架-您的应用已沙箱化.在所有iPhone上,您都可以使用一定数量的框架.

a dynamic library (.dlyb) which can be distributed as a framework and installed on the machine. But be aware, that you can't install frameworks on the iPhone - your app is sandboxed. A set number of frameworks are available to you which are on all iPhones.

您还可以使用静态库.在链接过程中,静态库会编译到您的应用二进制文件中.

you can also consume a static library. a static library is compiled into your apps binary during linking.

链接: http://blog.carbonfive.com/2011 /04/04/using-open-source-static-libraries-in-xcode-4/

另一种相当常见的形式是使用代码.在iPhone开发中很常见,因为设备的关闭程度和应用的沙盒存储方式.它也很流行,因为许多组件和库都是在github上开源的.共享代码通常有两种形式:

The other and fairly common form is consuming code. It's common in iPhone development because how closed the device is and how sandboxed your app is. it's also popular because many components and libraries are open sourced on github. sharing code usually comes in two forms:

复制代码-将一些文件添加到您的应用中,然后就可以使用了.您必须定期更新文件.

copy code - add some files to your app and off you go. you have to update files on some perioding basis.

xcode子项目-您可以将外部库xcode项目作为子项目添加到您的项目中.该子项目可以产生您的应用程序使用的静态库(目标).在xcode4中,您还可以有一个包含多个项目的工作区.

xcode sub-project - you can add an external libraries xcode project as a sub-project to your project. that sub-project can produce a static library (target) which your app consumes. in xcode4, you can also have a workspace which contains multiple projects.

使用代码的好处是可以对其进行调试.代码越复杂,使用子项目的吸引力就越大.如果只有少数几个独立文件,那么添加文件就很简单.

Consuming code has the benefit of being able to debug into it. The more complex the code becomes, the more attractive consuming a sub-project is. If it's a handful of self-contained files, then just adding the files is simple.

希望有帮助.

这篇关于第三方库如何在Objective-C和Xcode中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆