Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 8 with mixed Swift and Objective-c project generated "ModuleName-Swift.h" header not found

I have a project with mixed Swift and Objective-C in Xcode 8 that uses the generated "ModuleName-Swift.h" header file to import swift into Objective-c classes, but the preprocessor is not able to find the generated header file and throws an error on the import.

"Lexical or Preprocessor issue : 'ModuleName-Swift.h file not found'"

enter image description here

The project compiles just fine, but the preprocessor throws errors for the header not being found and for any Swift classes called inside the class there is no syntax highlighting or code completion. It's a struggle working with Swift classes in Objective-c that are unrecognized by Xcode 8, but yet compile just fine.

Any ideas on how to appease the preprocessor in Xcode 8?

like image 677
myuiviews Avatar asked Sep 23 '16 19:09

myuiviews


4 Answers

I had exactly the same issue. Found the solution after adding a new file aiming to only one target (by mistake) and noticing that it had no problem reading the Swift classes. So, if you have multiple targets, and since the migration you didn't have the need to build and run them, suggest you to do that.

like image 128
Ernesto Fernandez Avatar answered Nov 20 '22 20:11

Ernesto Fernandez


Have this problem when we have multiple targets. If the Objective-c Generated Interface Header Name variable in Swift compiler of newly created targets is different than the original target's value. Change it to the same value with original target. See the following:

change, newtargetname-Swift.h to originaltargetname-Swift.h for new target

enter image description here

like image 29
Mesut GUNES Avatar answered Nov 20 '22 22:11

Mesut GUNES


To fix this issue Xcode 9.2, After long research i came to known my "Objective-c Generated Interface Header Name" is named after Product Name "productname-Swift.h"enter image description here

like image 5
datha Avatar answered Nov 20 '22 20:11

datha


You need to add this in your build settings.

There might be an issue while migrating to Xcode 8, where you will have unspecified in the build setting Swift header file.

This if from killerz

Go to Build Settings->Objective-C Generated Interface Header Name and set the value to YourModule-Swift.h (this is usually already set, this is the filename you need to import on .m file #import "YourModule-Swift.h"

like image 1
Tal Zion Avatar answered Nov 20 '22 22:11

Tal Zion