allenlinli
allenlinli

Reputation: 2154

Can not reference (subclassed) Swift classes after set failed: failed after changed to BUILD_LIBRARY_FOR_DISTRIBUTION = YES

The problem is as the title.

Here is the reproduce steps:

  1. Create a project based on Objective-C
  2. Create a Swift class which subclass UIViewController. It will create a bridging header automatically.
  3. Use the Swift class within the Objective-C project (e.g. the default ViewController) by adding "#import "FooProjectName-Swift.h" to the top of the Objective-C file.
  4. set BUILD_LIBRARY_FOR_DISTRIBUTION = YES (The WWDC video talked about this)
  5. Xcode will show an error that suggests us to remove the briding header
  6. Remove the briding header as suggested
  7. The Swift class will not be referenced, and Xcode shows the error

Here is the sample project with commits showing these steps https://github.com/allenlinli/BUILD_LIBRARY_FOR_DISTRIBUTION-Bug-When-Use-Swift

Upvotes: 0

Views: 301

Answers (1)

allenlinli
allenlinli

Reputation: 2154

Figured out that I should set only BUILD_LIBRARY_FOR_DISTRIBUTION = YES for a framework target, not a sample app target.

Upvotes: 1

Related Questions