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.
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:
Copy the starter folder in a convenient location on your computer. A location in your user folder is a good idea.
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.
Type pod install to fetch RxSwift from GitHub and install it in the chapter project.
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!
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.