Aleem
Aleem

Reputation: 3291

Objective c and Swift using in Framework in Xcode

I've my own old framework which is only compatible in objective c, but Now I open in new xcode and added few swift classes (Xcode not gave me option to create bridging as this do in normal App when you add swift class in objective c project), Also Xcode gave me suggestion to update build setting and I updated those and currently I'm on Xcode 8.2.1. Now I try to build but I am getting few error as you can see in picture . I googled and found solution to delete derive data and quite xcode and open and clean. I done Everything but didn't workout.

Need help and suggestion. enter image description here

Upvotes: 1

Views: 3852

Answers (1)

yageek
yageek

Reputation: 4465

When you are mixing Swift/Objc inside a framework, you can import Swift code for Objective-C use and import Objective-C from Swift.

First, ensure that Define Settings is set for the current framework target.

To import Swift into Objective-C: In each Objective-C file that requires the Swift code, import the generated Swift header with the complete current Framework Path : #import <Framework/Framework-Swift.h>

To import Objective-C into Swift:

Ensure you have an umbrella header. The path can be found inside the Build Settings of the target. In this header, import all the needed Objective-C headers like normally in Objective-C: #import "Header"

Source: https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-ID122

Upvotes: 2

Related Questions