简体   繁体   English

可以将xcode项目构建到没有源代码的静态库中吗?

[英]Can you build an xcode project into a static library that doesn't have source code in it?

I have an Objective-C iPad app I want to build an opaque static library from so I can give it to testers using X-code to test without giving them the source code. 我有一个Objective-C iPad应用程序,我想从中构建一个不透明的静态库,因此我可以将其提供给使用X代码进行测试的测试人员,而无需提供源代码。 How can I do this? 我怎样才能做到这一点?

Use a "Static Library" target. 使用“静态库”目标。 Add your source to the target, and build. 将源添加到目标并进行构建。 Since Objective-C is compiled to machine code, the resulting library is binary only. 由于将Objective-C编译为机器代码,因此生成的库仅是二进制的。 That said, Objective-C binaries are not as difficult to dig into as C++, for example. 就是说,例如,Objective-C二进制文件不像C ++那样难于挖掘。 Since Objective-C uses runtime dispatching, many symbol names are retained. 由于Objective-C使用运行时调度,因此保留了许多符号名称。 Using classdump at the command line, users will still be able to at least learn the classes and selectors in your binary. 在命令行上使用classdump ,用户仍将至少能够学习二进制文件中的类和选择器。 If this is unacceptable, you will have to consider writing the library in pure C (I discourage you from using C++ since it would require clients to use Objective-C++ just to use your library). 如果这是不可接受的,那么您将不得不考虑使用纯C语言编写库(我不鼓励您使用C ++,因为它会要求客户端仅使用Objective-C ++才能使用您的库)。

Objective-C已编译,因此只需对其进行编译,然后分发二进制文件。

If you want the recipients to be able to test on both a device and the simulator, build a fat library. 如果您希望收件人能够在设备和模拟器上进行测试,请构建一个胖库。 I liked this article on fat binaries. 我喜欢这篇关于胖二进制文件的文章

A static library is not very useful by itself. 静态库本身并不是很有用。 You will probably want to copy your entire project, remove all headers and sources except main.m and add your static library. 您可能需要复制整个项目,删除除main.m之外的所有标头和源,并添加静态库。 That way all the resources, frameworks, and build rules will remain in tact. 这样,所有资源,框架和构建规则将保持不变。 Then send along the library, project, and all resources. 然后发送库,项目和所有资源。

Unless there is a specific reason why you would want testers to access your application through XCode, you can instead build a binary for ad-hoc distribution that can be installed on up to 100 devices. 除非有特定原因,否则您希望测试人员通过XCode访问您的应用程序,否则,您可以为临时分发构建二进制文件,该二进制文件可以安装在最多100个设备上。 Check up "Ad Hoc Distribution" for the iPhone. 检查iPhone的“临时分发”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM