0

I have a webservice written in objective C. I want it access it from swift file. How do I achieve that? My attempt so far:

Webservice.h

#import <Foundation/Foundation.h>

typedef void(^WebServiceCompletionHandler)(id result,BOOL isError,NSString *strMsg);

@interface Webservice : NSObject
@property(strong,nonatomic) NSString *strURL;

-(void)registerWithFullName:(NSString*)strFullName ContactNumber:(NSString*)strContactNumber WithCompletionHandler:(WebServiceCompletionHandler)handler;

@end

Webservice.m

@implementation Webservice

-(id)init
{
    if (self=[super init])
    {
        self.strURL=@"www.abc.com/registration";
    }
    return self;
}

-(void)registerWithFullName:(NSString*)strFullName ContactNumber:(NSString*)strContactNumber WithCompletionHandler:(WebServiceCompletionHandler)handler{

         //Implementation
}

Now the swift file where I want to call the webservice.

Register.swift

override func viewDidLoad {

let service  = Webservice.init()
heyWeb.registerWithfullName("Test", contactNumber: "+1039383838383", withCompletionHandler: { (result, isError, strMsg) -> Void in

                })
}

But I am getting the following error while running the project.

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_Webservice", referenced from:
      type metadata accessor for __ObjC.Webservice in Register.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Can anyone help me to figure out the problem?

Poles
  • 3,585
  • 9
  • 43
  • 91

1 Answers1

0

create one bridge file with name -Bridging-Header.h and import your objc file in that bridge file, and finally Goto Project settings and give the path of that bridge file in Objective C Bridging Header as follows Sample-Bridging-Header.henter image description here

Satyanarayana
  • 1,059
  • 6
  • 16
  • i think you need to add ios default frame work which is missed and it is required for WebService class – Satyanarayana Apr 06 '16 at 12:14
  • may be the following link will help for you , http://stackoverflow.com/questions/26559904/undefined-symbols-for-architecture-x86-64-on-xcode-6-1 – Satyanarayana Apr 06 '16 at 12:17