項目集成ReactiveCocoa遇到的坑及解決辦法

  首先,使用CocoaPods集成(注意:因爲ReactiveCocoa須要iOS8.0,而且是與swift混編的,因此Podfile文件要寫成platform :ios, '8.0' 和 use_frameworks!),單集成沒問題,但項目裏用到SSKeychain,只要用到use_frameworks!老是報SSKeychain重複,把SSKeychain摘出來不用cocoaPods管理也是不行。html

  因而用第二套方案:GitHub上官方提供的方法:ios

To add RAC to your application:git

  1. Add the ReactiveCocoa repository as a submodule of your application’s repository.
  2. Run script/bootstrap from within the ReactiveCocoa folder.
  3. Drag and drop ReactiveCocoa.xcodeproj and Carthage/Checkouts/Result/Result.xcodeproj into your application’s Xcode project or workspace.
  4. On the 「General」 tab of your application target’s settings, add ReactiveCocoa.framework and Result.framework to the 「Embedded Binaries」 section.
  5. If your application target does not contain Swift code at all, you should also set the EMBEDDED_CONTENT_CONTAINS_SWIFTbuild setting to 「Yes」.

補充:github

  一、2兩步請參考這裏,三、四、5跟着作就好。而後build,會報錯:bootstrap

(null): error: /Users/xianfx/Documents/優化/XinfuPlatform/external/ReactiveCocoa/Carthage/Checkouts/Result/build/Debug-iphoneos/Result.framework: No such file or directoryswift

(null): error: /Users/xianfx/Documents/優化/XinfuPlatform/external/ReactiveCocoa/build/Debug-iphoneos/ReactiveCocoa.framework: No such file or directoryxcode

 解決辦法是:找到項目的.xcodeproj文件 -> 顯示包內容 -> 打開 project.pbxproj 文件,找到對應路徑,刪除便可。app

  使用,又報錯:iphone

dyld: Library not loaded: @rpath/libswiftCore.dylib優化

  Referenced from: /Users/xianfx/Library/Developer/Xcode/DerivedData/XinfuPlatform-fsgkjtwplnourtaicvecgysbcqhq/Build/Products/Debug-iphonesimulator/ReactiveCocoa.framework/ReactiveCocoa

  Reason: image not found

好吧,中間停了很久沒搞了,今天又試了下,看到了這個記錄,解決了:targets -> BuildSettings ->Embedded Content Contains Swift code 設置成YES。

 

 

僅供參考!

相關文章
相關標籤/搜索