realm-swift: Unable to compile Realm when targetting watchOS

How frequently does the bug occur?

All the time

Description

Am using Realm integrated in a pure SPM library project that targets iOS, tvOS macOS and watchOS. With latest update of packages can no longer build for watchOS. The error is:

.../simulated_failure.cpp:174:1: error: thread-local storage is not supported for the current target
thread_local bool (*s_mmap_predicate)(size_t);
^
1 error generated.

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

Sample project is available here

clone project from project root directory

$ open Package.swift

In xcode select watchOS as run target

Build

Version

10.21.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

Yes, using encryption

Platform OS and version(s)

watchOS 7.4. up

Build environment

Xcode version: 13.2.1 Dependency manager and version: Xcode SPM (swift 5.5.2)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I have a core PR for this, where I’m trying to cover all issues where thread_local is not supported, this is the branch, if you want to test out. @ding-stephen

This is still happening using SPM and Realm 10.24.0. Can we reopen this please?

This has been fixed on core and will be available shortly.

@dianaafanador3 Facing the same issue, I can confirm that your branch fixed the issue for me (on WatchOS). Any plans to merge these changes?

The same issue for my project with the latest Realm 10.24.2 on my Intel Mac. But the problem is only happened on the simulators, not when testing on actual device.

截屏2022-03-27 21 08 31

I’m able to build on our Intel CI system with the latest release where I wasn’t before, but still can’t on my M1 laptop, so must be something more subtle.

Additional, FWIW, if I change the compile time condition @ line 171 to

#if (REALM_ARCHITECTURE_X86_32 && REALM_IOS) || REALM_WATCHOS

Code compiles