Chapter 2: RealmSwift errors

I’m using Xcode 10. After pod install, I get the following errors for RealmSwift for the starter project

…/02-your-first-realm-app/starter/Pods/RealmSwift/RealmSwift/List.swift:641:17: Invalid redeclaration of ‘replaceSubrange(:with:)’
…/02-your-first-realm-app/starter/Pods/RealmSwift/RealmSwift/List.swift:622:17: Invalid redeclaration of ‘removeSubrange’
…/02-your-first-realm-app/starter/Pods/RealmSwift/RealmSwift/List.swift:648:17: Invalid redeclaration of 'replaceSubrange(

And the following errors for MyToDo target, which I guess are because of previous errors

/Users/[user]/Library/Developer/Xcode/DerivedData/MyToDo-dthtufdacklerreelusppygyigxr/Build/Products/Debug-iphonesimulator/RealmSwift/RealmSwift.framework/Modules/module.modulemap:9:12: Header ‘RealmSwift-Swift.h’ not found
/Users/[user]/Documents/Books/Realm/02-your-first-realm-app/starter/MyToDo/Scenes/ToDoListController.swift:30:8: Could not build Objective-C module ‘RealmSwift’

Hi @dgrigoryan, the projects in the book are setup with the latest version as of publishing the last edition: Xcode 9 and Realm 3.4. If you have the digital edition, once we update the book for Xcode 10 you will get the new source code/PDF automatically.

Hi Marin, I was just writing up a similar question when I discovered that it had just been asked. I’ve been working my way through the chapters and sample code in the Realm book, and really enjoying it. It’s a very comprehensive book with great examples. But when I went to start working through the Chapter 9 code, I found that Apple had automatically updated my version of Xcode to the new 10.0. This lead to the same errors listed above. I found a Realm forum post saying the issue would be taken care of in Realm 3.10, which is now out. But I guess there are some things in the books example code that need to be changed too.

So my follow-up question is, do you know when the 10.0 version of the sample code might be available? If it won’t be available for awhile, do you think a good work around would be to install Xcode 9.x again? My understanding is that it is possible to have multiple versions of Xcode installed.


Hi Tom,

we usually update books when there is a major new version of the software covered. For iOS we usually put out a new edition of the books in autumn when the new iOS comes out, but for Realm we are not sure just yet when there is gonna be a new major version release. My best guess is if we don’t hear anything in the next 2-3 months we’re going to release a compatibility update for whatever version is available at the time.

Meanwhile you can have as many Xcodes as you want (I usually have at least 3 on my computer) - just put them anywhere else out of your Applications folder. I have a “Developer” folder in my user folder and keep them there. The download link is: Sign In - Apple


Hey @dgrigoryan, I had the same issue but I was able to have it work on Xcode 10 with the latest Swift by updating the Podfile and changing the RealmSwift version to 3.7.1

Hope that also works for you! :slight_smile:

PS: don’t forget to run “$ pod update” after changing the podfile so you get the new version


I have worked on all RxSwiftPlayground projects of the book many times, without problems using Xcode 10 doing the following:

Remove from your Podfile the following lines:

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|

My Podfile contents:

platform :ios, ‘11.0’

target ‘RxSwiftPlayground’ do

# Pods for RxSwiftPlayground
pod ‘RxSwift’, ‘~> 4.0’
pod ‘RxCocoa’, ‘~> 4.0’

Perform the pod install command:

pod install

Then open the RxSwiftPlayground.xcworkspace project and select Product menu and press Option key + Clean Build Folder. After that, build the project with Command + B.

Then in the project select the Playground file and change the option Automatically Run to Manually Run at the bottom of the Playground (Long press on the triangle button at the bottom of the Playground).

For some unknown reason the last option let work without any issues, the drawback is that you have to press Run button in the playground every time you have to test the code. And because the Playground is compiling your code all the time, even while you are typing code, usually it fail and you have to restart it (maybe a Playground bug), but configuring this option on Manually Run, the Playground never stops and works smoothly.

Hope this helps.

@fifo “updating the Podfile and changing the RealmSwift version to 3.7.1” This worked for me. I updated my podfile and updated cocoa pods and then I was able to get the projects to work (I have not tried the playgrounds yet).

Hi @icanzilb, any update on a new version of the book? Back on September you mentioned:

My best guess is if we don’t hear anything in the next 2-3 months we’re going to release a compatibility update for whatever version is available at the time.

Thank you!

We are working on the last couple chapters of the update, it should come out in few weeks tops

@dgrigoryan I’m experience this issue too. Did you ever find a solution?

Thanks for the tip @fifo! This worked for me