Error: Value of type string has no member componentsSeparatedByCharactersInSet
<p>The following code throws the following error: "Value of type string has no member componentsSeparatedByCharactersInSet"</p>

<p>This code is from another project that worked before in swift versions 1 or 2 but no longer works.  </p>

<pre><code>   import Foundation

extension String {

    func split() -&gt; [String] {
        return self.componentsSeparatedByCharactersInSet(
            CharacterSet.whitespaceAndNewlineCharacterSet())
            .filter({$0 != ""});
    }
}

extension Array {

    func unique&lt;T: Equatable&gt;() -&gt; [T] {
        var uniqueValues = [T]();

        for value in self {
            if !contains(uniqueValues, value as T) {
                uniqueValues.append(value as! T);
            }
        }
        return uniqueValues;
    }

    func first&lt;T&gt;(test:(T) -&gt; Bool) -&gt; T? {
        for value in self {
            if test(value as! T) {
                return value as? T;
            }
        }
        return nil;
    }
}
</code></pre>