I tried to delete the storyboard file and related Info.plist
entry but this time extension stopped working; it doesn't even launch from XCode.
The operation couldn’t be completed. (LaunchServicesError error 0.)
It is easy on the regular app (containing app) as we see it's entry point and application delegate, but how to do it on extensions too?
Remove
NSExtensionMainStoryboard
fromInfo.plist
AddNSExtensionPrincipalClass = YourViewController
Don't forget to create your own view in
loadView
FWIW, it didn't work for me until I added a prefix of the module name for my Swift view controller class, e.g.
That is probably because class lookup for Swift modules turns module names into prefix for class name. E.g. to create your class in code you would write
NSStringFromClass("SafariActionExtension.RootViewController")
, hence the prefix.I did the following steps:
Go to the NSExtension Dictionary, remove this key: NSExtensionMainStoryboard. Replace it with this key NSExtensionPrincipalClass and add your ViewController as the value, e.g. TodayViewController.
before:
after:
@objc (TodayViewController)
in my TodayViewController class (after the imports).The app should run now. But there were two other things I had to do:
So add these lines:
self.preferredContentSize = CGSizeMake(0, 200)