0

I am inexperienced with Objective-C and this is my first attempt at anything Swift. I Can't get Xcode to compile. ( I may also be missing a necessary line or two, but if I get it to compile, I can usually figure out the rest )

I've been all over docs and getting started, I don't know enough to know the answer if it's there:
http://bustoutsolutions.github.io/siesta/guide/objc/
https://bustoutsolutions.github.io/siesta/api/

My Code:

// MyAPI.swift
import Siesta
import SwiftyJSON

@objc class MyAPI: Service {
    internal static let instance = MyAPI(baseURL:"https://api.example.com")
}

// ViewController.mm
#import "ViewController.h"
#import "PlateScanner.h"
#import "Plate.h"
#import "MyProject-swift.h"
...
- (IBAction)callAPI:(id)sender
{
   [[MyAPI.instance resource:@"/profile/"] child:@"123"];
}

-(void)resourceChanged: (BOSResource*) resource event: (NSString*)   event {
    if([event hasPrefix:@"NewData"]) {
        NSLog(@"%@",[resource text]);
    }
}
...

I get the following 2 errors from ViewController.mm:
1. line starting "[[MyAPI": No visible @interface for 'MyAPI' declares the selector 'resource:'
2. line starting "-(void)reso": Expected a type

From this I understand that my ViewController is not understanding the necessary BOSResource type, but I don't know how to get the swift library imported properly?

Xcode generated code:

//MyProject-swift.h
...
SWIFT_CLASS("_TtC10MyProject5MyAPI")
@interface MyAPI : BOSService
+ (MyAPI * _Nonnull)instance;
@end
...

With Error in line starting "@interf...": Cannot find interface declaration for 'BOSService', superclass of 'MyAPI'

Any help is greatly appreciated!

markjwill
  • 206
  • 5
  • 15
  • Your code appears to work in a `.m` file, but gives errors in a `.mm`. Siesta hasn’t been tested with Objective-C++ — only Objective-C. I'm not even entirely sure it's possible to use Swift bridging headers from Objective-C++. If you don’t need the C++ features, switching to `.m` may fix your problem. – Paul Cantrell May 09 '16 at 15:13
  • Pretty sure you are correct ( though still getting some errors ). I am using the Objective-C++ for some OCR library work, but I think I can move that code out of my ViewController perhaps... much to try, thanks for the direction – markjwill May 10 '16 at 12:36

0 Answers0