最佳方式安装一个自定义可可框架 [英] Best way to install a custom cocoa framework

查看:117
本文介绍了最佳方式安装一个自定义可可框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义框架,遵循Apple的框架编程指南>> 安装您的框架我安装在/ Library / Frameworks中。我通过添加一个运行脚本构建阶段与以下脚本:

I have a custom framework that, following the advice in Apple's Framework Programming Guide >> Installing your framework I install in /Library/Frameworks. I do this by adding a Run Script build phase with the following script:

cp -R  build/Debug/MyFramework.framework /Library/Frameworks



在我的项目中,我链接/ Library / Frameworks / MyFramework,类如下:

In my projects I then link against /Library/Frameworks/MyFramework and import it in my classes like so:

#import <MyFramework/MyFramework.h>

这样工作得很好,除了我总是在调试器控制台看到以下消息:

This works very well, except that I always see the following message in my debugger console:


将程序加载到调试器中
sharedlibrary apply-load-rules all
警告:无法读取/ Users / elisevanlooij / Library / Frameworks / MyFramework.framework / Versions / A / MyFramework(找不到文件)。
警告:无法从MyFramework读取符号(尚未映射到内存中)。
程序加载。

Loading program into debugger… sharedlibrary apply-load-rules all warning: Unable to read symbols for "/Users/elisevanlooij/Library/Frameworks/MyFramework.framework/Versions/A/MyFramework" (file not found). warning: Unable to read symbols from "MyFramework" (not yet mapped into memory). Program loaded.

显然,编译器首先查找/ Users / elisevanlooij / Library / Frameworks,找不到MyFramework,然后查找/ Library / Frameworks,找到MyFramework并继续其快乐的方式。到目前为止这已经比一个真正的问题更烦恼,但是当runnning单元测试,gdb停止在(文件未找到),并拒绝继续。我已经通过添加一个额外的行到运行脚本阶段解决了这个问题

Apparently, the compiler first looks in /Users/elisevanlooij/Library/Frameworks, can't find MyFramework, then looks in /Library/Frameworks, does find MyFramework and continues on its merry way. So far this has been more of an annoyance than a real problem, but when runnning unit tests, gdb stops on the (file not found) and refuses to continue. I have solved the problem by adding an extra line to the Run Script Phase

cp -R  build/Debug/MyFramework.framework ~/Library/Frameworks

但它感觉像是一个不应该在第一地点。如何解决这个问题?

but it feels like sello-taping something that shouldn't be broken in the first place. How can I fix this?

推荐答案

在过去的几个月里,我学到了很多关于框架的知识,重写这个答案。请注意,我在说在开发工作流程中安装框架

In the past months, I've learned a lot more about frameworks, so I'm rewriting this answer. Please note that I'm talking about installing a framework as part of the development workflow.

安装公共框架的首选位置一个将被多个应用程序或软件包使用的框架)是/ Library / Frameworks [链接文本],因为此位置中的框架由编译器在编译时自动发现,动态链接器在运行时发现。编程指南]。最优雅的方法是在Build设置的部署部分。

The preferred location for installing a public framework (i.e. a framework that will be used by more than one of your apps or bundles) is /Library/Frameworks[link text] because "frameworks in this location are discovered automatically by the compiler at compile time and the dynamic linker at runtime."[Framework Programming Guide]. The most elegant way to do this is in the Deployment section of the Build settings.

当你在框架上工作时,有时你想更新框架当你做一个构建,和时间,当你不。因此,我只在发布配置中更改部署设置。所以:

As you work on your framework, there are times when you do want to update the framework when you do a build, and times when you don't. For that reason, I change the Deployment settings only in the Release Configuration. So:


  1. 双击框架目标,打开目标信息窗口并切换到Build选项卡。

  2. 在配置选择框中选择发布。

  3. 向下卷动至[部署]部分,并输入下列值:




部署位置= YES(单击复选框)

Deployment Location = YES (click the checkbox)

安装构建产品位置= /

Installation Build Products Location = /

安装目录= / Library / Frameworks

Installation Directory = /Library/Frameworks

安装构建产品位置作为安装的根。它的默认值是一些/ tmp目录:如果你不改变它到系统根目录,你永远不会看到你安装的框架,因为它隐藏在/ tmp。

The Installation Build Products Location serves as the root of the installation. Its default value is some /tmp directory: if you don't change it to the system root, you'll never see your installed framework since it's hiding in the /tmp.

现在你可以按照你喜欢的Debug配置工作,而不破坏你的其他项目,当你准备好发布所有你需要做的是切换到Release并做一个Build。

Now you can work on your framework as you like in the Debug configuration without upsetting your other projects and when you are ready to publish all you need to do is switch to Release and do a Build.

Xcode 4警告
由于切换到Xcode 4,我遇到了一些我的自定义框架的问题。大多数情况下,它们在GDB中链接警告,它们不会真正干扰框架的有用性,除非运行内置单元测试。我一周前向苹果提交了一份技术支持票,他们仍在调查。当我得到一个工作的解决方案,我会更新这个答案,因为这个问题已经证明很受欢迎(1 kViews和计数)。

Xcode 4 Warning Since switching to Xcode 4, I've experienced a number of problems with my custom framework. Mostly, they are linking warnings in GDB that do not really interfere with the usefulness of the framework, except when running the built-in unit-test. I have submitted a technical support ticket to Apple a week ago, and they are still looking into it. When I get a working solution I will update this answer since the question has proven quite popular (1 kViews and counting).

这篇关于最佳方式安装一个自定义可可框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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