Swift extensions that apply only when you import them
<p>I have some swift extensions I want to across projects.</p>

<p>I'd like to avoid category pollution though, unless those extensions are requested.</p>

<p>Is it possible to write them so that they only apply if I've done a certain import, like:</p>

<pre><code>import MySwiftExtensions

// Use custom extensions
let x = [1,3,5,7].average()
let y = [1,3,5,7].firstWhere { $0 &gt; 3 }
let z = "campervan".make1337()
</code></pre>

<p>I could write these as static methods wrapped in a single letter class (eg: <code>ø.average([1,3,5,7])</code>, like <a href="https://lodash.com/">lodash</a>) to achieve the same thing but sometimes you get much more concise usage from instance methods.</p>