【问题标题】:Xcode, cocoapods + nib file, s.resources = ['*.{xib}'] not workXcode,cocoapods + nib 文件,s.resources = ['*.{xib}'] 不起作用
【发布时间】:2014-10-09 14:58:20
【问题描述】:

我有一个麻烦。 我创建了一个简单的项目,结果有下一个文件:ViewController.h、ViewController.m、ViewController.xib、ViewController.podspec 和 LICENSE。

Structure of ViewController.podspec:
Pod:: Spec.new do |s|
  s.name             = "ViewController"
  s.version          = "0.1.0"
  s.summary          = "Some text"
  s.homepage         = "setmypage"
  s.license          = 'MIT'
  s.author           = { "Oleksii" => "oleksii@site.com" }
  s.source           = { :path => "." }
  s.platform     = :ios
  s.requires_arc = true
  s.source_files = '*.{h,m,xib}'
  s.resources = ['*.{xib}']

end

我创建了简单的新项目并使用 Pod 添加了文件夹。

在我为我的 Pod 做了 pod lib lint 之后 并做 pod 安装这个 pod。

Structure Podfile:
platform :ios
pod "ViewController", :path => "testPod/"
    pod 'ViewController'

好的。我的 Pod 有项目。但是当我尝试构建我的项目时,我收到了 无法运行命令“StripNIB ViewController.nib” - 此目标可能包含其自己的产品。

我该怎么办?

【问题讨论】:

    标签: ios objective-c xcode cocoapods


    【解决方案1】:

    我遇到了同样的问题。您不应在 podspecs 的 source_files 参数中包含 xib:

     s.source_files = '*.{h,m,xib}'
     s.resources = ['*.{xib}']
    

    我的 podspecs 与你的有点不同,因为默认情况下 cocoapod 0.39 版在 source_files 中设置了一个通配符,这显然过于包容了,即使我的 xib 作为资源 (resource_bundle) 包含在内:

     s.source_files = 'Pod/Classes/**/*.{h,m}'
     s.resource_bundles = {
         'MyPodBundle' => ['Pod/Classes/**/*.xib']
     }
    

    所以请确保您没有将您的 xib 包含为 source_files

    【讨论】:

      【解决方案2】:

      您将产品的目标列在目标依赖项下的可能原因。在 xcode 中选择您的目标并在Build Phases 下查看Dependencies list 您的产品目标不应该在那里列出。

      同时检查您的Bundle Resources 和Link Binary with Libraries,您的产品不能在此处列出。

      【讨论】:

      • 1) 目标依赖项(0 项); Link Binary with Libraries 包含带有红色名称的“LibPods.a”
      • In Copy Bundle Resources (4 Items): Main.storyboard, ViewController.podspec, LaunchScreen.xib, Images.xcassets
      猜你喜欢
      • 1970-01-01
      • 2017-01-13
      • 2010-10-04
      • 1970-01-01
      • 1970-01-01
      • 2017-01-08
      • 2020-06-18
      • 2012-04-21
      • 2017-02-21
      相关资源
      最近更新 更多