#import "Project-Swift.h" The file is not updated

I have a project with Swift and Objective-C code. In my current project, I have a problem with the file #import "Project-Swift.h"

not updating if I add new Swift modules.

#import "Project-Swift.h" // does not refresh if I add .swift files

      

So, fast code is not available in an Objective-C universe. files exist but only contain defaults #defines

, etc. There are no project related materials.

Clearing cache, rebuilding, deleting Derived Data doesn't help.

+3


source to share


3 answers


I decided. I forgot @objc(<class>)

. It is necessary.

Details here (Migration)

Migrating Objective-C Code to Swift



And here (Swift Type Compatibility)

Interacting with the Objective-C API

+3


source


Just use @objc in front of the Swift class you want to use in your Object-C code, then build the project. For example:

 @objc class Person : NSObject
 {
  // Swfit code goes here.
 }

      



The #import "Project-Swift.h" will now be available in your project.

+1


source


In my case, it worked to create a different target that I used in my project:

  • Make sure your class is prefixed with @objc

  • Choose another scheme (goal) enter image description here
  • Build || Run
  • Updating the bridge file
  • Change the schema to the goal I was working on
+1


source







All Articles