You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
4. Next add the Objective C header file to the bridging header to expose the class to Swift.
//ForwardAndBack-Bridging-Header.h//// Use this file to import your target's public headers that you would like to expose to Swift.//
#import"MKCFoo.h"
5. Finally try to use the property (which is a Swift class exposed using @objc) defined on the Objective C file.
//Baz.swift
import Foundation
publicfinalclassBaz{func executeFoo(_ foo:MKCFoo){// This line below will not work as long as Bar.swift has the following @objc(MKCBar) attribute.// foo.bar}}
6. Last but not least try to remove the name from @objc and update accordingly
// Now try to replace @objc(MKCBar) in Bar.swift with just @objc and update the forward decleration in MKCfoo.h and correct the type in MKCfoo.m and now the line below will work but I've lost the prefix :-(// foo.bar
Attachment: Download
Environment
Xcode 10 and Xcode 11 beta
Additional Detail from JIRA
md5: 3a6000ace6d82ee762847b7fd7085767
duplicates:
Issue Description:
The problem is related when going from Swift->ObjC->Swift.
1. Create the Bar class and prefix the class for Objective C using @objc(...).
2. Use forward declaration from the Objective C header file to avoid circular references.
4. Next add the Objective C header file to the bridging header to expose the class to Swift.
5. Finally try to use the property (which is a Swift class exposed using @objc) defined on the Objective C file.
6. Last but not least try to remove the name from @objc and update accordingly
Please see the attached project or the problem described in this blog post https://cjwirth.com/tech/circular-references-swift-objc
The text was updated successfully, but these errors were encountered: