WhoopsBing
WhoopsBing

Reputation: 533

Swift Compiler Errors caused by Importing Header File in Bridging Header

  1. My project builds and runs successfully.
  2. I create a bridging header, so that I can segue between my Swift and Objective-C views.
  3. I import my Objective-C header file in my bridging header.
  4. All of a sudden, I have 40 swift compiler errors in my Objective-C header file that I imported. (image attached for details)

Image

Why does this happen, and how can I fix it? My ViewController.h file ran perfectly before I imported it in my bridging header.

Upvotes: 0

Views: 288

Answers (1)

Dave Weston
Dave Weston

Reputation: 6635

To define constants in an Objective C header file, you'll want to do something like this:

// header file
FOUNDATION_EXPORT static CGFloat MyNamespaceAlpha;

// implementation file
static CGFloat MyNamespaceAlpha = 0.8f;

Upvotes: 0

Related Questions