Realm-cocoa: RealmSwift 1.0.2 does not compile with Swift 2.3

Created on 20 Jul 2016  ·  18Comments  ·  Source: realm/realm-cocoa

Goals

Compile RealmSwift 1.0.2 with the Use Legacy Swift Language Version flag enabled.

Expected Results

I expect it to compiler without any errors.

Actual Results

The following two compilation errors:

.../Pods/RealmSwift/RealmSwift/Realm.swift:1137:18: Use of unresolved identifier 'RLMRealmDidChangeNotification'
.../Pods/RealmSwift/RealmSwift/Realm.swift:1139:18: Use of unresolved identifier 'RLMRealmRefreshRequiredNotification'

Steps to Reproduce

Try to compiler a test project with Swift 2.3 that depends on RealmSwift through Cocoaopds.

Code Sample

Because we are in Swift 2.3, the swift(>=3.0) code is not compiled. But Swift 2.3 requires Realm to reference RLMNotification.DidChange and RLMNotification.RefreshRequired instead of RLMRealmDidChangeNotification and RLMRealmRefreshRequiredNotification.

Version of Realm and Tooling

ProductName:    Mac OS X
ProductVersion: 10.11.5
BuildVersion:   15F34

/Applications/Xcode-beta.app/Contents/Developer
Xcode 8.0
Build version 8S174q

/Users/david/.rbenv/shims/pod
1.1.0.beta.1
Realm (1.0.2)
RealmSwift (1.0.2)
RealmSwift (~> 1.0)

/bin/bash
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)

/usr/local/bin/carthage
0.14.0
(not in use here)

/usr/bin/git
git version 2.8.4 (Apple Git-73)
T-Bug

Most helpful comment

We got Xcode 8 stable version. still facing problem with this issue.

All 18 comments

Sorry, just saw this was fixed in master :) My bad.

Hey Guys,
I still met the same issue on Realm 1.0.2, and I suppose it will be resolved in following release, am I right?

As Swift 2.3 is only available with a prerelease version of Xcode, we're only supporting it when building from master at this time. Once Xcode 8 and Swift 2.3 are officially released it will be supported in released versions of Realm.

Fair enough,
thanks anyway 😅

@bdash @jpsim Do you know approximately when the next version of Realm supporting Swift 2.3 will be released? Xcode 8.0 final release will most likely be out this Thursday or Friday. Also, will a version of Realm supporting Swift 3.0 be available soon, or is that further out? Thanks!

We intend to have a new release out with full Xcode 8 support sometime this week.

@tgoyne Thanks for the info! I love Realm and am looking forward to using it with with Xcode 8.

We got Xcode 8 stable version. still facing problem with this issue.

Hi same issue with xcode 8 any assistance

I see that this issue is closed. Is it really ? If yes, could you point me to the Cocoapods version of RealmSwift fixing this bug ? If no, maybe we should re-open the issue.
Thanks !

I still have this issue with Xcode 8. Is there a solution that I missed, or can the issue be opened again?

Try this:

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

Any solution for Carthage users? (tried with --no-use-binaries but it failed the compilation :/ )

Cool, thanks ! It worked

+1 for not currently working with Carthage...

Does anyone know how to make this works?

Temporary Xcode 8 installation instructions for Realm Swift using CocoaPods and Carthage:

Xcode 8 Realm Swift Installation Instructions

CocoaPods

  1. Install CocoaPods 0.39.0 or later.
  2. In your Podfile, add use_frameworks! and the following pods to your main and test targets:

    pod 'Realm', git: '[email protected]:realm/realm-cocoa.git', branch: 'master', submodules: true
    pod 'RealmSwift', git: '[email protected]:realm/realm-cocoa.git', branch: 'master'
    
  3. Paste the following at the bottom of your Podfile, updating the Swift version if necessary:

    post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '2.3' # or '3.0'
      end
    end
    end
    
  4. From the command line, run pod install.
  5. Use the .xcworkspace file generated by CocoaPods to work on your project!

Carthage

  1. Install Carthage 0.17.0 or later.
  2. Add github "realm/realm-cocoa" "master" to your Cartfile.
  3. Run carthage update. To modify the Swift toolchain used to build, specify
    it via the --toolchain argument. For example:

    carthage update --toolchain com.apple.dt.toolchain.Swift_2_3
    
  4. Drag RealmSwift.framework and Realm.framework
    from the appropriate platform directory in Carthage/Build/ to the
    "Embedded Binaries" section of your Xcode project's "General" settings.
  5. iOS/tvOS/watchOS: On your application targets’ “Build Phases” settings
    tab, click the “+” icon and choose “New Run Script Phase”. Create a
    Run Script with the following contents:

    /usr/local/bin/carthage copy-frameworks
    

    and add the paths to the frameworks you want to use under “Input Files”, e.g.:

    $(SRCROOT)/Carthage/Build/iOS/Realm.framework
    $(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework
    

    This script works around an
    App Store submission bug
    triggered by universal binaries. Make sure this phase is _after_ the
    "Embed Frameworks" phase.


A release with official support for Xcode 8 is coming tomorrow. See https://github.com/realm/realm-cocoa/issues/3796#issuecomment-247412484 for more information.

(don't need step 3. if cocoapods version > 1.1.0.rc.2)

Was this page helpful?
0 / 5 - 0 ratings