Exposing a C Function from a Custom Objective-C Framework

I'm trying to write my first custom Cocoa Framework, and I want to expose a simple C function from a framework that wraps a bunch of functionality like NSApplicationMain does. When I just imported the files directly from the project, everything went fine, the project was built, and my C function was called correctly.

Now I have a new Cocoa Framework project that contains files, I can’t create my program because I get "No characters found" error messages, especially for my C function.

I tried the function definition prefix in the header file using extern, but still nothing.

Can anyone give me a head? How can I expose standard C functions through a custom Cocoa Framework?

A rough idea of ​​what I'm doing:

My program that uses my own framework:

#import <BDWebApplicationFramework/BDWebApplication.h> int main (int argc, const char * argv[]) { return BDWebApplicationMain(argc, (const char **)argv); } 

My frame header: BDWebApplication.h

 #import <Foundation/Foundation.h> @interface BDWebApplication : NSObject { NSString *name; } @property (readwrite, copy) NSString *name; @end extern int BDWebApplicationMain(int argc, const char * argv[]); 

My framework file: BDWebApplication.m

 #import "BDWebApplication.h" @implementation BDWebApplication @synthesize name; - (id)init { [super init]; name = @"New name"; return self; } - (void)dealloc { [name release]; [super dealloc]; } @end int BDWebApplicationMain(int argc, const char * argv[]) { // Do some Obj-c stuff here } 
+4
source share
1 answer

The problem here is almost certainly hidden in your Xcode build settings, and not in the code you posted (which looks good).

First of all: are you becoming attached to your new structure? Assuming you are, are you sure you are exporting characters that you think when you build the framework? (There are several options to indicate this, and some of them have semantics, which may surprise the careless.)

What would be more useful in helping you diagnose this is the full text of the transcripts of the Xcode assembly for both the framework and the executable.

+3
source

All Articles