kylef / PathKit

Effortless path operations in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift 3 support

sauliusgrigaitis opened this issue · comments

Swift 3 introduced breaking changes:

 Compiling Swift Module 'PathKit061' (1 sources)
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:38:19: error: 'CollectionType' has been renamed to 'Collection'
  public init<S : CollectionType where S.Generator.Element == String>(components: S) {
                  ^~~~~~~~~~~~~~
                  Collection
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:38:42: error: 'Generator' is not a member type of 'S'
  public init<S : CollectionType where S.Generator.Element == String>(components: S) {
                                       ~ ^
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:577:18: error: 'SequenceType' has been renamed to 'Sequence'
extension Path : SequenceType {
                 ^~~~~~~~~~~~
                 Sequence
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:580:39: error: 'GeneratorType' has been renamed to 'IteratorProtocol'
  public struct DirectoryEnumerator : GeneratorType {
                                      ^~~~~~~~~~~~~
                                      IteratorProtocol
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:39:8: error: value of type 'S' has no member 'isEmpty'
    if components.isEmpty {
       ^~~~~~~~~~ ~~~~~~~
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:41:15: error: value of type 'S' has no member 'first'
    } else if components.first == Path.separator && components.count > 1 {
              ^~~~~~~~~~ ~~~~~
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:42:15: error: value of type 'S' has no member 'joinWithSeparator'
      let p = components.joinWithSeparator(Path.separator)
              ^~~~~~~~~~ ~~~~~~~~~~~~~~~~~
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:51:14: error: value of type 'S' has no member 'joinWithSeparator'
      path = components.joinWithSeparator(Path.separator)
             ^~~~~~~~~~ ~~~~~~~~~~~~~~~~~
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:557:30: error: 'fromCString' is unavailable: Please use String.init?(validatingUTF8:) instead. Note that it no longer accepts NULL as a valid input. Also consider using String(cString:), that will attempt to repair ill-formed code units.
        if let path = String.fromCString(gt.gl_pathv[index]) {
                             ^~~~~~~~~~~
Swift.String:4:24: note: 'fromCString' has been explicitly marked unavailable here
    public static func fromCString(cs: UnsafePointer<CChar>) -> String?
                       ^
/home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/Sources/PathKit.swift:557:30: error: 'fromCString' is unavailable: Please use String.init?(validatingUTF8:) instead. Note that it no longer accepts NULL as a valid input. Also consider using String(cString:), that will attempt to repair ill-formed code units.
        if let path = String.fromCString(gt.gl_pathv[index]) {
                             ^~~~~~~~~~~
Swift.String:4:24: note: 'fromCString' has been explicitly marked unavailable here
    public static func fromCString(cs: UnsafePointer<CChar>) -> String?
                       ^
<unknown>:0: error: build had 1 command failures
error: exit(1): /home/saulius/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2016-03-24-a/usr/bin/swift-build-tool -f /home/saulius/workspace/Swifton/Packages/PathKit-0.6.1/.build/debug.yaml default

FYI, I just provided a PR for this. If you want to use it now, you can use my repo ( ratranqu/PathKit). It works with the latest swift 3.0 dev snapshot from 2013/03/24.

@ratranqu thanks! I tried you branch, but it doesn't compile on Linux:

warning: no sources in test module: /home/saulius/temp/PathKit
Compiling Swift Module 'PathKit' (1 sources)
/home/saulius/temp/PathKit/Sources/PathKit.swift:68:21: error: value of type 'Index' (aka 'String.CharacterView.Index') has no member 'distanceTo'
      let index = p.startIndex.distanceTo(p.startIndex.successor())
                  ~~^~~~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:161:17: error: value of type 'NSString' has no member 'standardizingPath'
    return Path(NSString(string: self.path).standardizingPath)
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:191:39: error: value of type 'NSFileManager' has no member 'destinationOfSymbolicLink'
    let symlinkDestination = try Path.fileManager.destinationOfSymbolicLink(atPath:path)
                                 ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:224:12: error: value of type 'NSString' has no member 'deletingPathExtension'
    return NSString(string: lastComponent).deletingPathExtension
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:264:17: error: value of type 'NSFileManager' has no member 'fileExists'
    return Path.fileManager.fileExists(atPath:self.path)
           ~~~~~^~~~~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:281:16: error: value of type 'NSFileManager' has no member 'fileExists'
    guard Path.fileManager.fileExists(atPath: normalize().path, isDirectory: &directory) else {
          ~~~~~^~~~~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:302:16: error: value of type 'NSFileManager' has no member 'fileExists'
    guard Path.fileManager.fileExists(atPath: normalize().path, isDirectory: &directory) else {
          ~~~~~^~~~~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:319:24: error: value of type 'NSFileManager' has no member 'destinationOfSymbolicLink'
      let _ = try Path.fileManager.destinationOfSymbolicLink(atPath: path)
                  ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:337:17: error: value of type 'NSFileManager' has no member 'isReadableFile'
    return Path.fileManager.isReadableFile(atPath: self.path)
           ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:351:17: error: value of type 'NSFileManager' has no member 'isWritableFile'
    return Path.fileManager.isWritableFile(atPath: self.path)
           ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:365:17: error: value of type 'NSFileManager' has no member 'isExecutableFile'
    return Path.fileManager.isExecutableFile(atPath: self.path)
           ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:379:17: error: value of type 'NSFileManager' has no member 'isDeletableFile'
    return Path.fileManager.isDeletableFile(atPath: self.path)
           ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:398:14: error: value of type 'NSFileManager' has no member 'createDirectory'
    try Path.fileManager.createDirectory(atPath: self.path, withIntermediateDirectories: false, attributes: nil)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:411:14: error: value of type 'NSFileManager' has no member 'createDirectory'
    try Path.fileManager.createDirectory(atPath: self.path, withIntermediateDirectories: true, attributes: nil)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:424:14: error: value of type 'NSFileManager' has no member 'removeItem'
    try Path.fileManager.removeItem(atPath: self.path)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:437:14: error: value of type 'NSFileManager' has no member 'moveItem'
    try Path.fileManager.moveItem(atPath: self.path, toPath: destination.path)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:450:14: error: value of type 'NSFileManager' has no member 'copyItem'
    try Path.fileManager.copyItem(atPath: self.path, toPath: destination.path)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:462:14: error: value of type 'NSFileManager' has no member 'linkItem'
    try Path.fileManager.linkItem(atPath: self.path, toPath: destination.path)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:474:14: error: value of type 'NSFileManager' has no member 'createSymbolicLink'
    try Path.fileManager.createSymbolicLink(atPath: self.path, withDestinationPath: destination.path)
        ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:554:47: error: value of type 'NSUUID' has no member 'uuidString'
    let path = try processUniqueTemporary() + NSUUID().uuidString
                                              ^~~~~~~~ ~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:584:16: error: value of type 'NSString' has no member 'substring'
    return try NSString(contentsOfFile: path, encoding: encoding).substring(from:0) as String
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:599:9: error: value of type 'NSData' has no member 'write'
    try data.write(toFile:normalize().path, options: .dataWritingAtomic)
        ^~~~ ~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:619:9: error: value of type 'NSString' has no member 'write'
    try NSString(string: string).write(toFile:normalize().path, atomically: true, encoding: encoding)
        ^~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:646:21: error: value of type 'NSFileManager' has no member 'contentsOfDirectory'
    return try Path.fileManager.contentsOfDirectory(atPath:path).map {
               ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:664:21: error: value of type 'NSFileManager' has no member 'subpathsOfDirectory'
    return try Path.fileManager.subpathsOfDirectory(atPath:path).map {
               ~~~~~^~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
/home/saulius/temp/PathKit/Sources/PathKit.swift:735:39: error: value of type 'NSFileManager' has no member 'enumerator'
      self.directoryEnumerator = Path.fileManager.enumerator(atPath:path.path)!
                                 ~~~~~^~~~~~~~~~~ ~~~~~~~~~~
<unknown>:0: error: build had 1 command failures
error: exit(1): /home/saulius/.swiftenv/versions/DEVELOPMENT-SNAPSHOT-2016-03-24-a/usr/bin/swift-build-tool -f /home/saulius/temp/PathKit/.build/debug.yaml default

@saulius: Hum... I didn't touch the Linux bits as no running Linux vms with latest Dev branch. Let me have a look when I hv some time. Can you share which version of swift you are running please?

Thx.

@ratranqu I use latest DEVELOPMENT-SNAPSHOT-2016-03-24-a

@sauliusgrigaitis, I've just done a commit on my local copy (and pushed to PR). Can you confirm you are sorted now?

@ratranqu thanks, looks like it works at least on Linux!

Support for Swift 3 has been added in PathKit 0.7.0.