Following the instructions on https://nativescript.org/blog/adding-objective-c-code-to-a-nativescript-app/ I setup a very simple nativescript project (with typescript underneath):
- tns create simpleApp --tsc
- tns platform add ios
- tns prepare ios
- run the generated ios project via xcode.
The app runs correctly.
Next I added a custom obj-c class to the project (App_Resources/iOS/src/Stuff .h and .m):
#import <Foundation/Foundation.h>
@interface Stuff: NSObject
+(void)doStuff;
@end
#import "Stuff.h"
@implementation Stuff
+(void)doStuff {
NSLog(@"I should see this...");
}
@end
And a module.modulemap:
module Stuff {
header "Stuff.h"
export *
}
A tns prapare ios command successfully processes the class.
When I try to add the 'Stuff' object to the typescript source, I get a cannot find name Stuff.
How do I get the marshalling/metadata between typescript and obj-c working? Do I need to run some scripts? add imports? The tutorial does not mention anything about that...
This is what I added to the nativescript default template app:
onTap() {
this._counter--;
this.updateMessage();
Stuff.doStuff();
}
And hoped to see the log text when tapping the button...