Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode preview linking fails #8735

Open
CyprienRicque opened this issue Dec 29, 2024 · 1 comment
Open

XCode preview linking fails #8735

CyprienRicque opened this issue Dec 29, 2024 · 1 comment

Comments

@CyprienRicque
Copy link

CyprienRicque commented Dec 29, 2024

How frequently does the bug occur?

Always

Description

Running xcode preview works fine until I add any Realm call in the file.

import SwiftUI
import RealmSwift

#Preview {
    _ = try? Realm(configuration: .init())  // comment this: Preview works again
    return Text("Coucou")
}

Reproduction at: https://github.com/CyprienRicque/PreviewRealmFail.git

I have been trying different flags and compile targets to fix this. Nothing worked.
Problem occurs for

  • iOS 17 and 18
  • Legacy and non legacy preview execution
  • with and without linker flag -ld64
  • sdk version 10.54.2 and 20.0.1

Note that the stack trace may vary but is always about linking to realm errors.

Stacktrace & log output

[Remote] JITError: Runtime linking failure
    
    Additional Link Time Errors:
    Symbols not found: [ _RLMRealmPathForFile, _$s10RealmSwift0A0V13configuration5queueA2C13ConfigurationV_So012OS_dispatch_D0CSgtKcfC, _$s10RealmSwift0A0V13ConfigurationVMa, _$s10RealmSwift0A0V13ConfigurationV7fileURL18inMemoryIdentifier13encryptionKey8readOnly13schemaVersion14migrationBlock06deleteA17IfMigrationNeeded21shouldCompactOnLaunch11objectTypes12seedFilePathAE10Foundation0E0VSg_SSSgAP4DataVSgSbs6UInt64VySo12RLMMigrationC_AYtcSgS2bSi_SitcSgSaySo13RLMObjectBaseCmGSgAStcfC ]
    

(Not the complete output)

Can you reproduce the bug?

Always

Reproduction Steps

SPM with

    .target(
      name: "StyleGuide",
      dependencies: [
        .product(name: "RealmSwift", package: "realm-swift"),
      ]
    )

Create a file with

import SwiftUI
import RealmSwift

#Preview {
    _ = try? Realm(configuration: .init())
    return Text("Coucou")
}

Observe the preview work fine without realm, and fail to build with realm

Version

20.0.1

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

MacOS 15.2

Build environment

Xcode version: 16.2
Dependency manager and version: SPM

@CyprienRicque
Copy link
Author

The error is fixed by using legacy previews https://forums.developer.apple.com/forums/thread/764016
in the reproduction repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant