Bernhard Harrer
Bernhard Harrer

Reputation: 125

Instantiate Storyboard from local Swift Package

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

Upvotes: 1

Views: 330

Answers (1)

RelativeJoe
RelativeJoe

Reputation: 5104

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

Upvotes: 3

Related Questions