如何为其他开发人员构建框架或库,安全的方法?

我们有一个框架或库的想法,它对任何 iOS 开发人员都非常有帮助。因此,我们正在认真考虑从应用程序开发转向框架/库开发。

但是,当我们想要为库/框架收费时,我们必须以某种方式保护代码。我们怎样才能构建一个框架,让框架的用户看不到源代码,就像我们看不到苹果框架的源代码一样?他们只提供头文件和一些奇怪的 Unix exe 文件与编译框架,我猜。

或者,如果它不可能做一个编译的框架/库,其他 iOS 开发人员可以使用而不能复制和粘贴我们的源代码,那么有一种方法来混淆的目标-c 代码?

66310 次浏览

Yes, it is possible to build frameworks so the user of the framework can't see the source code.

Check out these articles (I've successfully used the first one to create frameworks in the past -- the later articles are updates to the original):

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

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

http://www.drobnik.com/touch/2010/10/embedding-binary-resources/

To use the framework, your users would just drag the .framework bundle into Xcode. They will be able to see the header files you copy into the bundle (see the articles above), but not the source (as it's not included -- only the compiled output is in the bundle).

This can also be a great way to distribute code that is used for multiple projects within your company.


Update:

Check out the link featherless added below -- it is much more recent and all on one page: http://github.com/jverkoey/iOS-Framework. It also lays out the issues with several other approaches. This is the guide I now follow when trying to remember what to do when setting up a new framework. :)

Update2 (with Xcode 6 release)

There is a option, exactly that you a re looking for: Universal Framework for iOS!

Will be my code visible to others? A: No. This Framework will export a compiled binary, so anyone can see inside it. You can make the same for some other files, like XIBs.

Why I need this? A: This is for developers/teams that want to share their codes without shows the entire code (.m/.c/.cpp files). Besides this is for who want to organize compiled code + resources (images, videos, sounds, XIBs, plist, etc) into one single place. And this is also for that teams that want to work together above the same base (framework).

(c) http://blog.db-in.com/universal-framework-for-ios/

There is also a template for XCode 4 that will let you create iOS static framework projects.

This guide is a bit more recent for creating iOS static frameworks:

https://github.com/jverkoey/iOS-Framework