问题
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)
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)
回答1:
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.
回答2:
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"
回答3:
I found the solution for my case. I just had to specify arm64 as valid architecture for the widget target.
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
回答4:
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.ExtensionName and create provisioning profile with this AppID.
Also, the appGroupID created should be embedded in both the AppIDs(for application as well as extension).
回答5:
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. Hope it helps.
回答6:
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.
hope this helps someone
回答7:
In my case I set preferred content size and it is starting working on device
self.preferredContentSize = CGSizeMake(UIScreen.mainScreen().nativeBounds.width, 100.0)
回答8:
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.
The confusing part was that this limitation was not seen in Simulator, only on a real device.
来源:https://stackoverflow.com/questions/25837479/ios-8-today-extension-not-working-on-device