这是对官方教程的补充
To add RAC to your application:
- Add the ReactiveCocoa repository as a submodule of your application‘s repository.
- 首先你得有个git,给自己的工程创建一个git
-
$ git submodule add https://github.com/ReactiveCocoa/ReactiveCocoa.git external/ReactiveCocoa $ git add .gitmodules external/ReactiveCocoa $ git commit -m "Add ReactiveCocoa as a submodule"
- Run
script/bootstrap
from within the ReactiveCocoa folder.- 这里需进入sh(只需在终端键入"sh")
- cd 到脚本所在目录,键入脚本文件名即可
- Drag and drop
ReactiveCocoaFramework/ReactiveCocoa.xcodeproj
into your application‘s Xcode project or workspace. - 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.
- On iOS, add
- 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). - For iOS targets, add
-ObjC
to the "Other Linker Flags" build setting. - 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会很方便, 弄了半天没搞定,只好按上边的步骤)
To see a project already set up with RAC, check out C-41 or GroceryList, which are real iOS apps written using ReactiveCocoa.
时间: 2024-11-12 13:22:03