Cocoapods .podspec找不到包含标头

时间:2019-04-25 05:26:18

标签: cocoapods static-libraries podspec

我有一个Objective-C iOS库,该库使用并提供了第三方静态C库。我的Objective-C源文件之一使用

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

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

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

enter image description here

这是我的.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_dirspec.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

1 个答案:

答案 0 :(得分:0)

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