Xcode 15 beta 3 linker issue: ld: warning: duplicate -rpath

Hello,

In Xcode 15 beta 3, if a project embedded a Swift package (no matter static or dynamic), and the package has its own dependencies, the linker will always emit following warning:

ld: warning: duplicate -rpath '/Users/.../Library/Developer/Xcode/DerivedData/MyApp.../Build/Products/Debug-iphonesimulator/PackageFrameworks' ignored

The warning is not appeared on beta 2 and beta 1.

Reproduce Steps

  • [1] Create a new iOS project in Xcode 15 beta 3
  • [2] Create a new Swift package MyLibrary, and add any dependency in the Package.swift. Example:
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
    name: "MyLibrary",
    platforms: [.iOS(.v16)],
    products: [
        .library(name: "MyLibrary", targets: ["MyLibrary"]),
    ],
    dependencies: [
        // 👀 Add any dependency to this package.
        // Here I use "Version" which is a simple pure swift package:
        .package(url: "https://github.com/mxcl/Version.git", .upToNextMajor(from: "2.0.0")),
    ],
    targets: [
        .target(name: "MyLibrary", dependencies: ["Version",]),
    ]
)
  • [3] In the project page, embed MyLibrary into the iOS app target.
  • [4] Build the project. It will succeed but with link warnings.

In addition, if you create a dynamic framework and embed MyLibrary, the warnings also reproduce. And this is only a simple case. In my real project, the linker will also emit a lot of warnings like this:

ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$__TtP10SPConfetti18SPConfettiDelegate_
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$__TtP10SPConfetti18SPConfettiDelegate_
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionTaskDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDataDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSURLSessionDownloadDelegate
ld: warning: could not associate debug note to atom l_OBJC_LABEL_PROTOCOL_$_NSObject
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionTaskDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDataDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSURLSessionDownloadDelegate
ld: warning: could not associate debug note to atom l_OBJC_PROTOCOL_REFERENCE_$_NSObject
Post not yet marked as solved Up vote post of Gong Down vote post of Gong
8.7k views
  • Reported FB12531495

  • Seeing this too

  • @interferon Some of the objc libraries failed to link due to this issue. 🥲 Not solved yet.

Replies

+1

We have exactly the same issue since Xcode 15 beta 1 - beta 3.

  • [@fish aside ;hsdf; las;dlf](https://developer.apple.com/forums/profile/fish aside ;hsdf; las;dlf) How do you link your library in your project? I use Swift package and link the library dynamically. And I saw this warning only on beta 3.

Add a Comment

I'm also seeing this. An easy repro is to simply create a macro package and try to build it.

Update: I have downgraded to Xcode 15 beta 2 because my real project couldn't link successfully. I hope this issue will be resolved by next beta. 😫

😫 I can still reproduce the warning in beta 4 using exactly the same reproducing steps in the original post.

Still seeing this in beta 4 as well.

+1, seeing this in Xcode 15 beta 4 as well. I also need to have -ld64 in my Other Linker Flags to use the old linker because PLCrashReporter suffers from a linker error with the new linker (FB12592304). Not sure if that makes a difference.

  • -ld64 saves me a day. And thanks for reporting a FB! I hope Apple can fix this issue in the next beta...

Add a Comment

Update:

It seems that Xcode 15 beta 5 has partially fixed the issue. However, I am still seeing some ld: warning: ignoring duplicate library '-lc++' warnings.

Post not yet marked as solved Up vote reply of Gong Down vote reply of Gong
  • and the warnings appeared in watchOS target.

Add a Comment

I see ld: warning: ignoring duplicate library '-lc++' along with ld: warning: ignoring duplicate library '-lz' in my project in Xcode 15 Beta 5. I've double checked and I'm not including them anywhere explicitly. I am getting less of them than I got in previous Xcode 15 beta builds.

Xcode 15 beta 8 (15A5229m)

ld: warning: ignoring duplicate libraries: '-lz'

  • Still also seeing this on Version 15.0 (15A240d)

Add a Comment

If you’re using Xcode 15 beta to build your product and you continue to see problems like this with 15.0b5 or later, you should absolutely file a new bug about it. The lead bug here, FB12531495, was reported as fixed in 15.0b5, so if you’re hitting this bug on a newer release then something else is triggering it.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • FB13166163

  • Thanks, Quinn. I still see it in Xcode 15 (15A240d) and cannot for the life of me figure out where it is coming from. When I look at the output from the link step I definitely see multiple calls to -lc++ and -lz but I cannot find them in the build settings. I'll submit a new feedback.

Add a Comment

I continue to see this issue as well, including with the new 5.1 beta today. I think the root of the problem is the way Xcode evidently collects inferred library linkage for dependent Swift Packages. At least, that's one easy scenario to reproduce the bug with. @eskimo : I filed FB13229994 with a simple example project demonstrating (I hope) the issue.

  • Thanks for filing FB13229994.

  • Sure thing!

Add a Comment

It appears that adding -Wl,-no_warn_duplicate_libraries to "Other Linker Flags" will quiet the warnings.

Add a Comment

I wrote extensively about the issue with the warnings, how to suppress them, and how to conditionalize the suppression to only apply to Xcode 15:

https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/

https://indiestack.com/2023/10/conditional-xcode-build-settings/

Hope that helps somebody!

  • Does anyone have an idea how to set this parameter to remove the warnings when using gradle (command ios:createIPA) to create the IOS ipa file? I cannot remove this error as my project is not done directly in Xcode...

Add a Comment