How to import RxSwift in Playground of xcode?
it's super easy:
- Create a new project, Xcode menu > File > New > Project… (Single
View App)
- Close Xcode
- Initialize pods in the new project (pod init in terminal)
- Edit Podfile, add RxSwift, RxCocoa
- Install pods (pod install in terminal)
- Open RxSwiftProject.xcworkspace created by CocoaPods
- Build and run project using default scheme
- Add a new playground, Xcode menu > File > New > Playground…
- Select Add to: RxSwiftProject , to add it to the RxSwift workspace
- Save it in the workspace folder
example code here
No longer works in Xcode 9.1
$ pod playgrounds RxSwift,RxCocoa
gives
Errno::ENOENT - No such file or directory @ dir_initialize - /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source/Playground with Platform Choice.xctemplate
- You should clone the RxSwift repository on your computer
- Open
Rx.xcworkspace
- Build the
RxSwift-macOS
scheme - Open
Rx.playground
in theRx.xcworkspace
tree view and add a new page import RxSwift
in the new page.- Choose
View > Debug Area > Show Debug Area
As @sas has hinted at, you can use Arena.
To be more specific:
One line to install Arena:
brew install finestructure/tap/arena
One line to create your RxSwift enabled Playground:
arena https://github.com/ReactiveX/RxSwift
Results:
➡️ Package: https://github.com/ReactiveX/RxSwift @ from(5.1.1)
ð§ Resolving package dependencies ...
ð Libraries found: RxSwift, RxCocoa, RxRelay, RxBlocking, RxTest
ð¨ Building package dependencies ...
✅ Created project in folder 'Arena-Playground'
Done! Open Arena-Playground
and find your Playground (probably called MyPlayground), code there. It may require a click on Product -> Build to get going the first time.