Today Extension Failed to inherit CoreMedia permissions from
Asked Answered
M

15

70

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)
}
Methaemoglobin answered 29/9, 2014 at 1:44 Comment(7)
I'm having the same problem. I also noticed that after that, the memory consumed by my widget scales to almost 1gb, which is really strange since I only do one simple network request and is not even executed.Chant
Me too. But I'm not using Swift at all and for me it appears when accessing a method on one of my NSManagedObject subclasses (which actually seems to be interpreted as an NSManagedObject, which is weird enough on its own).Lymph
I checked with Xcode 6.1 Beta and the message is still there. I don't see any runtime problems with my Extensions and the debugger doesn't specifically say that this is a warning. Hoping Apple won't reject the App when I submit it for review.Methaemoglobin
I'm having a similar problem. The error will probably go away if you remove "widgetMarginInsetsForProposedMarginInsets". (I'm getting the same error when using "preferredContentSize"). Still haven't figured out how to actually solve this though.Diba
I'm developing custom keyboard and I'm facing this message from time to time. I've found that if I set "Team" in "General" tab of target settings both for my containing app target and extension target to "None" (and clean after this change), this log message doesn't appear. I believe it's bug in iOS.Scriabin
Were you able to fix this? I am currently having the same issue right nowApthorp
The number is different because it is probably the PID of Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/CoreServices/SpringBoard.app/SpringBoardEpisiotomy
C
54

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.

Capabilities should look like this

Christenson answered 29/9, 2014 at 16:14 Comment(6)
I have already done that. App Groups are ON for both the app and the extension target and they are using the same group.Methaemoglobin
Not sure then. I received the warning after creating a template app extension. I had added no custom code. Turning on App Groups resolved the issue for me. Are you specifying suiteName when reading from NSUserDefaults? E.g. var userDefaults = NSUserDefaults(suiteName: "group.com.yourdomain.yourappname")Christenson
Yes Jon, I am. I have another sample app (raywenderlich.com/83809/ios-8-today-extension-tutorial) that is all Swift (both the containing app and Extension) so I am ruling out that it is due to a mix of Obj-C and Swift. The sample app that I mentioned uses a custom framework instead of App Groups and it also gets that message in the log. Hoping this is just an Xcode bug. Btw I am using version 6.0.1.Methaemoglobin
One more thing I should mention: There was an App Group I created but named it incorrectly. I have that unused group unchecked for both targets but I can't find a way to delete it.Methaemoglobin
Another UPDATE: Deleted that unused App Group from the Developer Portal, NO LUCK.Methaemoglobin
Same issue but this only happens in the emulator for me, works fine on a real deviceMaccabees
H
16

First, click on Assets.xcassets

First, Click on Assetes.xcassets

Second, click on Target Membership, check both your app and widget to allow widget access your resources.

Second, Click on Target Membership

After that, run your Widget again, it should now work fine.

Hone answered 4/3, 2016 at 11:5 Comment(2)
Shan this would appear to be the correct answer, let's get it to the top of the page.Dragonet
For me the problem is taht i was sharing information from one class in my app to my extension. The probles was resolved when i selected both targets for that file. Best regardsFillender
R
14

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

Romine answered 29/10, 2014 at 13:10 Comment(4)
I did it after add app group, so I don't know it helps with this step. But thanks for solution ;)Cauley
Yeah it's just weird sometimes!Romine
Unfortunately, sometimes the problem returnsCauley
Info.plist there is a entry similar to bundle display nameRomine
D
9

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.

Dorpat answered 24/2, 2015 at 10:34 Comment(5)
Oddly enough, he's right. I was getting this same error and tried everything here but nothing worked. I saw this and simply selected the Today view and choose "Add Missing Constraints". Then the error went away and the Today extension now runs.Tumult
Follow up, I just cleared the constraints and now I'm getting the CoreMedia permission error again... so this error is definitely constraint related. Also confirmed that the AppGroup step above is necessary, when I turn that off I get the error again.Tumult
I added every constraint possible...still seeing this errorCrowbar
Constraint-related for me too. I know I shouldn't comment just to say "me too", but since this answer is pretty strange and apparently doesn't make sense, I was overlooking it, even though that's the only one that actually worked for me!Ebonyeboracum
Can confirm - to be specific, the error only occurred in the simulator. On the device it worked fine. Adding constraints to all objects caused it to work in the simulator as well. I did not have to add or enable app groups.Demean
B
9

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

Botany answered 10/12, 2016 at 19:19 Comment(0)
L
6

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

Leeds answered 6/4, 2018 at 12:45 Comment(0)
R
4

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

enter image description here

Rima answered 13/11, 2015 at 11:57 Comment(0)
R
4

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.

Rattletrap answered 25/1, 2017 at 16:10 Comment(1)
I was experiencing this issue when trying to activate a keyboard extension and this solution resolved my issue. Many thanks, upvotedGloria
S
2

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

Scandian answered 24/1, 2017 at 7:19 Comment(0)
H
2

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)
}
Helices answered 28/3, 2019 at 20:24 Comment(0)
T
0

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

Thump answered 22/12, 2015 at 23:23 Comment(0)
F
0

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.

Fiendish answered 11/2, 2017 at 16:55 Comment(0)
N
0

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.

Nosey answered 30/3, 2017 at 17:13 Comment(0)
S
-3

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

Squander answered 18/12, 2014 at 14:32 Comment(0)
S
-4

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

Santiago answered 19/11, 2015 at 9:57 Comment(4)
Try to give a more description and complete answer, if possible with example and codes.Anurous
For me, this error only appeared in simulator, and not when I side-load a device.Episiotomy
Weird that people massively upvote a solution like "just clean-build it", and downvote this.Kelwin
Well, at the end of the day it worked for me. Completely agree with @KelwinStirrup

© 2022 - 2024 — McMap. All rights reserved.