编译 ReactiveCocoa 时出错

Getting error compiling ReactiveCocoa

我刚刚为一个新项目安装了这个 Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'

def import_pods
    pod 'Mantle'
    pod 'LBBlurredImage'
    pod 'TSMessages'
    pod 'ReactiveCocoa'
end

target 'WeatherJoy2' do
    import_pods
    link_with 'WeatherJoy2'
end

pod 安装成功,但在构建项目时出现以下错误:

/Users/ankit/Documents/WeatherJoy2/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+RACKVOWrapper.m:49:3: Unknown type name 'rac_propertyAttributes'; did you mean 'mtl_propertyAttributes'?
/Users/ankit/Documents/WeatherJoy2/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+RACKVOWrapper.m:49:40: Implicit declaration of function 'rac_copyPropertyAttributes' is invalid in C99

/Users/ankit/Documents/WeatherJoy2/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+RACKVOWrapper.m:49:27: Incompatible integer to pointer conversion initializing 'mtl_propertyAttributes *' with an expression of type 'int'

项目中没有其他东西,这是一个新项目。我在 xcode 6.2 和 OSX 10.9.5

我在同时使用 Mantle 和 ReactiveCocoa 时遇到了同样的问题。它似乎是由 pods 和 EXTRuntimeExtensions.h header 引起的,这使得 ReactiveCocoa 导入了 header 的不兼容的 Mantle 版本(mtl_ vs rac_ 函数名前缀).

在我的例子中,我通过将 ReactiveCocoa pod 中每次出现的 #import "EXTRuntimeExtensions.h" 替换为 #import "../Objective-C/extobjc/EXTRuntimeExtensions.h"

来修复它

作为一个选项,您可以将 ReactiveCocoa 版本设置为低于 3.0.0。例如,2.5 版本通常与 Mantle 一起工作。

pod 'Mantle', "~> 2.0.2"
pod 'ReactiveCocoa', "~> 2.5"