Environment setup

Before we go ahead and start working with code, we need to set up the project for this chapter. This process is similar to the one we followed in earlier chapters with a small difference—follow the steps in order to get started:

  1. Create a single view application project and name it RxOperators.
  2. Open Terminal.app and navigate to the project folder. Create a podfile inside your Xcode projects folder by executing the pod init command.
  3. Open the created podfile and paste the code of the podfile:
# Uncomment the next line to define a global platform for your project
target 'RxOperators' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'RxSwift'
# Pods for RxOperators end
  1. Enter the pod install command to fetch all the listed libraries from GitHub and install all of them in the project.
  2. As a result of the installation, you will find a newly created workspace by the name .xcworkspace. Launch this file, and you are ready to work with the reactive components that will be introduced in this chapter.

We will work with a playground in this chapter and, as soon as we have the .xcworkspace ready, we will create a new playground file in the project and name it RxOperators.

Next, we will import RxSwift in this newly created RxOperators playground file and build the project to get rid of any possible errors. After the setup is complete, the project will look something like this:

Sometimes Xcode stops responding as soon as you open the .xcworkspace file or might give unexpected error messages. The easiest fix for this problem is to close all the instances of Xcode and then start fresh. That works like magic sometimes!