Home > database >  Instantiate Storyboard from local Swift Package
Instantiate Storyboard from local Swift Package

Time:06-21

I try to instatiat a ViewController vom a local SPM Package but I always get the error "Could not find a storyboard".

let myViewController = UIStoryboard(
      name: "MyStoryboard",
      bundle: Bundle(
              url: Bundle.main.url(
                   forResource: "myModule_myModule",
                   withExtension: "bundle"
              )!
      )
).instantiateViewController(withIdentifier: "MyViewController")

This code works when using it as an remote package, but not when dragging it to Xcode and use it local.

Thanks Bernhard

CodePudding user response:

Unlike Remote Packages, When adding a Local one Xcode doesn't prompt you to add it to a target. Hence you need to add it manually in your Target's General settings, under Frameworks, Libraries, and Embedded Content

  • Related