Alex Bollbach
Alex Bollbach

Reputation: 4570

Using Swift in Objective-C project

Although I have followed and tried everything from This Thread and read all of Apple's Guide of Swift-ObjC interoperability, I'm unable to recognize or use Swift fies in my project.

I have created a Swift file that declares/defines a class called TorusView that inherits from UIView. I've tried to gain access to this class in another class MenuView by importing the bridging header, importing the Swift class, importing the class with the syntax *-swift.h (which seems to now be *.swift.hin Xcode7.2). I've made all of the modifications to my target build settings recommended in that lengthy Stack question and a variety of others from google searches.

Nothing I've tried has allowed me to create a TorusView objective in my objective-C class.

Upvotes: 0

Views: 410

Answers (2)

woodruff
woodruff

Reputation: 16

first: Build Settings --> defines module --> YES.

second:Product Module Name -->YOUR project NAME.

last:improt "YOUR project NAME-Swift.h" in your Object-c file

like this: enter image description here

Upvotes: 0

feb
feb

Reputation: 1668

You need to import a header file YourAppName-Swift.h, it contains all the public (and internal if same target) declared types in Swift.

Upvotes: 0

Related Questions