# Chapter 2: RealmSwift errors

**URL:** <https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965>\
**Category:** Realm: Building Modern Swift Apps with Realm\
**Created:** [September 27, 2018, 1:03pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965 "2018-09-27T13:03:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgrigoryan](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dgrigoryan/32/102075_2.png) [@dgrigoryan](https://forums.kodeco.com/u/dgrigoryan)\
**Post date:** [September 27, 2018, 1:03pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/1 "2018-09-27T13:03:10Z")

</div>

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(_:with:)’

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’

---

<div class="post-metadata">

**Author:** ![icanzilb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/icanzilb/32/109333_2.png) [@icanzilb](https://forums.kodeco.com/u/icanzilb)\
**Post date:** [September 27, 2018, 3:54pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/2 "2018-09-27T15:54:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tomp](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/tomp/32/81494_2.png) [@tomp](https://forums.kodeco.com/u/tomp)\
**Post date:** [September 30, 2018, 5:28pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/3 "2018-09-30T17:28:35Z")

</div>

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.

Thanks.  
Tom

---

<div class="post-metadata">

**Author:** ![icanzilb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/icanzilb/32/109333_2.png) [@icanzilb](https://forums.kodeco.com/u/icanzilb)\
**Post date:** [September 30, 2018, 6:25pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/4 "2018-09-30T18:25:32Z")

</div>

Hi Tom,

we usually update [raywenderlich.com](http://raywenderlich.com) 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](https://developer.apple.com/download/more/)

Marin

---

<div class="post-metadata">

**Author:** ![fifo](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fifo/32/78180_2.png) [@fifo](https://forums.kodeco.com/u/fifo)\
**Post date:** [October 15, 2018, 2:16am UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/5 "2018-10-15T02:16:28Z")

</div>

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! 🙂

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

---

<div class="post-metadata">

**Author:** ![williammr](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/williammr/32/84320_2.png) [@williammr](https://forums.kodeco.com/u/williammr)\
**Post date:** [November 13, 2018, 3:26am UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/6 "2018-11-13T03:26:38Z")

</div>

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|  
> config.build\_settings[‘CONFIGURATION\_BUILD\_DIR’] = ‘$PODS\_CONFIGURATION\_BUILD\_DIR’  
> end  
> end  
> end

My Podfile contents:

> platform :ios, ‘11.0’
> 
> target ‘RxSwiftPlayground’ do  
> use\_frameworks!
> 
> # Pods for RxSwiftPlayground  
> pod ‘RxSwift’, ‘~\> 4.0’  
> pod ‘RxCocoa’, ‘~\> 4.0’  
> end

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.

---

<div class="post-metadata">

**Author:** ![gsalerno](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gsalerno/32/105896_2.png) [@gsalerno](https://forums.kodeco.com/u/gsalerno)\
**Post date:** [December 29, 2018, 2:25am UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/7 "2018-12-29T02:25:07Z")

</div>

@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).

---

<div class="post-metadata">

**Author:** ![jcabrera](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jcabrera/32/109112_2.png) [@jcabrera](https://forums.kodeco.com/u/jcabrera)\
**Post date:** [January 28, 2019, 10:23pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/8 "2019-01-28T22:23:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![icanzilb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/icanzilb/32/109333_2.png) [@icanzilb](https://forums.kodeco.com/u/icanzilb)\
**Post date:** [January 28, 2019, 10:45pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/9 "2019-01-28T22:45:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zbhardin](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/zbhardin/32/79544_2.png) [@zbhardin](https://forums.kodeco.com/u/zbhardin)\
**Post date:** [February 25, 2019, 8:12pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/10 "2019-02-25T20:12:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zbhardin](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/zbhardin/32/79544_2.png) [@zbhardin](https://forums.kodeco.com/u/zbhardin)\
**Post date:** [February 25, 2019, 8:41pm UTC](https://forums.kodeco.com/t/chapter-2-realmswift-errors/50965/11 "2019-02-25T20:41:33Z")

</div>

Thanks for the tip @fifo! This worked for me
