Xcode passes -L/usr/lib/swift to linker when compiling for ios

I'm in my way to understanding compilation commands that xcode makes, and here is interesting one.

-L/.../Xcode.app/.../XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
-L/usr/lib/swift

You can see, that ios app linking uses path for swift binaries that are built for macos, without it all swift symbols will be undefined. The other one, that looks to be as correct one actually not needed (or needed in some rare cases). Initially I thought that usr/bin/swift contains fat binaries, but it's not.

Why is that? Is it very well known that macos/ios swift binaries will never have extra symbols, and linking will be incorrectly successful or failed? And are different architectures don't matter for linker?

Which version of Xcode are you using?

Xcode 11.1 (11A1027), also checked in 11.2.1, same.

In general, references past to the compiler and linker are interpreted relative to the SDK root, which is passed in via the -isysroot argument.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

That makes sense now, thanks!