After updating to Xcode 16.3, getting the error - Symbol not found: ___cxa_current_primary_exception

It didn't happen with Xcode 16.2 that I used before, but after updating to 16.3, when I build the app, the following error is output to the console and the app doesn't run.

dyld[2150]: Symbol not found: ___cxa_current_primary_exception
  Referenced from: <6B00A4F2-B208-3FDB-BA38-B7095AF0034A> /private/var/containers/Bundle/Application/B590DB18-9C66-4C9E-8330-104943419E60/Mubeat DEV.app/Mubeat DEV.debug.dylib
  Expected in:     <7F51CB08-A0CA-386E-BB62-4B8BFB0CED9F> /usr/lib/libc++.1.dylib
Symbol not found: ___cxa_current_primary_exception
  Referenced from: <6B00A4F2-B208-3FDB-BA38-B7095AF0034A> /private/var/containers/Bundle/Application/B590DB18-9C66-4C9E-8330-104943419E60/Mubeat DEV.app/Mubeat DEV.debug.dylib
  Expected in:     <7F51CB08-A0CA-386E-BB62-4B8BFB0CED9F> /usr/lib/libc++.1.dylib
dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib

After looking for another solution, I found a way to remove the -Objc option in Other Linker Flags, but this method only works on iOS 18.4 and doesn't work on other versions.

Is there another solution?

I believe this is a bug, may I ask you to file a bug?

Once you open the bug report, please post the FB number here for my reference.

If you have any questions about filing a bug report, take a look at Bug Reporting: How and Why?

Albert Pascual
  Worldwide Developer Relations.

Xcode 16.4 beta 1 still has issue with Symbol not found: ___cxa_current_primary_exception

Symbol not found: ___cxa_current_primary_exception Referenced from: <6A570AA3-0A49-31FB-81DA-81E88B14C7CA> /private/var/containers/Bundle/Application/93D9A1A1-4FC2-414B-AD9C-F66E12D02B01/Runner.app/Runner.debug.dylib Expected in: <09BDEE26-E6C3-3545-8CC9-6F215DEAFB43> /usr/lib/libc++.1.dylib dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/usr/lib/libRPAC.dylib:/usr/lib/libViewDebuggerSupport.dylib

I also encountered the same problem, how to solve it,my xcode version is 16.3

I encountered the same situation, and I found the reason.

the reason is symbol definition change in libc++.dylib. in iOS 18.4 above, symbols in libc++abi.dylib are defined as indirect in libc++.dylib. so when building apps, these symbols are marked as defined in libc++.dyilb. but in older OSes lower than iOS 18.4, these are marked as undefined in libc++.dylib. so dyld would meet bad situation.

the workaround about this is forcing link order, preceding libc++abi.dylib over libc++.dylib.

I filed feedback about this, ticket number is FB17734818

the workaround about this is forcing link order, preceding libc++abi.dylib over libc++.dylib.

Thanks, After adding the following settings to Other Linker Flags, the app no longer crashes on Xcode 16.4 with iOS versions earlier than 18.4 — at least for now:

-Wl,-force_load,$(SDKROOT)/usr/lib/libc++abi.tbd
-Wl,-weak_library,$(SDKROOT)/usr/lib/libc++.tbd
-Wl,-weak_library,$(SDKROOT)/usr/lib/libc++.1.tbd

I hope this issue will be properly addressed in the next Xcode update.

We had been using the workaround above in our project, and it was working fine.

Later, we partially migrated the project from CocoaPods to SwiftPM, and after that the issue started showing up again at runtime. In our case it was no longer just a launch-time symbol error, but a runtime crash caused by a weak import.

I do not know why, I do not know how, and I do not know why this makes any difference at all, but the only thing that fixed the project for us was removing the commas from the workaround above.

This form finally worked for us:

"-Wl -force_load $(SDKROOT)/usr/lib/libc++abi.tbd",
"-Wl -weak_library $(SDKROOT)/usr/lib/libc++.tbd",
"-Wl -weak_library $(SDKROOT)/usr/lib/libc++.1.tbd",

@khatum Thanks for providing this into the forums for other users.

Is there anything that keep you from moving to the latest Xcode released?

Thanks

Albert 
  Worldwide Developer Relations.

After updating to Xcode 16.3, getting the error - Symbol not found: ___cxa_current_primary_exception
 
 
Q