Duplicate symbols error when upgrading react-native to 0.39.0 and above

1.4k views Asked by At

I am trying to update an ios app to react-native 0.39 and more. Everything works at 0.38.2 but after that I've got the ld: X duplicate symbols for architecture Y issue. The app itself is a mixture of swift, obj-c, web embedding etc ...

But it has a share extension made of swift and react-native.

The npm and pod installs seem to work with no issues.

After some researches, I found the reason of the issue, and tried a bunch of solutions, but I still did not succeed to solve that :

[...|similar duplicate symbol _CSSNodeList{something}] duplicate symbol _CSSNodeListFree in: ~/Library/Developer/Xcode/DerivedData/....../Build/Products/Debug-iphonesimulator/React/libReact.a(CSSNodeList-10ACA1A52987016B.o) ~/Library/Developer/Xcode/DerivedData/....../Build/Products/Debug-iphonesimulator/React/libReact.a(CSSNodeList-5089F60B494D1C9C.o) duplicate symbol _CSSNodeListAdd in: ~/Library/Developer/Xcode/DerivedData/....../Build/Products/Debug-iphonesimulator/React/libReact.a(CSSNodeList-10ACA1A52987016B.o) ~/Library/Developer/Xcode/DerivedData/....../Build/Products/Debug-iphonesimulator/React/libReact.a(CSSNodeList-5089F60B494D1C9C.o) ld: 103 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

From what I can understand, I've got at least 2 references to CSSNodeList (and probably on other react objects) somewhere in my share extension. But looking at the linked frameworks and libraries or link binary with libraries, I can only see one, and the issue persists if I remove libReact.a and put it back.

Tried to clean the project, DerivedData, pods, node_modules (...) with not more success.

(If it's helpful, I am running Xcode 8.2.1, Cocoapod 1.1.1, npm 4.0.5.)

Thanks for your help, guys.

1

There are 1 answers

1
mloigeret On BEST ANSWER

I had the same issue. The solution is documented in https://github.com/facebook/react-native/issues/11502

The short answer is to select your pod project, select the React target and then select Build phases and Compile Sources.

In there remove CSSLayout.c and CSSNodeList.c .

Try to build again. In my case I still have errors.

So go back to the React Compile Sources and re-add CSSLayout.c and CSSNodeList.c.

Build again and voilĂ  !!