swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.75k stars 1.35k forks source link

Target Protocol Does not have directoryURL so the deprecated warning cannot be solved #7870

Open ibrahimkteish opened 3 months ago

ibrahimkteish commented 3 months ago

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

Description

The Path type in Swift Package Manager plugins has been deprecated in favor of URL. However, the Target protocol still uses Path for the directory property:

protocol Target {
    var directory: PackagePlugin.Path { get }
}

When accessing any property of directory, we receive a deprecation warning:

"'property' is deprecated: UseURLtype instead ofPath. but we dont have access to URL.

The issue is that we don't have access to an equivalent URL property or a way to convert Path to URL within the plugin context.

when you run from terminal we get: - warning: 'propertyName' is deprecated: UseURLtype instead ofPath`.

Expected behavior

We should have a way to access the target's directory as a URL or a method to convert Path to URL without triggering deprecation warnings.

let target = any Target object target.directoryURL.lastComponent

Actual behavior

Currently, we must use the deprecated Path properties, leading to warnings and potential future incompatibilities. let target = any Target object target.directory.lastComponent <- "'lastComponent' is deprecated: Use URL type instead of Path

Steps to reproduce

in any plugin code whenever we access any property from any object that conforms to Target we

Swift Package Manager version/commit hash

Swift 6.0.0-dev

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1) Target: arm64-apple-macosx15.0 Darwin Ibrahims-MacBook-Pro-16-M2.local 24.0.0 Darwin Kernel Version 24.0.0: Wed Jul 31 21:50:55 PDT 2024; root:xnu-11215.0.199.501.2~1/RELEASE_ARM64_T6020 arm64