I am writing a Swift extension for my ObjC class. Although my code compiles and works fine, I get a bunch of Xcode warnings (one for each Swift):
"Method definition for 'foo_method:' not found" "Method definition for 'bar_method:' not found" "Method definition for 'baz_method:' not found"
He is dead just to play an Xcode message. I did this demo project with four lines of custom code:
Objective-C (subclass of NSView)
// Subclass_of_NSView.h #import <Cocoa/Cocoa.h @interface Subclass_of_NSView : NSView @end // Subclass_of_NSView.m @implementation Subclass_of_NSView - (instancetype)initWithFrame:(NSRect)frame //______________^ WARNING: Method definition for resizeSubviewsWithOldSize: not found { self = [super initWithFrame:frame]; if (self) { // Initialization code here. } return self; } @end
Swift (extends a subclass of Obj-C)
// Extension_of_Subclass.swift import Foundation extension Subclass_of_NSView { override func resizeSubviewsWithOldSize( old_bounds_size:NSSize ) { } }
Bridging header
// Demo_Project-Bridging-Header.h
I assume the warnings will disappear if I, too:
a) create a bunch of dummy methods in the .m file of my ObjC class.
b) in my Swift extension, extend the superclass class of the ObjC class.
I do not like any of these solutions.
Is there a better way to make the compiler happy?
source share