Gonzalo.-
Gonzalo.-

Reputation: 12682

Undefined symbols for architecture x86_64: "_RCTSetLogFunction" in React Native when compiling iOS

I'm revamping an old app written in react-native (which had no changes from ~2018) to its latest versions. I migrated from react-native 0.59 to the latest 0.64

To do so, I got help from the react-native migration help tool.

I also had to update my dependencies to work with auto-link and cocoa pods. I'm fairly new to mobile and react native (my background is on web with plain react), so there might be something obvious that I'm missing.
But, while android compiles and works successfully on my Mac, I can't make the compilation to work with iOS.

As the title says, I'm getting the following error:

Undefined symbols for architecture x86_64: "_RCTSetLogFunction", referenced from: -[MetronomeWalletTests testRendersWelcomeScreen] in MetronomeWalletTests.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is happening in the test project, not in the main project (or however it is called).

Things I've tried

If I understand correctly, this error takes place in the phase "Link {projectName}Tests (x86_64)"

None of these have worked. I've run out of ideas.

Environment:

I get this error building both from the console and from xcode

Upvotes: 3

Views: 361

Answers (1)

Tom Spencer
Tom Spencer

Reputation: 8047

It looks like this issue has been fixed for newly scaffolded projects. I was also facing this issue when upgrading an existing React Native project from 0.59.10 to 0.65, with the caveat that it was only happening when building in Release mode (e.g. when archiving the project in Xcode).

The solution for me is outlined in this PR - the gist is to wrap any usage of RCTSetLogFunction inside an #ifdef DEBUG block, to prevent it being run in Release mode.

I realise this might not answer the original question but I thought I'd post it here in case its helpful to anyone else.

Upvotes: 3

Related Questions