【问题标题】:Cocoapods .podspec cannot find include headersCocoapods .podspec 找不到包含标头
【发布时间】:2019-04-25 05:26:17
【问题描述】:

我有一个 Objective-C iOS 库,它使用并发布了第三方静态 C 库。我的一个 Objective-C 源文件使用

导入该库
#import <teamspeak/public_errors.h>

但 Cocoapods 生成的 xcode 目标找不到该标头。

这是我的文件夹的简化结构

这是我的.podspec 文件

Pod::Spec.new do |spec|
  spec.name             = 'TSKit'
  spec.version          = '0.1.0'
  spec.summary          = 'An iOS TeamSpeak client'

  spec.description      = <<-DESC
  TSKit is a Objective-C wrapper around the C TeamSpeak client library.
                       DESC

  spec.homepage         = 'https://github.com/JanC/TSKit'
  spec.license          = { :type => 'MIT', :file => 'LICENSE' }
  spec.author           = { 'Jan Chaloupecky' => 'jan.chaloupecky@gmail.com' }
  spec.source           = { :git => 'https://github.com/JanC/TSKit.git', :tag => spec.version.to_s }
  
  spec.ios.deployment_target = '8.0'

  spec.frameworks = 'AVFoundation', 'AudioToolbox'

  spec.source_files = 'TSKit/Classes/**/*'
  
  spec.ios.vendored_library = 'TSKit/lib/libts3client.a'
  spec.libraries            = "ts3client", 'c++'

  spec.preserve_paths = 'TSKit/include/**' 
  
  # spec.header_dir          = "TSKit/include"
  # spec.header_mappings_dir = 'TSKit/include'

  spec.pod_target_xcconfig  =  {"HEADER_SEARCH_PATHS" => "$(PODS_ROOT)/#{spec.name}/include/**"}

end

如您所见,我尝试同时使用 spec.header_dir spec.header_mappings_dir 都没有运气。

pod lib lint 失败:

 -> TSKit (0.1.0)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
    - NOTE  | [iOS] xcodebuild:  10:9: fatal error: 'teamspeak/public_errors.h' file not found

你可以在这里找到一个示例项目(一定要检查so-question 分支)

https://github.com/JanC/TSKit/tree/so-question

【问题讨论】:

    标签: cocoapods static-libraries podspec


    【解决方案1】:

    spec.header_mappings_dir = 'TSKit/include/**/*.h' 应该会导致 cocoapods 递归遍历子文件夹 teamspeak 并找到 public_error.h 标头。

    【讨论】:

      猜你喜欢
      • 2013-09-16
      • 2014-11-23
      • 2013-11-02
      • 2011-01-09
      • 1970-01-01
      • 2013-10-11
      • 2012-12-15
      • 2016-09-19
      • 1970-01-01
      相关资源
      最近更新 更多