Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-449

[Xcode 11] swift package generate-xcodeproj with RealmSwift dependency does not build.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      Bug: An Xcode 11 project which is generated from an executable-type Swift Package which has RealmSwift as a dependency does not build.

      Goals

      The goal is to have an Xcode 11 project which is generated from an executable-type Swift Package which has RealmSwift as a dependency that can successfully build and run.

      Expected Results

      What Swift Package that builds from the command line is also expected to build in an Xcode 11 project generated from the same package.

      Actual Results

      Build fails as show below in the steps to reproduced.

      Steps to Reproduce

      1. Setup an executable type Swift Package with RealmSwift as a dependency.
      2. Verify build from the command line on has only a few warnings.
      swift build
      
      # RealmSPMXcode/.build/checkouts/realm-cocoa/Realm/RLMRealm.mm:135:17: 
      # warning: method definition for 'privilegesForRealm' not found [-Wincomplete-implementation]
      # @implementation RLMRealm {
      
      # RealmSPMXcode/.build/checkouts/realm-cocoa/include/Realm/RLMRealm.h:658:1: 
      # note: method 'privilegesForRealm' declared here
      # - (struct RLMRealmPrivileges)privilegesForRealm;
      
      ## ... snip ...
      
      # warnings generated.
      # [139/139] Linking RealmSPMXcode
      
      1. Generate an Xcode 11 project from the Swift Package.
      swift package generate-xcodeproj 
      # generated: ./RealmSPMXcode.xcodeproj
      open RealmSPMXcode.xcodeproj/
      
      1. Build in Xcode with "My Mac" as the target.

      _Workaround: Edit RealmCore 5.23.5/realm/util/terminate.cpp to remove the

      REALM_VER_CHUNK

      expansion related error:_

      REALM_NORETURN void terminate(const char* message, const char* file, long line) noexcept
      {
          std::stringstream ss;
          // ss << file << ":" << line << ": " REALM_VER_CHUNK " " << message << '\n'; // :BEFORE:
          ss << file << ":" << line << ": [realm-core-5.23.5] " << message << '\n';    // :AFTER:
          terminate_internal(ss);
      }
      

      After the about workaround more errors occur:

      Notice that .build/checkouts/realm-cocoa/Realm/ObjectStore/src/impl/results_notifier.hpp
      and .build/checkouts/realm-cocoa/Realm/ObjectStore/src/impl/results_notifier.cpp are in the same directly.

      Next attempted workaround ...

      // #include "impl/results_notifier.hpp"
      #include "results_notifier.hpp"
      

      ... leads to yet more errors:

      Code Sample

      Version of Realm and Tooling

      Realm framework version: REALM_COCOA_VERSION 3.21.0

      Realm Object Server version: REALM_VERSION 5.23.5

      Xcode version: 11.2

      iOS/OSX version: macOS Mojave 10.14.6 (18G1012)

      Dependency manager + version: swift-tools-version 5.1

            Assignee:
            diana.perez@mongodb.com Diana Maria Perez Afanador
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: