Begin by adding Nami.framework to the extension target as you normally would, by dragging it into the binaries & frameworks section.

That adds the Nami.framework as a binary, but for an extension there is one more step that needs to be done - the framework itself has to be copied into the extension, and signed.  In order to do that, go the the Build Phases tab of your Extension project, and use the + button to add a new "Copy Files" phase, in which you add Nami.framework.  See the screenshot below.

The SDK instructions say to add some code to main.swift and the app delegate, which you can still do for your main project.  For an extension, you also need to add some specific startup and shutdown code so Nami can operate properly.  In your extension
MSMessagesAppViewController  add the following methods:

import Nami // top of file

// These go inside the MSMessagesAppViewController
override func willBecomeActive(with conversation: MSConversation) {
     super.willBecomeActive(with: conversation)
     NamiExtensionManager.shared.startupNamiFromMessageExtension(messageViewController: self, applicationGroupName: nil)      
     Nami.shared.configure(appID: "YOU_APP_ID_HERE")
override func didResignActive(with conversation: MSConversation) {

If you have a sharedApplicationGroup  defined between your app and the iMessage extension, enter the name of that group in the startupNamiFromMessageExtension call so that it can properly share information with the main application.

Now you can add whatever other code you like, and Nami should behave normally within the extension.


If you want to try manually raising a paywall to test the framework, you can add this code in viewDidLoad  of your MessagesViewController :

Nami.shared.doConfigBasedWork {
    DispatchQueue.main.asyncAfter(deadline: .now()+4 ) {
    NamiPaywallManager.shared.presentLivePaywall(fromVC: self)
Did this answer your question?