FileKit icon indicating copy to clipboard operation
FileKit copied to clipboard

warning: 'ExpressibleByStringInterpolation' is deprecated

Open TofPlay opened this issue 7 years ago • 5 comments

Hi, When I build your component with carthage I have these warnings:

../Sources/Carthage/Checkouts/FileKit/Sources/Path.swift:1066:17: warning: 'ExpressibleByStringInterpolation' is deprecated: it will be replaced or redesigned in Swift 4.0.  Instead of conforming to 'ExpressibleByStringInterpolation', consider adding an 'init(_:String)'
../Sources/Carthage/Checkouts/FileKit/Sources/TextFile.swift:231:21: warning: conditional downcast from 'NSString?' to 'String' is a bridging conversion; did you mean to use 'as'?

TofPlay avatar May 26 '17 05:05 TofPlay

This also appears in Issue Navigator when using Cocoapods. And in this case it is annoying - I don't like having warnings in my project.

ivankolesnik avatar May 29 '17 15:05 ivankolesnik

Just a try with this commit 6f2353f785df388783932fe1b87c13ca3a4a278b I think PR #49 will do better job for some part and I do not want to add conflict, so I reverted

phimage avatar Aug 14 '17 07:08 phimage

String bridging fixed

For ExpressibleByStringInterpolation I do not known how to convert the code and keep the functionality It seems to work with swift 4

phimage avatar Sep 30 '17 20:09 phimage

Is there any update for this issue?

Cookiezby avatar Apr 26 '19 03:04 Cookiezby

The warning is not the same

Initializer 'init(stringInterpolation:)' nearly matches defaulted requirement 'init(stringInterpolation:)' of protocol 'ExpressibleByStringInterpolation'

https://nshipster.com/expressiblebystringinterpolation/

maybe something like that

extension Path: ExpressibleByStringInterpolation {

    public init(stringInterpolation: StringInterpolation) {
        self.init(stringInterpolation.value)
    }

    public struct StringInterpolation: StringInterpolationProtocol {

        var value: String = ""

        public init(literalCapacity: Int, interpolationCount: Int) {
            self.value.reserveCapacity(literalCapacity)
        }

        public mutating func appendLiteral(_ literal: String) {
            self.value.append(literal)
        }

        public mutating func appendInterpolation<T>(_ value: T) where T: CustomStringConvertible {
            self.value.append(value.description)
        }
    }

}

phimage avatar Apr 26 '19 07:04 phimage