Realm-cocoa: How can solved the warning "direct access in function 'auto realm::sync"

Created on 4 Aug 2020  路  32Comments  路  Source: realm/realm-cocoa

Xcode Version: 11.5
Project Target: iOS 13.5
Language: Swift 5

Installed via Pod
Realm Version: 5.3.3

The warning is
warning: direct access in function 'auto realm::sync::Instruction::visit<(anonymous namespace)::RecoverLocalChangesetsHandler&>((anonymous namespace)::RecoverLocalChangesetsHandler&)' from file '/Users/shams/Work/iOS/innogyHealthGuard/Pods/Realm/core/librealmcore-ios.a(client_reset.o)' to global weak symbol 'typeinfo for realm::Lst' from file '/Users/shams/Work/iOS/innogyHealthGuard/Pods/Realm/core/librealmcore-ios.a(list.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

O-Community

Most helpful comment

Realm (5.4.1), Xcode 12.

ld: warning: direct access in function 'realm::sync::InstructionApplier::operator()....

image

All 32 comments

I don't know for certain. But looked at some other cases where this warning appears with other libraries.
Do the project, Pods, and Realm library settings for Symbols Hidden by Default and Inline Methods Hidden match?

I'm also seeing this. I'm using RealmSwift. I believe it appeared in 5.3.3 and wasn't present in 5.3.2. It's not just one warning; there are 32 of them.

Inline Methods Hidden: YES
Symbols Hidden by Default: NO

I have about 20 pods and they all have those same values for those two build settings.

The values for these build settings in the Pods project itself are different. Both values are NO.

If I go back to 5.3.2 the build settings mentioned above are the same as in 5.3.3 but the warnings don't appear. I believe that librealmcore-ios.a is distributed as a binary so it isn't being built on my Mac. So the problem is how that library was built.

I don't know how to determine the build settings for librealmcore-ios.a but I think that's what changed.

There are a series of recent commits that update the core library by @tgoyne that are probably the culprit.

I have the same problem, and I'm using RealmSwift too. Problem exist in 5.3.3 version only, 5.3.2 don't have those warnings.
direct access in function 'auto realm::sync::Instruction::visit<(anonymous namespace)::RecoverLocalChangesetsHandler&>((anonymous namespace)::RecoverLocalChangesetsHandler&)' from file '/Users/kamil/Projects/XXX/Pods/Realm/core/librealmcore-ios.a(client_reset.o)' to global weak symbol 'typeinfo for realm::Lst<realm::Timestamp>' from file '/Users/kamil/Projects/XXX/Pods/Realm/core/librealmcore-ios.a(list.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

+1

Xcode Version: 11.6
Project Target: iOS 12.4.1 & 13.6
Language: Swift 5

Installed via Pod
Realm Version: 5.3.5

I have exported all generated errors:
Build App_2020-08-24T10-14-50.txt

+1 as well. Updated from Realm 5.3.3 to 5.3.5 today and still get 32 warnings of variations on the following:

"Direct access in function 'realm::sync::InstructionApplier::operator()(realm::sync::Instruction::ArrayInsert const&)' from file '../Realm/core/librealmcore-ios.a(instruction_applier.o)' to global weak symbol 'typeinfo for realm::Lst >' from file './Realm/core/librealmcore-ios.a(list.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings."

+1

Screenshot 2020-09-01 at 11 22 18

In the Realm target under your pods project do you see the highlighted flags?

I've updated to 5.3.5. I see those custom build flags in the project (and also in the two .xcconfig files). I don't see the warnings.

Looking at the history for Realm.podspec those flags for armv7 were added on Feb 11, 2020, which was a version older than 5.0.0.

FWIW, these warnings seemed to come and go but I couldn't figure out what the correlation was. Maybe this is a Cocoapod or Xcode bug. Xcode doesn't like Cocoapods.

It seems Realm & RealmSwift 5.3.6 has fixed it, at least for me.

Yes, it's fixed in v5.3.6

v5.3.6 same issue....

Yes, it's fixed in v5.3.6

I changed from v5.3.5 to v5.3.6.
This issue still appears.

Updated to 5.3.6 -- Problem persists...

Updated to 5.4.0 Still have the problem.

@uglyelf Can you check the flags mentioned by leemaguire upthread? If they are missing this may be a syncing issue and you may want to try these various things to clear your cache. Option-Clean in Xcode. delete your Pods folder. pod deintegrate. Run pod install or pod update after and rebuild. I found the errors disappeared and reappeared a few times but eventually went away and stayed away. Not certain what really fixed it though.

K. I've now done all that and cleared the derived data and restarted x-code. Still has the error. @phoney I'm grateful for your suggestions. Do you have any more?

Sorry about that. Do you see those flags in the Pods project?

pod cache clean should delete all the pods and local pod specs. I think if you do pod cache list you can see the paths to the cached files and then manually delete them. Also, quit and restart Xcode.

Sorry. Should have said, yes, the flags are there.
I just ran pod cache clean --all
No change.

Hmmm. My Podfile line is pod 'RealmSwift', '~> 5.0' Is yours the same? I'm currently on Realm 5.4.0 but this seemed to go away with 5.3.5.

One other cleaning suggestion: close Xcode, delete the folder in Library/Developer/Xcode/DerivedData/ for your project. This does slightly more than opt-clean.

Right right. I cleared the derived data as stated a couple responses ago. Always clear the derived data. :)
I don't have limitations on my pod file for realm. Here are my versions in the Podfile.lock regarding realm:

  • Realm (5.4.0):

    • Realm/Headers (= 5.4.0)

  • Realm/Headers (5.4.0)
  • RealmSwift (5.4.0):

    • Realm (= 5.4.0)

Realm (5.4.1), Xcode 12.

ld: warning: direct access in function 'realm::sync::InstructionApplier::operator()....

image

This bug came back in 5.4.1. I updated to 5.4.2 today and it still persists. I do see the flags in the Pods project for RealmSwift.

I think we need to open another issue for it since this one is closed.

@tgoyne Do you understand the cause of this issue?

This is still happening in 5.4.2, 32 issues and tried everything explained above. Nothing seems to work

Can you add -fvisibility=hidden to 'Other C++ Flags' in your Target/Project (and Pods) and see if that helps.

@leemaguire
Adding the -fvisibility=hidden聽to 'Other C++ Flags' in the Target/Project did not yield any change.
Adding the -fvisibility=hidden聽to 'Other C++ Flags' in the Pods project did not yield any change.
Adding the -fvisibility=hidden聽to 'Other C++ Flags' in the Realm target in the Pods project on the other hand increased the warning count to 43 and added 5 errors:

Undefined symbol: _OBJC_CLASS_$_RLMResults
Undefined symbol: _OBJC_CLASS_$_RLMRealmConfiguration
Undefined symbol: _OBJC_CLASS_$_RLMObject
Undefined symbol: _OBJC_METACLASS_$_RLMObject
Undefined symbol: _OBJC_CLASS_$_RLMRealm

--
Mac OS X 10.15.7 (19H2)
Xcode 12.0 (12A7209)
CocoaPods 1.9.3
Realm 5.4.4

Below is my current setting, it seems to have solved it for me at least in Run, The errors appear sometimes on Build but never on Run. I also did not add them manually, I deleted the Pods folder and did pod install. The flags were absent when I updated the pod from pre 5.0 release.

Inline Methods Hidden - Yes and Symbols Hidden by Default - No for Pods Project and Target.
Inline Methods Hidden - Yes and Symbols Hidden by Default - Yes for main target

I've stumbled onto this setting and there's not rationale behind it so, any enlightenment would be useful.

Screenshot 2020-09-29 at 3 38 47 PM
(Other C++ Flags in Realm Target)

5.4.6 same
Xcode 12
cleared pods and derived data

Same here

Warnings are back for me in 5.4.7 and 5.4.8. The flags are all present in the Realm project. The warnings refer to librealmcore-ios.a, which I believe isn't compiled on my computer. It's downloaded as part of the library. Commit messages seem to say that realm core has been updated a lot lately. I believe the problem is how that file is built.

Please update to the latest version of Realm v10.1.1 this should resolve these warnings.

Closing this issue due to inactivity. If this issue still persists with the latest version v10.1.4 please open a new issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings