2016-07-04 37 views
1

我有一個現有的Xcode框架,它使用Swift和Objective-C,我試圖讓它作爲Cocoapod工作。我到目前爲止的步驟是:用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 

我的問題是,我得到的失敗都試圖構建示例Xcode項目並試圖拴在吊艙上。構建示例Xcode項目,我收到以下錯誤:

Xcode errors

在命令行中,當我這樣做:

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標頭。我將不勝感激任何建議。

回答

0

我有一個黑客修復這個問題。我想要一個更好的。修復方法是將SMCoreLib.h文件放在:SMCoreLib/Classes/SMCoreLib.h。該文件包含單個行:

#import "SMCoreLib-umbrella.h" 

這個問題似乎是生成的接口標頭不尊重名稱變更爲在一個模塊映射給出的傘頭。 Cocoapods創建了這個模塊映射和名稱更改。此攻擊修復程序存在於此項目的Git回購https://github.com/crspybits/SMCoreLib.git中。

+0

這是一個已知問題。 [rdar:// 24641873](https://openradar.appspot.com/24641873) – izerik

+0

酷!謝謝! –