Kodeco Forums

RxSwift: Transforming Operators

Learn how to leverage transforming operators in RxSwift, in this tutorial taken from our latest book, RxSwift: Reactive Programming With Swift!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/682-rxswift-transforming-operators

Is there a step needed to get RxSwift working in XCode? I downloaded the starter project, made sure the scheme was RxSwiftPlayground, and hit Build. I get errors
diff: /
/Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run ‘pod install’ or update your CocoaPods installation.

I’m brand new to RxSwift and this was first attempt to do something with it.

Hi @jimg, have you followed the instructions in chapter 1 to do pod install first?

Oh, duh, you won’t have access to that unless you bought the book. Please hang on, I am checking into this. The short answer is to go to the project directory in Terminal and run pod install, but I am seeing about having those instructions added to the tutorial. Thanks

No, Scott. Is Chapter 1 available (haven’t bought book yet - wanted to try the examples out to see if this is something I want to learn). I didn’t have cocoapods installed, so I did that and then did the pod install. I think I have it now. If Chapter 1 is available, let me know.

1 Like

Glad you’re good to go now. Re: “if this is something I want to learn,” I can help you with that: Yes! :grin:

I got rid of the pod error messages but now am getting No Such Module RxSwift and an error on import RxSwift line. Also the Pods_RxSwiftPlayground.framework seems to be missing.

Installing RxSwift for this tutorial

As for this tutorial and all projects in the book, they all come with a completed Podfile, but without the dependency files included. We looked into this option, but it didn’t make sense to include all the files for RxSwift in every single project for each chapter in the book download.

Before you start working on this tutorial, make sure you have the latest version of CocoaPods installed. You need to do that just once before starting to work on this tutorial or any of the book’s projects. Usually executing this in Terminal will suffice:

sudo gem install cocoapods

If you want to know more, visit the CocoaPods website.

Then follow these steps:

  1. Download the exercise files for this tutorial if you haven’t already.
  2. Copy the starter folder in a convenient location on your computer. A location in your user folder is a good idea.
  3. Open the built-in Terminal.app or another one you use on daily basis and navigate to the starter folder. Type cd /users/yourname/path/to/starter, replacing the example path with the actual path on your computer.
  4. Type pod install to fetch RxSwift from GitHub and install it in the chapter project.
  5. Finally, inside the starter folder, find the newly created .xcworkspace file and launch it. Build the workspace one time in Xcode, and you’re ready to work through the chapter!

I’ve updated the tutorial exercise files, starter, challenge, and final. Everything is set up and ready to go now. Sorry for the hassle everyone. Enjoy! :smile:

Thanks, Scott - got it working now.

1 Like

Scott thanks for great tutorial. After reading it I have a question, I want to take last flatMap value and print it after button press, how can I achieve it? I don’t see a way how to extract last value from map sequence 


If I understand your question correctly, if value is an array, just get its last property value. Otherwise, your observable needs to be one that replays, such at a ReplaySubject, BehaviorSubject, or Variable.

Hi. I have the pods installed but I get this error when trying to run

“The file “RxSwiftPlayground” couldn’t be opened because you don’t have permission to view it.” Am I missing a step? Thanks! :slight_smile:

1 Like

Same issue here, any updates?

Have you done a clean and deleted derived data?

If you right-click on the playground file in Finder, what do you see for Sharing & Permissions?

Yes, I’ve done that but no luck, I was using Xcode 8.3.2, not sure if that makes a difference.

I solved it by manually open the .project file first.
It will ask you

“RxSwift” is a project downloaded from the Internet. Are you sure you want to open it?

Then I can build it successfully :slight_smile:

Opening the project file for chapter 11 doesn’t help.

@zboralski Can you be more specific about the issue you’re encountering?

Did you try these steps?

In case it’s a permission issue, also check out this post.

can you give a example of flatmap marble diagram, i realy can’t figure out the flatMap { $0.value * 10 }:grinning: