在项目中添加ReactiveCocoa #安装与配置

这是对官方教程的补充

To add RAC to your application:

  1. Add the ReactiveCocoa repository as a submodule of your application's repository.
    1. 首先你得有个git,给自己的工程创建一个git
    2.   
      $ git submodule add https://github.com/ReactiveCocoa/ReactiveCocoa.git external/ReactiveCocoa
      $ git add .gitmodules external/ReactiveCocoa
      $ git commit -m "Add ReactiveCocoa as a submodule"
  2. Run script/bootstrap from within the ReactiveCocoa folder.
    1.   这里需进入sh(只需在终端键入"sh")
    2. cd 到脚本所在目录,键入脚本文件名即可
  3. Drag and drop ReactiveCocoaFramework/ReactiveCocoa.xcodeproj into your application's Xcode project or workspace.
  4. On the "Build Phases" tab of your application target, add RAC to the "Link Binary With Libraries" phase.
    • On iOS, add libReactiveCocoa-iOS.a.(我没找到这个东西,于是添加了ReactiveCocoa.framework)
    • On OS X, add ReactiveCocoa.framework. RAC must also be added to any "Copy Frameworks" build phase. If you don't already have one, simply add a "Copy Files" build phase and target the "Frameworks" destination.
  5. Add "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include" $(inherited)to the "Header Search Paths" build setting (this is only necessary for archive builds, but it has no negative effect otherwise).
  6. For iOS targets, add -ObjC to the "Other Linker Flags" build setting.
  7. If you added RAC to a project (not a workspace), you will also need to add the appropriate RAC target to the "Target Dependencies" of your application.

If you would prefer to use CocoaPods, there are some ReactiveCocoa podspecs that have been generously contributed by third parties.(系统假如已经安装了CocoaPods会很方便,但是安装cocoapod的过程中是有些坑的。教程自行谷歌。本文过程中没有使用cocoapod。)

To see a project already set up with RAC, check out C-41 or GroceryList, which are real iOS apps written using ReactiveCocoa.

posted on 2014-11-27 17:26  HowMacist  阅读(918)  评论(0编辑  收藏  举报

导航