Sanket Pandya
Sanket Pandya

Reputation: 1095

"InvalidArgumentException" Could not find a storyboard named "Details" in bundle NSBundle

I have created a Cocoa Touch framework with unit test target. Now I am trying to build and run my unit test cases which has code to initiate storyboard. But it is not able to load storyboard files and throwing me the error.

"InvalidArgumentException" Could not find a storyboard named "Details" in bundle NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Agents> (loaded).

Here is my code

UIStoryboard *sb =
  [UIStoryboard storyboardWithName:"Details" bundle:nil];

It is working when I provide the bundleID explicitly like

UIStoryboard *sb =
[UIStoryboard storyboardWithName:"Details" bundle:[NSBundle bundleWithIdentifier:@"com.abc.xyz"]];

So I am not sure why it is not taking the bundle implicitly. What configuration do I need to change. Any help would be appreciated. Thanks!

Upvotes: 3

Views: 1499

Answers (2)

Try this (in my obj c may be mistakes):

UIStoryboard *sb =
  [UIStoryboard storyboardWithName:"Details" bundle: Bundle(for: Self.self)]

In swift:

let storyboard = UIStoryboard(name: "Details", bundle: Bundle(for: Self.self))

In fact you need to bundle storyboard to your framework

Upvotes: 0

Ronak Chaniyara
Ronak Chaniyara

Reputation: 5436

Add your Details. storyboard the file under "Copy Bundle Resources"

Go to Xcode project icon and navigate to: Targets > Build Phases > Copy Bundle Resources

Click the + button at the bottom to add the storyboard file.

OR

Check for target membership in File Inspector for storyboard if is checked. Make sure you have that value checked.

Upvotes: 1

Related Questions