xcode iOS 8 Today Extension 无法在设备上运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25837479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:33:21  来源:igfitidea点击:

iOS 8 Today Extension not working on device

iosxcodeios8ios-app-extension

提问by Jarryd Baillie

When I run my Today Extension on the simulator everything works fine and it displays the following as expected:

当我在模拟器上运行我的 Today Extension 时,一切正常,并按预期显示以下内容:

enter image description here

在此处输入图片说明

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)上运行它时,主体不会显示(不要介意标题和图标,那已经改变了)

enter image description here

在此处输入图片说明

I attached the debugger to my extension and I got this:

我将调试器附加到我的扩展中,我得到了这个:

enter image description here

在此处输入图片说明

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.

我删除了 Today Extension 的所有代码,以检查我的代码是否有问题,但没有任何变化,所以我怀疑我的代码有问题。任何有关如何解决此问题的建议将不胜感激。

(I do have app groups enabled if thats of any significance)

(如果这有任何意义,我确实启用了应用程序组)

采纳答案by Jarryd Baillie

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”

回答by Exile3daime

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 会给你一个崩溃。

回答by artud2000

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

在小部件目标上

Build Settings > Valid Architectures

构建设置 > 有效架构

I was having just armv7 and armv7s. I added arm64 and it worked like charm in my 5s device

我只有 armv7 和 armv7s。我添加了 arm64,它在我的 5s 设备中发挥了很大的作用

回答by Jas_meet

Few points to remember while using app extensions

使用应用扩展时需要记住的几点

  • Bundle Identifier for the target extension should be com.companyName.AppName.ExtensionName

  • You need to have separate AppID for the target extension, with identifier specified as com.companyName.AppName.ExtensionNameand create provisioning profile with this AppID.

  • Also, the appGroupID created should be embedded in both the AppIDs(for application as well as extension).

  • 目标扩展的捆绑标识符应该是com.companyName.AppName.ExtensionName

  • 您需要为目标扩展使用单独的 AppID,将标识符指定为com.companyName.AppName.ExtensionName并使用此 AppID 创建配置文件。

  • 此外,创建的 appGroupID 应该嵌入到 AppID 中(对于应用程序和扩展程序)。

回答by Nimisha Patel

In my case I set preferred content size and it is starting working on device

就我而言,我设置了首选内容大小,它开始在设备上工作

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

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

回答by Zatman

I had an issue using custom ViewController in my Share Extension. 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.

我在共享扩展中使用自定义 ViewController 时遇到问题。事实证明,Extension 迷你应用程序中的资源是有限的,因此当我的 Extension 生成缩略图时,由于使用了太多后台线程,它导致该扩展程序崩溃。将缩略图生成减少到一个,解决了这个问题。

The confusing part was that this limitation was not seen in Simulator, only on a real device.

令人困惑的部分是这个限制在模拟器中看不到,只有在真实设备上才能看到。

回答by Vilém Kurz

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.
  • the widget does not receive core data changes notifications
  • do not call NCWidgetController.widgetController().setHasContent from widgetPerformUpdateWithCompletionHandler. The best place to use it (mostly) is your containing app, not the widget itself.
  • 在模拟器 viewDidLoad 每次都被调用,在设备上,视图被加载一次,只有 viewWillAppear 被调用。
  • 小部件不接收核心数据更改通知
  • 不要从 widgetPerformUpdateWithCompletionHandler 调用 NCWidgetController.widgetController().setHasContent。使用它的最佳位置(主要是)是您的包含应用程序,而不是小部件本身。

hope this helps someone

希望这有助于某人

回答by Ersin Sezgin

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 viewdidloadviewwillappearand - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandlermethods. Hope it helps.

由于您没有分享任何代码,我无法为您提供具体答案。请尝试使用以下步骤调试您的小部件 Debug->Attach to Process->(从菜单中选择您的小部件)并调试您的viewdidload viewwillappear- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler方法。希望能帮助到你。