Cocoapod依赖关系不再捆绑在应用

时间:2018-01-24 16:00:03

标签: cocoapods

我有一组项目,例如下面的Podfile,它们共享两个常见的开发窗口。

platform :ios, '11.2'
use_frameworks!

workspace "AppWorkspace"

target 'App' do
    project "App/app"
    pod 'PromiseKit', :inhibit_warnings => true
    pod 'LibKit', :path => '../LibKit'
    pod 'LibUI', :path => '../LibUI'

    target "AppBeta" do
        inherit! :search_paths
    end
end

文件系统的布局如下:

  • AppProject
    • 应用
  • LibKit
  • LibUI

为简洁起见,这里是LibUI的Podspec,因为它还包含资源包:

Pod::Spec.new do |s|
  s.name             = 'LibUI'
  s.module_name      = 'LibUI'
  s.version          = '0.1.1'
  s.summary          = 'A collection of UI components.'

  s.description      = <<-DESC
             A collection of shared UI components
  DESC

  s.homepage         = 'https://github.com/Foo/LibUI'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'ME' => '------@---------.com' }
  s.source           = { :git => 'https://github.com/Foo/LibUI.git' }

  s.platform = :ios
  s.ios.deployment_target = '10.0'
  s.swift_version = "4.0"

  s.source_files = 'LibUI/Classes/**/*'
  s.resource_bundles = {
     'LibUIBundle' => ['LibUI/Assets/*.xib', 'LibUI/Assets/*.xcassets']
  }
  # s.public_header_files = 'Pod/Classes/**/*.h'
  s.frameworks = 'UIKit'
end

在构建和运行应用程序时,我遇到了这个错误:

dyld: Library not loaded: @rpath/PromiseKit.framework/PromiseKit
Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/486B5EFB-6F18-45A7-AA78-07D18C0909FC/data/Containers/Bundle/Application/830433F4-AA5A-402E-9A81-E2A7C6A61EA7/AppBeta.app/AppBeta
Reason: image not found

每个pod都会重复此错误,直到我将Pods项目中的Mach-O Type版本设置从Dynamic Library更改为Static Library为止。

然而,我遇到了以下一组错误:

Unknown class _TtC8LibUI18SVTabBarController in Interface Builder file.
Unknown class _TtC8LibUI22SVNavigationController in Interface Builder file.
Unknown class _TtC8LibUI22SVNavigationController in Interface Builder file.
Could not load NIB in bundle: 'NSBundle /Users/me/Library/Developer/CoreSimulator/Devices/486B5EFB-6F18-45A7-AA78-07D18C0909FC/data/Containers/Bundle/Application/72B43E50-7A5D-4122-8CD3-09B862C5C6D4/AppBeta.app> (loaded)' with name 'MessageView''

故事板文件中引用的缺失类位于LibUI窗格中,并且Module字段在Interface Builder中针对这些类的相应实例正确设置为LibUI

MessageView类是LibUI Pod的成员。该类的类func尝试从resource_bundles LibUIBundle加载XIB,如下所示:

let libUIBundle = Bundle(for: MessageView.self)
let resourceBundleURL = libUIBundle.resourceURL?.appendingPathComponent("LibUIBundle.bundle")
let resourceBundle = Bundle(url: resourceBundleURL!)
guard let messageView: MessageView = UINib(nibName: "MessageView", bundle: resourceBundle).instantiate(withOwner: nil, options: nil)[0] as? MessageView else { return }

最近更新了以反映我搜索过的其他SO帖子中的建议。

所有这一切以前都有效,直到更新到iOS 11,我们推迟到最近。似乎Pods项目没有正确地将框架(动态链接时)和资源复制到我的应用程序包中。

我已经更新了Cocoapods。我还删除了该项目的Workspace和项目文件,然后使用默认值重新创建它们---将所有文件重新添加回项目---以避免任何可能影响这种情况的延迟构建设置。我做蠢事吗?如果这是一个错误,没有其他人遇到这个问题?

堆栈

   CocoaPods : 1.4.0.rc.1
        Ruby : ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
    RubyGems : 2.5.2
        Host : Mac OS X 10.13.2 (17C88)
       Xcode : 9.2 (9C40b)
         Git : git version 2.14.3 (Apple Git-98)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ e205fb520bcc24de216064c32914c85a2aaa25cc
               LibPods - https://github.com/Foo/LibPods.git @ 2c7954bf3d48a9d21ff9967fe6aa31d371e063e7

安装源

Executable Path: /usr/local/bin/pod

插件

cocoapods-deintegrate : 1.0.1
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.0
cocoapods-try         : 1.1.0

1 个答案:

答案 0 :(得分:0)

我终于在Github上找到了相关的问题,我会在这里链接以防其他人遇到这个问题:

Pods that are used by embedded dynamic frameworks can't be found in linked targets. No 'Embed Pods frameworks' build phase when building custom framework ?