ios 如何为其他开发人员构建框架或库,安全的方式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4065052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to build a framework or library for other developers, the secure way?
提问by Proud Member
We have an idea for an framework or library that will be very helpful for any iOS developer. So we're seriously thinking about switching from app development to framework/library development.
我们有一个对任何 iOS 开发人员都非常有帮助的框架或库的想法。所以我们正在认真考虑从应用程序开发切换到框架/库开发。
But when we want to charge for the library/framework, we must protect the code somehow. How can we build a framework in such a way that the user of our framework can't see the source code, similar to how we can't see the source code of Apples frameworks? They only ship the header files and some weird Unix exe file with the compiled framework, I guess.
但是当我们想为库/框架收费时,我们必须以某种方式保护代码。我们如何构建一个框架,让我们框架的用户看不到源代码,类似于我们如何看不到苹果框架的源代码?我猜他们只提供头文件和一些带有编译框架的奇怪的 Unix exe 文件。
Or if it is not possible to make an compiled framework / library that other iOS developers can use without beeing able to copy&paste our source codes, then is there a way to obfuscate the objective-c code?
或者,如果无法制作其他 iOS 开发人员可以使用的已编译框架/库而无需复制和粘贴我们的源代码,那么有没有办法混淆 Objective-C 代码?
回答by Jay Peyer
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/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/05/making-your-own-iphone-frameworks-in-xcode/
http://www.drobnik.com/touch/2010/10/embedding-binary-resources/
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).
要使用该框架,您的用户只需将 .framework 包拖入 Xcode。他们将能够看到您复制到包中的头文件(请参阅上面的文章),但不能看到源文件(因为它不包括在内——只有编译后的输出在包中)。
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. :)
查看下面添加的无羽毛链接 - 它是最新的,并且都在一页上:http: //github.com/jverkoey/iOS-Framework。它还列出了其他几种方法的问题。这是我现在在尝试记住设置新框架时要做什么时遵循的指南。:)
Update2 (with Xcode 6 release)
Update2(使用 Xcode 6 版本)
There is a option, exactly that you a re looking for:
Universal Framework for iOS
!
有一个选项,正是您正在寻找的:
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).
我的代码对其他人可见吗?A: 不会。这个框架会导出一个编译好的二进制文件,所以任何人都可以看到里面的内容。您可以对其他一些文件进行相同的操作,例如 XIB。
为什么我需要这个?A:这适用于希望在不显示完整代码(.m/.c/.cpp 文件)的情况下共享其代码的开发人员/团队。除此之外,这适用于想要将编译后的代码 + 资源(图像、视频、声音、XIB、plist 等)组织到一个地方的人。这也适用于希望在同一基础(框架)之上协同工作的团队。
回答by featherless
This guide is a bit more recent for creating iOS static frameworks:
本指南是创建 iOS 静态框架的最新指南:
回答by Greg
There is also a template for XCode 4that will let you create iOS static framework projects.
还有一个适用于 XCode 4的模板,可让您创建 iOS 静态框架项目。