XCode 15.2.0 - Linking error and duplicate symbols

I am building an app with cordova-ios (v7.1.0) through XCode.

At the end of the build, i have the following errors :

[... Lot of duplicate symbol errors...]

duplicate symbol '_kCULMainXmlTag' in:
    /Users/antoineabbou/Library/Developer/Xcode/DerivedData/Appname-***-dvetpwtvzosuihaisuqrtdqvndri/Build/Intermediates.noindex/Appname-***.build/Debug-iphonesimulator/Appname-***.build/Objects-normal/x86_64/CULConfigXmlParser-84817d24615b6eea8da61f9b08150c6b.o
ld: 34 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)

/Users/antoineabbou/Projects/briefme-pwa/brief-eco/cordova/platforms/ios/Appname-***.xcodeproj: warning: The Copy Bundle Resources build phase contains this target's entitlements file '/Users/antoineabbou/Projects/briefme-pwa/brief-eco/cordova/platforms/ios/Appname-***/Resources/Appname-***.entitlements'. (in target 'Appname-***' from project 'Appname-***')
** BUILD FAILED **


The following build commands failed:
	Ld /Users/antoineabbou/Projects/briefme-pwa/brief-eco/cordova/platforms/ios/build/Debug-iphonesimulator/Appname-***.app/Appname-*** normal (in target 'Appname-***' from project 'Appname-***')

I already tried to add -ld_classic, -ld64 or -Wl in other linker flags but it doesn't work.

I tried to remove all my DerivedData but it still have the same issue. I tried to reinstall XCode, to clone my repo from zero to have a fresh clean install but nothing does the job.

Any help would be great.

Thanks !

Hi,

Duplicate symbol errors are often a result of symbol definitions in header files.

Here's an example:

// In Globals.h file:
const char* const aGlobalString = "str";

This is a header file that defines a global variable. Including this header in multiple source files will lead to the duplicate symbols error.

To fix this, you'll need to move the definition to a source file and only declare the variable in the header using the extern keyword, like this:

// In Globals.h file:
extern const char* const aGlobalString;

// In Globals.c file:
const char* const aGlobalString = "str";

Hopefully this helps!

A duplicate symbol error means you have two .o files defining the same symbol. There error message should include the path to both .o files. From there you should be able to infer the source files.

One possibility is that a header file has a definition (instead of a declaration) and then causing every source file that includes that header to get the definition, which leads to duplicate symbol errors at link time. Look at which header file declares kCULMainXmlTag and make sure it has extern keyword on it.

As I said, this is an app created with Cordova, so the files you mention are rewritten with each build.

I have the impression that it's an error quite similar to this thread: https://forums.developer.apple.com/forums/thread/731089

Unfortunately, nothing works with the other linker flags.

XCode 15.2.0 - Linking error and duplicate symbols
 
 
Q