Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ld: warning: Could not find or use auto-linked library 'swiftCore'

I am trying to manually link some swift code from the command-line. Here's what I'm doing:

ld \
  -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \
  -lSystem \
  -arch x86_64 \
  -macosx_version_min 10.15 \
  -o ./bin/main \
  -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
  main.o

but that fails with the following output :

ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftIOKit'
ld: warning: Could not find or use auto-linked library 'swiftXPC'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'

If I use usr/lib/swift-5.0 instead of usr/lib/swift, the executable complains the dylibs are not usable with OS X more recent than 10.14.4.

What am I missing here? Can you help? Thanks in advance!

like image 232
Daniel Glazman Avatar asked Dec 03 '25 00:12

Daniel Glazman


1 Answers

This error can be fixed by adding "swift file" and "Create Bridging Header" in your Xcode.

Follow the below steps to resolve this.

  • open Xcode project.
  • Under your project select new file.
  • Add swift file there.
  • While adding swift file confirm "Create Bridging Header".
  • Clean your build
  • Now make new build.
like image 143
Sakshi Singh Avatar answered Dec 05 '25 07:12

Sakshi Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!