realm-swift: RealmSwift 1.0.2 does not compile with Swift 2.3

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)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

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

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: 'git@github.com:realm/realm-cocoa.git', branch: 'master', submodules: true
    pod 'RealmSwift', git: 'git@github.com: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.

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

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

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.

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