Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#import "Project-Swift.h" File does not refresh

I have a project with Swift and Objective-C code. In my current project I have the problem that the #import "Project-Swift.h" file does not refresh if I add new Swift modules.

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

So in the Objective-C universe, the swift code is not available. the files exists, but does only contains default #defines etc. No project related stuff.

Clear Cache, rebuild, delete Derived Data does not help.

like image 449
testing-engineer-4711 Avatar asked Oct 18 '25 17:10

testing-engineer-4711


2 Answers

Solved it. Forgot @objc(<class>). It is mandatory.

Details here (Migrating)

Migrating Objective-C Code to Swift

And here (Swift Type Compatibility)

Interacting with Objective-C APIs

like image 99
testing-engineer-4711 Avatar answered Oct 20 '25 08:10

testing-engineer-4711


In my case it worked by building for the other target I had on my project:

  • Check you have prefixed your class with @objc
  • Choose the other scheme (target) enter image description here
  • Build || Run
  • The bridging file updates
  • Change the scheme back to the target I was working on
like image 30
Juan Fran Jimenez Avatar answered Oct 20 '25 07:10

Juan Fran Jimenez