Today Extension Failed to inherit CoreMedia permissions from
SwiftIos App-ExtensionIos8 Today-WidgetSwift Problem Overview
I am trying to add a Today Extension in Swift to my Objective-C app. I keep getting this message in my debugger log: Failed to inherit CoreMedia permissions from 3005: (null)
. The number ex. 3005 is different every time. I am reading from NSUserDefaults from within the widget but I am reading/writing in the app itself. The only code in my TodayViewController is this the following:
override func viewDidLoad() {
super.viewDidLoad()
let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
totalLabel.text = formatter.stringFromNumber(0)
coinsLabel.text = formatter.stringFromNumber(0)
formatter.maximumFractionDigits = 0
billsLabel.text = formatter.stringFromNumber(0)
}
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
return UIEdgeInsetsMake(8.0, 16.0, 8.0, 16.0)
}
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)!) {
// Perform any setup necessary in order to update the view.
// If an error is encountered, use NCUpdateResult.Failed
// If there's no update required, use NCUpdateResult.NoData
// If there's an update, use NCUpdateResult.NewData
completionHandler(NCUpdateResult.NewData)
}
Swift Solutions
Solution 1 - Swift
I believe the "Failed to inherit CoreMedia permissions from NNNN" warning is related to App Groups when you are creating an App Extension. Both your containing application and your app extension need to have the App Groups capability turned ON and using the same app group container ID (example: group.com.yourdomain.yourappname). App Groups are used to allow multiple apps access to shared containers and allow additional interprocess communication between apps.
Solution 2 - Swift
First, click on Assets.xcassets
Second, click on Target Membership, check both your app and widget to allow widget access your resources.
After that, run your Widget again, it should now work fine.
Solution 3 - Swift
I had the same Log output. Cleaning (Cmd + Shift + K)
solved it for me.
Solution 4 - Swift
I run into that problem too, and The only solution I've solve was adding Vertical and Horizontal constrain of the every single object on storyboard.
Solution 5 - Swift
Check in mainstoryboard of today extension, viewcontroller with "Is Initial View Controller" option was enabled.
Solution 6 - Swift
After doing most of things that were mentioned in answers on this question and still getting errors with today widget - I found something that worked for me.
Open your widget target Build Settings and search for Always Embed Swift Standard Libraries. Select Yes.
Hope this works for you if nothing else didn't help
Solution 7 - Swift
Very misleading error. As its mentioned above. Select your view controller and add missing constraint or add constraint to yourself to fix the issue.
Solution 8 - Swift
I found that if you are using a StoryBoard you will need to go into info.plist and remove the property NSExtensionPrincipalClass
. After that the extension started loading just fine.
Solution 9 - Swift
I had the same issue while running my extension. In my case, it was solved by running the extension in the real device.
Solution 10 - Swift
This hit me because I'd had a custom consolidated init(nibName:bundle:coder:)
method in my view controller, and had implemented initWithCoder
like this to satisfy Swift:
required init?(coder aDecoder: NSCoder) {
self.init(nibName: nil, bundle: nil, coder: aDecoder)
}
I fixed the issue by making that implementation call super.init(coder:)
instead:
required init?(coder aDecoder: NSCoder) {
// [...setting some variables...]
super.init(coder: aDecoder)
}
Solution 11 - Swift
I resolved my case by: Turn on App Groups for both container and extension app. And delete all hidden UIKit controls as UILabel, UIView, ...
Solution 12 - Swift
I ran into this problem as well. The problem for me was that I was running two programs at once on my simulator. After I stopped one of them the error message went away. Hope it helps.
Solution 13 - Swift
Here's my experience with this error message. I had a storyboard with 4 ViewControllers in it. I did a refactor extract on all of them, so now I have 5 storyboards, 4 of which had view controllers and the original, "main," one only had storyboard references in it.
Well... that's bad. Don't do that.
Everything worked when I kept the initial storyboard in the original storyboard file, so I didn't refactor just one of them.
Solution 14 - Swift
Make sure the param of [[NSUserDefaults alloc] initWithSuiteName:APP_GROUP]
matches the group name you defined.
Solution 15 - Swift
It's the simulator's problem, try some real devices.