Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate definition of category 'my_framework' on interface 'NSObject'

I am in the process of updating my app and a common library (dynamic framework). What once was a static library as an Xcode subproject, is now a dynamic framework that contains swift code.

When writing my app's code, I'm seeing some compiler warnings. At this time, they're only warnings.

In my app's MainViewController I include a file that's written in swift. And so this has an import of App-swift.h. Inside of this autogenerated App-swift.h, there is section:

#if defined(__has_feature) && __has_feature(modules)
@import UIKit;
@import my_framework;
#endif

Inside of this 'my_framework' I have a category method on various files, e.g. NSObject+my_framework.h

Now, I'm getting a compiler warning for MainViewController.m saying "Duplicate definition of category 'my_framework' on interface 'NSObject'". The drop down supplies the locations of both definitions. One location is the actual category header file inside of my framework. The compiler 'sees' this location via it being included through the pch file. The other location links directly to my App-swift.h file at the line "@import my_framework".

Is there any way to avoid this warning?

like image 697
FishStix Avatar asked Dec 25 '22 09:12

FishStix


2 Answers

use @import or #import <FMK/FMK.h> instead #import "fmk.h"

like image 168
Will Avatar answered Dec 26 '22 22:12

Will


Same issue for me, I delete the line module * { export * } from my_framework.framework/Modules/module.modulemap, so it looks like :

framework module my_framework {
   umbrella header "my_framework.h"

   export *
}

And the warnings disappeared. Then, added module.modulemap to my_framework project, and setted its path to the MODULEMAP_FILE build setting.

like image 21
ıɾuǝʞ Avatar answered Dec 27 '22 00:12

ıɾuǝʞ