Hello to everyone!
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and
I have the following issue: if I call the hasSuffix(_ or the
hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev)
installed.
Any idea?
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and I have the following issue: if I call the hasSuffix(_ or the hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev) installed.
Looking in the standard library, the gibberish in the implementation of hasSuffix:
Makes me think this method is actually handled by NSString. Until Foundation is up and running and toll-free bridging works on Linux, I’m afraid you’re out of luck here.
They may come as extensions from NSString, which Swift doesn’t have fully implemented on Linux yet.
Alex
···
On 11 Dec 2015, at 11:18, Alessandro Morgantini via swift-users <swift-users@swift.org> wrote:
Hello to everyone!
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and I have the following issue: if I call the hasSuffix(_ or the hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev) installed.
Any idea?
Hello to everyone!
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and I have the following issue: if I call the hasSuffix(_ or the hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev) installed.
Any idea?
They may come as extensions from NSString, which Swift doesn’t have fully
implemented on Linux yet.
Alex
On 11 Dec 2015, at 11:18, Alessandro Morgantini via swift-users < > swift-users@swift.org> wrote:
Hello to everyone!
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and
I have the following issue: if I call the hasSuffix(_ or the
hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev)
installed.
Any idea?
Hello to everyone!
I'm a very newbie to Swift, I'm doing first experiments on Linux & Mac and I have the following issue: if I call the hasSuffix(_ or the hasPrefix(_ methods on a String instance, I obtain the following error:
$ swiftc prova.swift
prova.swift:110:4: error: value of type 'String' has no member 'hasSuffix'
if pippo.hasSuffix("ao") {
^~~~~ ~~~~~~~~~
Same code works well on OS X.
I'm using Ubuntu 14.04 with required dependencies (clang and libicu-dev) installed.
Any idea?
This is still affecting linux, I see the discussion is from 2015, but look at the example from Swift docs:
import Foundation
let romeoAndJuliet = [
"Act 1 Scene 1: Verona, A public place",
"Act 1 Scene 2: Capulet's mansion",
"Act 1 Scene 3: A room in Capulet's mansion",
"Act 1 Scene 4: A street outside Capulet's mansion",
"Act 1 Scene 5: The Great Hall in Capulet's mansion",
"Act 2 Scene 1: Outside Capulet's mansion",
"Act 2 Scene 2: Capulet's orchard",
"Act 2 Scene 3: Outside Friar Lawrence's cell",
"Act 2 Scene 4: A street in Verona",
"Act 2 Scene 5: Capulet's mansion",
"Act 2 Scene 6: Friar Lawrence's cell"
]
var act1SceneCount = 0
for scene in romeoAndJuliet {
if scene.hasPrefix("Act 1 ") {
act1SceneCount += 1
}
}
print("There are \(act1SceneCount) scenes in Act 1")
Gives me:
🏃 e[0;3m$ cd "/home/luis/.marathon/Scripts/Cache/-home-luis-Downloads-untitled/" && readlink OriginalFilee[0;23m
e[0;3m/home/luis/Downloads/untitled.swifte[0;23m
e[0;3m$ cd "/home/luis/Downloads/" && swift package --versione[0;23m
e[0;3mSwift Package Manager - Swift 4.1.0e[0;23m
e[0;3m$ cd "/home/luis/.marathon/Scripts/Cache/-home-luis-Downloads-untitled/" && swift build -C /home/luis/.marathon/Scripts/Cache/-home-luis-Downloads-untitled/ e[0;23m
e[0;3mCompile Swift Module 'untitled' (1 sources)
Linking ./.build/x86_64-unknown-linux/debug/untitled
Linking ./.build/x86_64-unknown-linux/debug/libMarathonDependencies.so
cannot find section .interp
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)e[0;23m
e[0;3mwarning: '--chdir/-C' option is deprecated; use '--package-path' instead
error: terminated(1): /usr/lib/swift/bin/swift-build-tool -f /home/luis/.marathon/Scripts/Cache/-home-luis-Downloads-untitled/.build/debug.yaml main output:
e[0;23m
[Finished in 0.8s with exit code 1]
Am I doing something wrong, or these properties are not implemented in Foundation still?
None of those errors seem relevant to these methods. I suggest asking for help in a separate thread. (I haven't seen this cannot find section .interp myself before.)