Realm-cocoa: support swift 3 soon ?

Created on 1 Sep 2016  Â·  24Comments  Â·  Source: realm/realm-cocoa

Realm version: ?
2
Xcode version: ?
8
iOS/OSX version: ?
10.12

T-Help

All 24 comments

Swift 3 works in master! We've been keeping it up-to-date with each beta release. For example, we migrated to Swift 3 Beta 6 just days after it launched. https://github.com/realm/realm-cocoa/pull/3965

Great work~ i will try it again~

target 'TestRealm' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TestRealm
  pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master’,:submodules => true
  pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master’,:submodules => true
end

Xcode 8 will convert realmswift.framework some code such as Results.swit

screen shot 2016-09-01 at 4 06 54 pm

@liufsd Don't run the migrator. Everything should work property. There's a bug in the Swift migrator where it will try to also migrate code in the _else_ section of #if swift(>3) #else #endif blocks.

oh?you mean i don't need convert swift 3? (I need select convert latter)

You shouldn't need to convert Realm's codebase (if it prompts you to). You may or may not want to update your code to Swift 3. We currently do support Swift 2.x still.

I'm working a new project,so I used Xcode 8 swift 3~ and realm is my best choice ~

Cool, Realm (w/ master) should be compatible with that configuration 😄

@liufsd Are you still having issues getting it to build? Don't convert any of _Realm_'s code.

sorry~
screen shot 2016-09-02 at 9 21 19 am
screen shot 2016-09-02 at 9 21 53 am

by the way , i use Xcode 8 beta 6~

Which version of CocoaPods are you using?

pod version 1.0.1

It looks like CocoaPods prior to v1.1.0 (currently in beta) does not set the SWIFT_VERSION setting on pod targets. The absence of this setting results in the Xcode error you're seeing. See CocoaPods/CocoaPods#5521 for how to explicitly set SWIFT_VERSION with existing versions of CocoaPods.

Yes~ done~ really thanks ~
i put this and work~

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end

I have test pod and carthage ~ and all of this work success~ great work~ thanks ~
and my cocoa project here: https://github.com/liufsd/PhotoCloud (branch:swfit 3.0) ,the ios project will open source latter~

When will swift 3 be released as an official Cocoapods version on trunk? Would be nice to move off of git and downsize my Podfile. Would go from:

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

to

    pod 'RealmSwift'

We've maintained support for Realm Swift across Xcode 8 betas since WWDC, making adjustments to continue compiling and passing tests for Swift 2.2, 2.3 and 3.0 as new betas came out.

However, due to the amount of churn Swift 3 has seen in the last 3 months, we held off on thoroughly reviewing all our Swift 3 API changes and accommodating both Xcode 7.3.1 and Xcode 8 into our continuous integration, testing, docs and release packaging processes.

With Xcode 8 GM last week, we decided to make a push to finalize our Swift 3 APIs along with the other integration points mentioned above.

That work is now mostly complete and we're preparing a 1.1.0 release for tomorrow, at which point our Swift 3 APIs will be final, binaries will be made available for Swift 2.3 and 3.0 in our release zips, and docs will be updated to reflect the new APIs.

Thanks for your patience.
JP

Awesome, thanks for all the hard work @jpsim and team

Would it be possible to point this out in you official documentation? I think a lot of other devs are currently migrating and would be happy to find this in your docs.

@ogezue
mac: https://github.com/liufsd/PhotoCloud/blob/master/Cartfile
ios: put this in your Podfile

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end

@ogezue you can see doc here: https://realm.io/docs/swift/latest/

Howdy! Any estimate when there would be a cocoapods release of RealmSwift for Swift3? The current 2.0.2 (as of today) does not compile due to several errors as such:

~~/Users/matti/src/foo/Pods/RealmSwift/RealmSwift/LinkingObjects.swift:123:29: error: extraneous argument label 'index:' in call~~ return notFoundToNil(index: rlmResults.index(of: object.unsafeCastToRLMObject())) ^

I'm in the process of updating a major customer app and would not prefer to go using the branch: 'master' mechanism.

_edit:_

I tried with:

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

.. and these too provide a non-Swift3 compliant version?

_edit 2:_ Sigh. Apparently I didn't read the supplied instructions properly and didn't understand the same code base is apparently used to build for both 2.3 and 3.0. Adding the post install hook to add config.build_settings['SWIFT_VERSION'] = '3.0' appears to have fixed it. Never mind my ramblings.

  • Matti
Was this page helpful?
0 / 5 - 0 ratings