'Swift Package: ld: warning: dylib was built for newer macOS version (11.0) than being linked (10.15)

I've been searching for solution to get rid of this warning error:

ld: warning: dylib (/Applications/Xcode.app/Contents/PlugIns/IDESwiftPackageCore.framework/Versions/A/Frameworks/SwiftPM.framework/SharedSupport/ManifestAPI/libPackageDescription.dylib) was built for newer macOS version (11.0) than being linked (10.15)

I tried to clean & build Xcode project but no luck

This warning error might appear to you after creating new swift package.



Solution 1:[1]

The only simple solution worked like magic is:

  1. Enter this command in your terminal:

sudo xcode-select --switch /Applications/Xcode.app

  1. Relaunch Xcode

Credit to Arturo: https://blog.arturofm.com/solve-warning-was-built-for-newer-macos-version-xcode/

I published his answer here because I was searching for weeks on Stack overflow but non of their solutions helped me.

Solution 2:[2]

Reset the package cache (File -> Packages -> Reset Package Caches) and clean your build folder (Product -> Clean Build Folder) and the warning should be gone.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hamad Fuad
Solution 2 RyuX51