简体   繁体   English

iOS 8 Today Extension不在设备上工作

[英]iOS 8 Today Extension not working on device

When I run my Today Extension on the simulator everything works fine and it displays the following as expected: 当我在模拟器上运行我的今日扩展时,一切正常,它会按预期显示以下内容:

在此输入图像描述

However when I run it on my devices (iPod touch and iPhone 5s) the body won't show (don't mind the title and icon, that was changed) 但是,当我在我的设备上运行它(iPod touch和iPhone 5s)时,机身将无法显示(不介意标题和图标,已更改)

在此输入图像描述

I attached the debugger to my extension and I got this: 我将调试器附加到我的扩展程序,我得到了这个:

在此输入图像描述

I have no idea what all of this means... 我不知道所有这些意味着什么......

I removed all code for the Today Extension to check if there was a problem with my code and nothing changed so I doubt theres a problem with my code. 我删除了今天扩展的所有代码,以检查我的代码是否有问题,没有任何改变,所以我怀疑我的代码是否有问题。 Any suggestions on how to fix this would be greatly appreciated. 任何有关如何解决这个问题的建议将不胜感激。

(I do have app groups enabled if thats of any significance) (如果有任何意义,我确实启用了应用程序组)

Make sure extension target version 确保扩展目标版本

Please make sure your extension target version is correct. 请确保您的扩展目标版本正确无误。 Xcode'd give you the highest version by default such as 8.3, and if your iOS version is lower than it, Xcode'd give your a crash. Xcode默认为你提供最高版本,如8.3,如果你的iOS版本低于它,Xcode会给你一个崩溃。

I found out that I was accessing my app group with the wrong suitename. 我发现我正在使用错误的联名访问我的应用程序组。 Just make sure you access the app group with "group.something.something" not just "something.something" 只需确保您使用“group.something.something”访问应用程序组,而不仅仅是“something.something”

I found the solution for my case. 我为我的案子找到了解决方案。 I just had to specify arm64 as valid architecture for the widget target. 我只需将arm64指定为小部件目标的有效架构。

On the Widget Target 在Widget目标上

Build Settings > Valid Architectures 构建设置>有效的体系结构

I was having just armv7 and armv7s. 我只有armv7和armv7s。 I added arm64 and it worked like charm in my 5s device 我添加了arm64,它在我的5s设备中起到了魅力的作用

Few points to remember while using app extensions 使用应用扩展程序时要记住几点

  • Bundle Identifier for the target extension should be com.companyName.AppName.ExtensionName 目标扩展的Bundle Identifier应为com.companyName.AppName.ExtensionName

  • You need to have separate AppID for the target extension, with identifier specified as com.companyName.AppName.ExtensionName and create provisioning profile with this AppID. 您需要为目标扩展具有单独的AppID,并将标识符指定为com.companyName.AppName.ExtensionName,并使用此AppID创建配置文件。

  • Also, the appGroupID created should be embedded in both the AppIDs(for application as well as extension). 此外,创建的appGroupID应嵌入AppID(用于应用程序和扩展)。

Since you didn't share any piece of code, I cannot help you with a specific answer. 由于您没有共享任何代码,我无法帮助您获得具体答案。 Please try to debug your widget by using following steps Debug->Attach to Process->(select your widget from the menu) and debug your viewdidload viewwillappear and - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler methods. 请尝试使用以下步骤调试窗口小部件:Debug-> Attach to Process - >(从菜单中选择窗口小部件)并调试viewdidload viewwillappear- (void)widgetPerformUpdateWithCompletionHandler:(void(^)(NCUpdateResult))completionHandler方法。 Hope it helps. 希望能帮助到你。

The sources of my problems: 我的问题的根源:

  • on simulator viewDidLoad was called each time, on the device the view is loaded once and only viewWillAppear is called. 在模拟器上,每次调用viewDidLoad,在设备上加载一次视图,只调用viewWillAppear。
  • the widget does not receive core data changes notifications 窗口小部件不会收到核心数据更改通知
  • do not call NCWidgetController.widgetController().setHasContent from widgetPerformUpdateWithCompletionHandler. 不要从widgetPerformUpdateWithCompletionHandler调用NCWidgetController.widgetController()。setHasContent。 The best place to use it (mostly) is your containing app, not the widget itself. 使用它的最佳位置(主要是)是包含应用程序,而不是小部件本身。

hope this helps someone 希望这有助于某人

在我的情况下,我设置首选内容大小,它开始在设备上工作

self.preferredContentSize = CGSizeMake(UIScreen.mainScreen().nativeBounds.width, 100.0)

I had an issue using custom ViewController in my Share Extension. 我在共享扩展中使用自定义ViewController时遇到问题。 It turns out that the resources are limited in Extension mini-apps, so when my Extension was generating thumbnails, it crashed the extension because too many background threads were being used. 事实证明,扩展迷你应用程序中的资源有限,所以当我的扩展程序生成缩略图时,它会因为使用了太多的后台线程而导致扩展程序崩溃。 Reducing thumbnail generation to a single one at a time fixed the issue. 将缩略图生成一次缩减为一个可以解决问题。

The confusing part was that this limitation was not seen in Simulator, only on a real device. 令人困惑的部分是模拟器中没有出现这种限制,只能在真实设备上看到。

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

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