環境
code:sh
$swift --version
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
モチベーション
https://developer.apple.com/documentation 上で、Foundation.URLの appendingPathComponent(_:) がiOS 17.2でDeprecatedになっていることを知ったが、移行先が書いてなかったので困った。Xcode上でJump to Definitionsしたら @available atrributeのmessageに "Use append(path:directoryHint:) instead" と書いてあったのでそっちを見たほうが確実。 /icons/hr.icon
Xcode上でJump to Definitionした先
code:swift
@available(macOS, introduced: 10.10, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(iOS, introduced: 8.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(tvOS, introduced: 9.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(watchOS, introduced: 2.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
public mutating func appendPathComponent(_ pathComponent: String, isDirectory: Bool)
append(path:) (iOS 16.0+)
code:swift
import Foundation
url.append(path: "hoge")
自己変容しないURLを返す appending(path:) もある (iOS 16.0+)
code:swift
import Foundation
let newURL = url.appending(path: "hoge")