Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing an iOS 8 share extension without a storyboard

Does anyone know of a good way to write an iOS 8 share extension without the MainInterface.storyboard that comes with the template?

When I delete the file or remove the NSExtensionMainStoryboard from Info.plist, the extension stops working (nothing happens when you tap on the button in the share pane). We tried replacing NSExtensionMainStoryboard with NSExtensionPrincipalClass which also didn't work.

Any ideas?

like image 263
Steve Gattuso Avatar asked Jun 25 '14 18:06

Steve Gattuso


People also ask

How do I add an extension to an Iphone share?

Add a Share Extension to your projectGo into the project section, click on the + button and select the Share extension from the list. Just call it Share or whatever name you prefer. The system asks you if you want to activate the Share scheme , just select Activate .

What are iOS extensions?

App Extensions are an iOS feature that allows developers to extend the functionality and content of their app beyond the app itself, making it available to users in other apps or in the main operating system.


1 Answers

Figured it out!

Turns out there's a weird module naming thing going on in Swift, so you can fix it by adding an @objc name to the class:

@objc(PrincipalClassName)  class PrincipalClassName: UIViewController { ... 

and then set the NSExtensionPrincipalClass key to PrincipalClassName.

like image 154
Steve Gattuso Avatar answered Oct 05 '22 22:10

Steve Gattuso