title: Swift Framework does not include symbols from extensions to generic structs
body: <p>I am having trouble linking my framework with code that takes advantage of that framework. Specifically, the linker isn't able to find the symbols for extensions for generics structs.</p>
  
  <p>This is what one of the extensions looks like for Optional:</p>
  
  <pre><code>extension Optional {
      /// Unwrap the value returning 'defaultValue' if the value is currently nil
      func or(defaultValue: T) -&gt; T {
          switch(self) {
              case .None:
                  return defaultValue
              case .Some(let value):
                  return value
          }
      }
  }
  </code></pre>
  
  <p>This method works great in a playground or in an app if the code is compiled within the main part of the app. However, when I try to compile this into a Framework, apps (and even the tests for the framework) produce the following linker error:</p>
  
  <blockquote>
    <p>Undefined symbols for architecture i386:   "__TFSq2orU__fGSqQ__FQQ",
    referenced from:
          __TFC18SwiftPlusPlusTests27Optional_SwiftPlusPlusTests13testOrWithNilfS0_FT_T_
    in Optional+SwiftPlusPlusTests.o</p>
  </blockquote>
  
  <p>Similar methods like the one following, link fine (notice, it is not on a generic)</p>
  
  <pre><code>extension String {
      /// Returns a string by repeating it 'times' times
      func repeat(times: Int) -&gt; String {
          var result = ""
          for i in 0..times {
              result += self
          }
          return result
      }
  }
  </code></pre>
  
  <p>There are two other extensions within my repository on github: <a href="https://github.com/drewag/SwiftPlusPlus">SwiftPlusPlus</a> that also do not link (both on generic strucs). You will reproduce the errors if you pull the latest commit, build the framework, and then try to run the unit tests.</p>
  
  <p>So far I have tried to run "strings" on the outputted framework and intermediate files and I do not see the symbols for these extensions but I do see the symbols for the <code>repeat</code> method extension on <code>String</code>. So it doesn't even seem to be compiling them into the library.</p>
  
  <p>Does anyone know why the symbols are not defined in the framework?</p>
  
  <p><strong>Edit</strong></p>
  
  <ul>
  <li><a href="https://github.com/drewag/SwiftPlusPlus/blob/master/SwiftPlusPlus/Optional%2BSwiftPlusPlus.swift">Here</a> is a link to my Optional Extension</li>
  <li><a href="https://github.com/drewag/SwiftPlusPlus/blob/master/SwiftPlusPlusTests/Optional%2BSwiftPlusPlusTests.swift">Here</a> is a link to the test file that causes the linker error when trying to compile the test target</li>
  </ul>