Search code examples
swifttoday-extension

How to access classes in the main app from a today extension


I'm building an app in Swift 4 and now I am adding a today extension to the app. I want to access a class from the main app, a repository class, in the today extension view controller.

What do I need to do to be able to create an instance of my repository class in the today extension view controller?

The repository class is public, has a public init and has public methods.

The only solution I have found is to put the repository in a separate framework, but that seems like a big step for my small app.


Solution

  • Put the class inside a swift file , click it and check the today extension target

    enter image description here

    //

    enter image description here