Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
815 views
in Technique[技术] by (71.8m points)

json - How do third-party libraries work in Objective-C and 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.

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)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

external code can be:

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.

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

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 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.

hope that helps some.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...