我有一个现有的Xcode框架,该框架同时使用Swift和Objective-C,并且正在尝试作为Cocoapod使用。到目前为止,我的步骤是:

1)我使用pod lib create SMCoreLib初始化了一个新文件夹(https://guides.cocoapods.org/making/using-pod-lib-create.html)。

2)我将Swift和Objective-C代码从我的框架复制到了这个新初始化的pod文件夹中的SMCoreLib / Classes文件夹中。我还将此代码拖到_Pods.xcodeproj中的相关组中。

3)我对项目的.podspec文件进行了一些更改。如下所示(请注意,Github存储库尚未通过这些更改进行更新;如果有人愿意,我可以这样做):

Pod::Spec.new do |s|
  s.name             = 'SMCoreLib'
  s.version          = '0.0.2'
  s.summary      = 'Spastic Muffin Core Library for iOS'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
    Objective-C and Swift classes to support Spastic Muffin code.
                       DESC

  s.homepage     = "https://github.com/crspybits/SMCoreLib.git"
  s.license      = { :type => "GPL3", :file => "LICENSE.txt" }
  s.author             = { "Christopher Prince" => "<snip>" }

  s.platform     = :ios, "8.0"

  s.source       = { :git => "https://github.com/crspybits/SMCoreLib.git", :tag => "#{s.version}" }

  s.ios.deployment_target = '8.0'

  s.source_files = 'SMCoreLib/Classes/**/*'

  s.resources = "SMCoreLib/Assets/**"

  # s.resource_bundles = {
  #   'SMCoreLib' => ['SMCoreLib/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'

  s.requires_arc = true

  # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }

  s.dependency 'AFNetworking'
  s.dependency 'HPTextViewTapGestureRecognizer', '~> 0.1'
  s.dependency 'Reachability'
end

我的问题是,尝试构建Example Xcode项目和尝试破坏Pod都失败了。构建示例Xcode项目时,出现以下错误:

ios - 用Swift和Objective-C构建一个Cocoapod:如何处理伞头问题?-LMLPHP

从命令行执行以下操作:
pod lib lint --allow-warnings --verbose --no-clean

我收到以下错误:
- NOTE  | [iOS] xcodebuild:  <module-includes>:2:9: note: in file included from <module-includes>:2:
- ERROR | [iOS] xcodebuild:  /Users/chris/Library/Developer/Xcode/DerivedData/App-bhqthebvswpzxeesjidsqpmmwovu/Build/Products/Release-iphonesimulator/SMCoreLib/SMCoreLib.framework/Headers/SMCoreLib-Swift.h:103:9: error: 'SMCoreLib/SMCoreLib.h' file not found
- NOTE  | [iOS] xcodebuild:  <unknown>:0: error: could not build Objective-C module 'SMCoreLib'

问题似乎是在自动生成的SMCoreLib-Swift.h生成的接口头中,找不到SMCoreLib.h伞头。我将不胜感激任何建议。

最佳答案

我有一个针对此问题的修补程序。我想要一个更好的。解决方法是将SMCoreLib.h文件放置在:SMCoreLib/Classes/SMCoreLib.h。该文件包含单行:

#import "SMCoreLib-umbrella.h"

问题似乎是,Generated Interface Header不尊重模块映射中给定的伞头的名称更改。 Cocoapods创建此模块图,并更改名称。此hack修复程序存在于此项目https://github.com/crspybits/SMCoreLib.git的Git存储库中。

10-08 18:06