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

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

问题描述

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

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.

更具体一点:我放了一个在我的今日扩展(我将称之为'小部件')和我的应用程序中的选项卡(我称之为'应用程序')中的控制器内的简单表视图,然后是一个框架(我称之为'框架' )共享代码。 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

然后,当然,我有我的Widget故事板和app storyboard,它们是不共享的。

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

因此,在我的App目标构建阶段,我将Framework作为目标依赖项,并将Widget作为目标依赖项(它来了)那种方式,当我创建目标,并删除它似乎没有任何帮助)。类似地,在Widget目标构建阶段,我将Framework作为目标依赖项。 Framework将TodayViewController.m和CalendarCell.m列为编译源,将CalendarCell.xib列为bundle资源。

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.

将你的框架添加到链接二进制文件库,如有必要,在构建设置中设置框架搜索路径

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

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

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