Share a module name between two embedded frameworks for iOS and tvOS
<p>I want to add a tvOS version to my iOS universal app.
My App is written entirely in Swift and doesn't use anything fancy. Rather we stick to Cocoa Touch and try to be as platform conform as possible.</p>

<p>It's been amazing how seemless that works...</p>

<p>However I have a little problem. The iOS targets use 3 embedded frameworks. I don't seem to able to find the right settings in the project to share those embedded frameworks between the iOS and the tvOS target.</p>

<p>The embedded frameworks are all 3 compiled at compile time. No static libraries. Everything is in Swift.</p>

<p>Obviously the frameworks need to be compiled differently for tvOS than for iOS, but do I really need to create extra targets for tvOS Frameworks? Not that it would be a problem, given that both versions of the framework use the physically same source files - BUT the frameworks must have different names, as two targets (a framework is a target) can not have the same name.</p>

<p>That's unfortunate, because now all the shared code needs compiler directives to import the differently named frameworks. :-(</p>

<pre><code>#if os(tvOS)
  import myFrameworkTV
#else
  import myFramework
#endif
</code></pre>

<p>Also accessing objects in those frameworks now has the same problem, if for some reason you need to use the fully qualified "path".</p>

<pre><code>#if os(tvOS)
  let someVar = myFrameworkTV.aClass.aType()
#else
  let someVar = myFramework.aClass.aType()
#endif
</code></pre>

<p>Isn't there a way to set it up, so that I can use the same names for my Framework across both platforms?</p>

<p>The two cocoaPods, which I use do that?</p>

<p>Will it be necessary to create a second project inside the same workspace, instead of just adding targets to the existing project?</p>

<p>If so, what are the downsides of an embedded project vs. adding a target for tvOS to the iOS project?</p>

<p>One of which certainly is that the cocoaPods integration may not work as worry-free, as it does, if I just add a new target and issue a 'pod install' again.</p>