[swift-users] hasSuffix(_:) and .hasPrefix(_:) String methods missing on Linux

Brent Royal-Gordon brent at architechies.com
Fri Dec 11 05:50:37 CST 2015


> 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:

  public func hasSuffix(suffix: String) -> Bool {
    return _stdlib_NSStringHasSuffixNFD(
      self._bridgeToObjectiveCImpl(), suffix._bridgeToObjectiveCImpl())
  }

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.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-users mailing list