Realm-cocoa: Add Swift 3 installation instructions

Created on 15 Jun 2016  路  18Comments  路  Source: realm/realm-cocoa

Goals

Running Realm DB in swift 3.0

Expected Results

Running Realm DB in swift 3.0 using XCODE 8 beta

Actual Results

Multiple errors:
screen shot 2016-06-15 at 22 04 39

Steps to Reproduce

Install xcode 8 beta to your mac and run project that was originally used swift 2.2

Code Sample

Version of Realm and Tooling

Realm version: ?
Realm (0.103.2)
RealmSwift (0.103.2)

Xcode version: ?
Version 8.0 beta (8S128d)

iOS/OSX version: ?
9

Dependency manager + version: ?
cocoa pods 0.39.0

T-Doc

Most helpful comment

@YHSX88 looks like you're not set up with git SSH access. Try https:

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master'
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master'

All 18 comments

You'll have to update your Podfile to target Realm's master branch to build with Swift 3:

pod 'Realm', git: '[email protected]:realm/realm-cocoa.git', branch: 'master'
pod 'RealmSwift', git: '[email protected]:realm/realm-cocoa.git', branch: 'master'

Note that this is extremely experimental at this point

Hi got error

**Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.**

I'm so sorry for bothering you with this.

@YHSX88 looks like you're not set up with git SSH access. Try https:

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master'
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master'

@YHSX88 Btw, if you have problems connecting to github over ssh on Sierra, you might be using a now deprecated dsa-key. See http://superuser.com/a/963029 on modifying PubkeyAcceptedKeyTypes to override this.

Hi All
To give you update @thabz I'm using still El Capitan but thanks for the others that will check the issue.
@jpsim that worked for me, however the only problem (I feel I need to mentioned it :) ). I was using Charts/Realm repo and because of that I got error while trying to update cocoa pods:

**[!] Unable to satisfy the following requirements:

But of course this is not of your problem :)

thank you all for your time

Best Regards
@YHSX88

The above instructions from @jpsim didn't work for me, manually copying out the realmSwift 3.0 folder files into the pod did.

Same issue here even after i change:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer

so xcrun swift --version returns 3.0

RealmSwift still uses the 2.2 files. can someone clarify how to not have to manually copy stuff around?
cheers and thanks

Same issue here.

xcrun swift --version returns 3.0, but XCode still asks me to migrate the Realm code to Swift 3.0

I think I can leave it open as it's a fresh topic and until the process is the butter smooth could help more people. If you think I'm wrong wit this statement please close it ....

We merged some changes that should fix CocoaPods for Swift 3. @austinzheng is now working on adding documentation for installing Realm Swift in Swift 3 projects.

Still working on putting these together, but anyone trying to use CocoaPods with Xcode 8 and building on a iOS device should be aware of this issue: https://github.com/CocoaPods/CocoaPods/issues/5523.

As a result, CocoaPods support for Xcode 8 is unfortunately blocked until an updated version of CocoaPods is released with the fix to that issue.

Thanks for the clarification @austinzheng.
I'll stop banging my head and try to move back to Xcode 7 for now.

@warpling Was the issue blocking you the code signing issue? I have a workaround if you're interested, although you probably shouldn't rely on it as anything more than a temporary hack. (Probably do it on a git branch or something just in case.)

@austinzheng I believe it was once I got everything compiling. Yeah I've been bouncing between an experimental branch, I'll try anything at this point if you don't mind sharing!

Try this out and see if it helps.

  1. Open the workspace
  2. Click on the Pods project
  3. For each target, turn on code signing in the "General" tab and click the "Automatically manage signing" checkbox. Also choose a team from the dropdown menu.
  4. You _should_ be able to build successfully for a device target now (if your problem is building to a simulator target, this answer won't help :( ). If it doesn't, go to "Code Signing Identity" under "Build Settings" and make sure all the "Any iOS SDK" options are set to either "iOS Developer", or one of the specific identities in your keychain.

Note that you'll need a valid developer account, iPhone certificate on the developer portal, all that stuff.

Let me know if this helps! If it doesn't, let me know as well and if I'll see what I can do to help.

Tangentially, another thing we're doing (while CocoaPods is fixing that issue) is changing our own Xcode project to not require code signing, so an interested individual could clone this repo and build the frameworks from source without having to fiddle with anything.

Closing this ticket; the issue will continue being tracked in #3796.

@YHSX88 , I am trying to use Charts/Realm too. Did you find a solution to the issue?

please add the pod dependency as

@jpsim just forgot to mention the submodule I suppose.

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git',:submodules => true, branch: 'master'
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git',:submodules => true, branch: 'master'

Was this page helpful?
0 / 5 - 0 ratings