我是通過(guò)Cocoapods來(lái)集成ReactiveCocoa,安裝pods就不詳述了。執(zhí)行touch podfile, 然后執(zhí)行vim podfile ?按下i開(kāi)始編輯, 寫(xiě)下如下代碼
platform :ios, '8.0'
target "你的工程名" do
pod 'ReactiveCocoa', '~> 5.0.1'
end
然后 install
特別注意添加 use_frameworks!
作用? https://segmentfault.com/a/1190000007076865
成功以后進(jìn)工程編譯報(bào)錯(cuò),錯(cuò)誤信息大概如下:
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly”?
原因是沒(méi)設(shè)置Swift的語(yǔ)言版本,在build settings 里面搜 swift lang 設(shè)置一下

再編譯出現(xiàn)幾十條錯(cuò)誤,都是swift語(yǔ)法錯(cuò)誤。查了下資料,因?yàn)閟wift升級(jí)5.0了,由于沒(méi)有更新最新xcode選項(xiàng)中沒(méi)有5.0
再編譯 出現(xiàn)'ReactiveCocoa.h' file not found錯(cuò)誤? 網(wǎng)上資料說(shuō)link binary with libraries里面添加一下framework,嘗試后沒(méi)用。
原來(lái)使用 ReactiveCocoa? 依賴(lài)于 ReactiveSwift ,等于你引入了兩個(gè)庫(kù)。 由于項(xiàng)目是純oc的只需要集成ReactiveObjC
把podfile改成如下
platform :ios, '8.0'
target "你的工程名" do
pod 'ReactiveObjC', '2.1.2'?
end
install 編譯通過(guò)
把#import "ReactiveCocoa.h"改成#import <ReactiveObjC/ReactiveObjC.h>?
集成成功