Today Extension Failed to inherit CoreMedia permissions from

∥☆過路亽.° 提交于 2019-11-28 16:10:31

问题


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)
}

回答1:


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.




回答2:


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.




回答3:


I had the same Log output. Cleaning (Cmd + Shift + K) solved it for me.




回答4:


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.




回答5:


Check in mainstoryboard of today extension, viewcontroller with "Is Initial View Controller" option was enabled.




回答6:


Very misleading error. As its mentioned above. Select your view controller and add missing constraint or add constraint to yourself to fix the issue.




回答7:


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




回答8:


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)
}



回答9:


I had the same issue while running my extension. In my case, it was solved by running the extension in the real device.




回答10:


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.




回答11:


I resolved my case by: Turn on App Groups for both container and extension app. And delete all hidden UIKit controls as UILabel, UIView, ...




回答12:


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.




回答13:


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.




回答14:


Make sure the param of [[NSUserDefaults alloc] initWithSuiteName:APP_GROUP] matches the group name you defined.




回答15:


It's the simulator's problem, try some real devices.



来源:https://stackoverflow.com/questions/26091463/today-extension-failed-to-inherit-coremedia-permissions-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!