【问题标题】:.h file not linking when pod installpod安装时.h文件未链接
【发布时间】:2017-03-31 16:20:35
【问题描述】:

Mac OS 10.12 xcode 8.1

我们正在尝试安装 pod 之类的

platform :ios, '8.0'

target 'ProjectName' do
pod 'ARSafariActivity', '~> 0.0'
pod 'FFBadgedBarButtonItem', '~> 1.0'
pod 'MMDrawerController', '~> 0.5'
pod 'MMProgressHUD', '~> 0.2'
pod 'MMSpreadsheetView', '~> 0.0'
pod 'Mantle', '~> 1.5'
pod 'Masonry', '~> 0.5'
pod 'NHAlignmentFlowLayout', '~> 0.1'
pod 'NMRangeSlider', '~> 1.1'
pod 'PBWebViewController', '~> 0.2'

pod 'SZTextView', '~> 1.1'
pod 'AAPLAdvancedCollectionView', :git => 'https://github.com/zwaldowski/AAPLAdvancedCollectionView.git', :tag => 'v1.0.11'
end
target 'ProjectNameTests' do
pod 'Kiwi', '~> 2.3'
pod 'OHHTTPStubs', '~> 4.0'
end

给出错误词法和预处理器问题。 未找到 Mantle.h 文件。

我们尝试了iOS - Build fails with CocoaPods cannot find header files,但仍然无法正常工作。

【问题讨论】:

  • 你试过这个吗:right click your project -> Add Files to "prjectName" ... -> Choose the Mantle dir in Pods dir ?然后导入Mantle.h?

标签: ios iphone cocoapods-1.1.1


【解决方案1】:

如果你不打算在 swift 和 Objective - c 之间添加桥接文件,你应该指定使用框架

使用没有 Bridge 文件的 Pods

将您的 pod 文件更新为

platform :ios, '8.0'

target 'ProjectName' do
use_frameworks!
pod 'ARSafariActivity', '~> 0.0'
pod 'FFBadgedBarButtonItem', '~> 1.0'
pod 'MMDrawerController', '~> 0.5'
pod 'MMProgressHUD', '~> 0.2'
pod 'MMSpreadsheetView', '~> 0.0'
pod 'Mantle', '~> 1.5'
pod 'Masonry', '~> 0.5'
pod 'NHAlignmentFlowLayout', '~> 0.1'
pod 'NMRangeSlider', '~> 1.1'
pod 'PBWebViewController', '~> 0.2'

pod 'SZTextView', '~> 1.1'
pod 'AAPLAdvancedCollectionView', :git => 'https://github.com/zwaldowski/AAPLAdvancedCollectionView.git', :tag => 'v1.0.11'
end
target 'ProjectNameTests' do
pod 'Kiwi', '~> 2.3'
pod 'OHHTTPStubs', '~> 4.0'
end

现在您不需要导入 .h 文件,它会作为模块导入:)

我希望你能在更新的 pod 文件中看到 use_frameworks! :)

将 Pod 与 Bridge 文件一起使用(如果您不想处理框架但只直接使用 Objective - C 文件)

创建一个名为 YourAppName-Bridging-header.h 的 .h 文件 打开它并添加您要导入的所有 Objective-C 文件,例如

#ifndef YourAppName_Bridging_Header_h
#define YourAppName_Bridging_Header_h


#endif /* YourAppName_Bridging_Header_h */

#import "Reachability.h"
#import <CommonCrypto/CommonCrypto.h>

现在就是这样,您可以在任何文件中使用它,而不必担心一次又一次地导入它们。

【讨论】:

    猜你喜欢
    • 2016-10-18
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    相关资源
    最近更新 更多