title: Determine if target can use a specific class Swift
body: <p>I am working on a project that currently has numerous targets and it's using Cocoapods. Each target is for a different client. Some clients need specific frameworks to track analytics and some others don't.</p>
  <p>I am trying to be more efficient and I want to achieve:</p>
  <ul>
  <li>If TargetA uses Firebase/Analytics(for example), the target will include FAHandler class which will be responsible for importing the framework and implementing the calls...</li>
  <li>A class call MyClass included in TargetA and TargetB ... will call any method from FAHandler.</li>
  <li>TargetB does not include FAHandler class</li>
  <li>MyClass will use a compiling variable to avoid compiling errors.</li>
  </ul>
  <p>My first approach was:</p>
  <pre><code>#if canImport(FAHandler)
     //do the business
  #endif
  </code></pre>
  <p>It seems that canImport only works for frameworks.</p>
  <p>Is there something similar for classes?</p>
  <pre><code>#if classIsAvailable(FAHandler) -&gt; Just guessing
     //do the business
  #endif
  </code></pre>
  <p>The main reason I am seeking this approach is because:</p>
  <ul>
  <li>FAHandler is an Interactor and no other classes need to know about Firebase/Analytics</li>
  <li>In the event of moving to Carthage, It will bring crashes as the Firebase/Analytics won't be copied.</li>
  </ul>
  <p>Thank you</p>