iOS 8 beta - Today 扩展无法识别嵌入式框架 [英] iOS 8 beta - Today extension doesn't recognize embedded framework

查看:20
本文介绍了iOS 8 beta - Today 扩展无法识别嵌入式框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个应用程序,它也有一个 Today 扩展(或小部件).Apple 推荐的在扩展程序和包含应用程序之间共享代码的方法是将共享代码放在应用程序和扩展程序都可以使用的嵌入式框架中.所以据我了解,我应该编写共享代码并使共享代码以框架为目标,然后让应用程序和扩展都将框架声明为依赖项.但是,在实践中,我发现虽然应用程序可以很好地识别框架,但 Today 扩展程序却不能.

I'm writing an app which also has a Today extension (or widget). Apple's recommended method of sharing code between extensions and containing apps is to put the shared code inside of an embedded framework which both the app and extension can use. So as I understand it, I'm supposed to write shared code and make the shared code target the framework, and then have the app and extension both declare the framework as a dependency. However, in practice, I'm finding that while the app recognizes the framework just fine, the Today extension does not.

更具体地说:我将一个简单的表格视图放在我的 Today 扩展(我将其称为Widget")和我的应用程序中的一个选项卡(我将其称为App")中的控制器中,然后是一个带有共享代码的框架(我将称之为框架").Widget 带有一个 TodayViewController,其中包含表格视图.这个表视图有一个自定义单元格,我称之为 CalendarCell.所以相关的共享类/文件是:

To be more specific: I'm putting a simple table view in a controller inside of both my Today extension (which I will call 'Widget') and as a tab in my app (which I will call 'App'), and then a framework (I'll call 'Framework') with shared code. Widget comes with a TodayViewController which contains the table view. This table view has a custom cell I'm calling CalendarCell. So the relevant shared classes/files are:

  • TodayViewController.h/m
  • CalendarCell.xib
  • CalendarCell.h/m

当然,我还有我的小部件故事板和应用故事板,它们不共享.

And then, of course, I have my Widget storyboard and App storyboard, which are not shared.

因此,在我的 App 目标构建阶段,我将 Framework 作为目标依赖项,并将 Widget 作为目标依赖项(当我创建目标时就出现了这种情况,删除它似乎没有任何帮助).同样,在 Widget 目标构建阶段,我将 Framework 作为目标依赖项.框架将 TodayViewController.m 和 CalendarCell.m 列为编译源,CalendarCell.xib 作为捆绑资源.

So, in my App target build phase, I have Framework as a target dependency and also Widget as a target dependency (it came that way when I created the target, and removing it doesn't seem to have helped anything). Similarly, in the Widget target build phase, I have Framework as a target dependency. Framework lists TodayViewController.m and CalendarCell.m as compile sources and CalendarCell.xib as a bundle resource.

所以这里出了问题:如果 Widget 没有列出 CalendarCell.m、TodayViewController.m 和 CalendarCell.xib 作为编译源和捆绑资源,那么这个小部件就不能工作.具体来说,如果 TodayViewController.m 未列出,则应用程序甚至无法在模拟器中运行(我收到相同的错误 这个人得到).如果 TodayViewController.m 已列出,但未列出任何其他源文件/资源​​,那么我会得到一个没有正文的扩展名(与 这个其他人得到).请注意,App 确实可以很好地识别框架,并且不必将这些文件列为编译源或捆绑资源 - 只是 Widget 失败了.

So here's what goes wrong: if Widget doesn't also list CalendarCell.m, TodayViewController.m, and CalendarCell.xib as compile sources and bundle resources, then the widget just doesn't work. Specifically, if TodayViewController.m isn't listed, then the app fails to even run in the simulator (I get the same error this person got). If TodayViewController.m is listed but any of the other source files / resources aren't, then I get an extension with no body (same as this other person got). Note that App does recognize the framework just fine and doesn't have to list these files as compile sources or bundle resources - it's just the Widget that fails.

如果有人对此有想法,我将不胜感激.Xcode 6/iOS 8 错误?还是我做错了什么?

If anyone has thoughts on this, I'd appreciate it. An Xcode 6 / iOS 8 bug? Or something I'm doing wrong?

推荐答案

实际上你是在 Target Dependencies 中添加框架.那是错误的.Target Dependencies 是我们应该指定一些其他目标的地方,这些目标应该被编译以运行我们的主目标.

Actually you are adding the framework in Target Dependencies. That's wrong. Target Dependencies is the place where we should specify some other targets which should get compile in order to run our main target.

将您的框架添加到 Link Binary With Libraries 中,如有必要,请在构建设置中设置框架搜索路径

Add your framework in to Link Binary With Libraries , if necessary set framework search path in build settings

这篇关于iOS 8 beta - Today 扩展无法识别嵌入式框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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