【发布时间】:2019-05-06 22:15:01
【问题描述】:
我有一个包含两个故事板的框架:StoryBoard_A.storyboard 和 StoryBoard_B.storyboard。 我可以到达 StoryBoard_A,但不能到达 StoryBoard_B
我在我的主项目中使用我的框架作为一个 pod。 在我的框架 podspec 文件中,我有:
s.source_files = "myFramework/**/*.{swift}"
s.resource_bundles = { 'myFramework' => ['myFramework/**/*.{storyboard,xib,xcassets}'] }
我知道两个故事板都在 myFramework 包中,因为:
- 在 myFramework Build Phases 的 Copy Bundle Resources 下,我可以看到它们都包含在内。
- 在 myFramework.framework 中我可以看到:StoryBoard_A.storyboardc 和 StoryBoard_B.storyboardc
- 当我将 myFramework 'pod install' 作为开发 pod 时,我可以在主项目的项目导航器中看到两个故事板
在 myFramework 中,从 ViewController_1 我从 StoryBoard_A.storyboard 启动 ViewController_a,从 StoryBoard_B.storyboard 启动 ViewController_b。 我使用相同的技术:
let podBundle = Bundle(for: ViewController_1.self)
let bundleURL = podBundle.url(forResource: "myFramework", withExtension: "bundle")
let bundle = Bundle(url: bundleURL!)!
let storyBoard = UIStoryboard(name: "StoryBoard_A", bundle: bundle)
let viewController_a = storyBoard.instantiateViewController(withIdentifier: "ViewController_a_id") as? ViewController_a
但当我这样做时:
let storyBoard = UIStoryboard(name: "StoryBoard_B", bundle: bundle)
let viewController_b = storyBoard.instantiateViewController(withIdentifier: "ViewController_b_id") as? ViewController_b
应用程序在第二行崩溃并出现以下错误:
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“在捆绑包中找不到名为“StoryBoard_B”的情节提要...
我错过了什么?
谢谢
【问题讨论】:
标签: ios swift frameworks storyboard cocoapods