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)
}
Shan
  • 3,057
  • 4
  • 21
  • 33
  • 2
    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. – Afonso Tsukamoto Sep 29 '14 at 03:19
  • 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). – flohei Oct 04 '14 at 17:31
  • 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. – Shan Oct 04 '14 at 19:10
  • 1
    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. – Pandafox Oct 26 '14 at 13:30
  • 1
    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. – vbezhenar Oct 30 '14 at 21:02
  • Were you able to fix this? I am currently having the same issue right now – fphelp May 17 '20 at 02:09
  • 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/SpringBoard` – benc May 13 '23 at 20:13

15 Answers15

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

Jon
  • 3,208
  • 1
  • 19
  • 30
  • 36
    I have already done that. App Groups are ON for both the app and the extension target and they are using the same group. – Shan Sep 29 '14 at 20:09
  • 1
    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") – Jon Sep 29 '14 at 20:36
  • Yes Jon, I am. I have another sample app (http://www.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. – Shan Sep 29 '14 at 20:50
  • 1
    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. – Shan Sep 29 '14 at 20:56
  • Another UPDATE: Deleted that unused App Group from the Developer Portal, NO LUCK. – Shan Sep 29 '14 at 21:01
  • 3
    Same issue but this only happens in the emulator for me, works fine on a real device – mliu Dec 31 '14 at 17:49
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.

Sam Spencer
  • 8,492
  • 12
  • 76
  • 133
vhong
  • 594
  • 4
  • 27
  • Shan this would appear to be the correct answer, let's get it to the top of the page. – Stu P. Oct 30 '17 at 20:47
  • 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 regards – Andres Paladines Jul 11 '19 at 20:56
14

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

Maurice
  • 1,466
  • 1
  • 13
  • 33
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.

Phanith
  • 111
  • 1
  • 6
  • 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. – William T. Apr 28 '15 at 05:44
  • 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. – William T. Apr 28 '15 at 05:45
  • 1
    I added every constraint possible...still seeing this error – Oren Oct 29 '15 at 23:58
  • 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! – cdf1982 Apr 10 '16 at 07:49
  • 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. – kiddailey Jul 03 '20 at 00:58
9

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

pavelcauselov
  • 519
  • 5
  • 10
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

0yeoj
  • 4,500
  • 3
  • 23
  • 41
moonvader
  • 19,761
  • 18
  • 67
  • 116
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

bpolat
  • 3,879
  • 20
  • 26
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.

BrenBoh
  • 59
  • 1
  • 1
    I was experiencing this issue when trying to activate a keyboard extension and this solution resolved my issue. Many thanks, upvoted – Gareth Clarke Feb 23 '21 at 12:30
2

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

Ramakrishna
  • 712
  • 8
  • 26
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)
}
Marco
  • 14,977
  • 7
  • 36
  • 33
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, ...

phuongle
  • 1,166
  • 11
  • 17
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.

joshLor
  • 1,034
  • 1
  • 12
  • 27
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.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
-3

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

Undo
  • 25,519
  • 37
  • 106
  • 129
BillChan
  • 85
  • 1
  • 3
-4

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

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129