首页 > 解决方案 > 无法在捆绑包中加载 NIB - pod 中有自己的框架

问题描述

我已经开发了一个框架并将其添加到 pod 中,以便开发人员可以使用 pod 安装它,就完成了。但是当开发人员尝试加载控制器时,他们会收到此错误

由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在包中加载 NIB:“NSBundle(已加载)”,名称为“XViewController”

在 google/stackoverflow 上找到了一些帮助,但没有用 Bundle code 是

static var framework: Bundle? {
        let currentBundle = Bundle.init(for: XViewController.self)
        if let path = currentBundle.path(forResource: "Resources", ofType: "bundle") {
            return Bundle(path: path)
        }
        return currentBundle
}

pod 仅包含一个.framework文件

podspec 文件是

Pod::Spec.new do |s|
  s.name           = 'XXSDK'
  s.version        = '1.0.1'
  s.summary        = 'A tool to enforce Swift style and conventions.'
  s.homepage       = 'https://example.com/sdkportal/'
  s.license        = { :type => 'MIT' }
  s.author         = { 'XXX' => 'abc@gmail.com' }
s.source            = { :http => 'fakeurl/XXSDKframework.zip' }
    s.ios.deployment_target = '10.0'
    s.ios.vendored_frameworks = 'XXSDK.framework'
  s.dependency "RealmSwift"
  s.dependency "Alamofire"
  s.dependency "MBProgressHUD"
end

.framework如果我仅通过插入文件来使用,一切正常XXSDK.framework,但如果我使用 pod,则会导致上述问题。

提前致谢。

标签: iosswiftcocoapods

解决方案


推荐阅读