views:

120

answers:

2

Hello,

I made a custom cocoa framework just to experiment and find the best way to make one but ran in to a problem using it. The framework project builds and compiles just fine, but when I use it in an xcode project I get the error, 'LogTest' undeclared. The name of the framework is LogTest

Heres the code to my app that uses the framework:

TestAppDelegate.h:

#import <Cocoa/Cocoa.h>
#import <LogTest/LogTest.h>

@interface TestAppDelegate : NSObject <NSApplicationDelegate> {

NSWindow *window;

}

@property (assign) IBOutlet NSWindow *window;

@end

TestAppDelegate.m:

#import "TestAppDelegate.h"

@implementation TestAppDelegate

@synthesize window;

- (void)awakeFromNib {
[LogTest logStart:@"testing 123":@"testing 1234"]; //This is the line where the error occurs
}


@end

Framework Code........

LogTest.h:

#import <Cocoa/Cocoa.h>
#import "Method.h"


@protocol LogTest //Not sure if this is needed I just wanted a blank header


@end

Method.h:

#import <Cocoa/Cocoa.h>


@interface Method : NSObject {

}


+ (void)logStart:(NSString *)test:(NSString *)test2;

  @end

Method.m:

#import "Method.h"


@implementation Method

+ (void)logStart:(NSString *)test:(NSString *)test2 {
NSLog(test);
NSLog(test2);
}

@end

If anyone knows why I am getting this error please reply.

Thanks for any help

A: 

You can't use compiled third-party frameworks on iPhone. You CAN include the source files and then compile them along with your app.

Also, see the other discussions at this link.

Dustin Pfannenstiel
Im not using iPhone but thanks for the reply
happyCoding25
A: 

From what I see of the header files you just posted. LogTest is not a class but an empty protocol. You should be calling logStart:: on Method not LogTest

IOW. change it to

- (void)awakeFromNib {
    [Method logStart:@"testing 123":@"testing 1234"];
}
Brandon Bodnár
Okay Thanks I'll try that
happyCoding25
When I do that I get a whole new set of errors in the build results.
happyCoding25
Those errors were likely being hidden by the previous error. The same matter before was that you were calling methods on a class that didn't exist.If you post your new errors we can see if we can help.
Brandon Bodnár
Ok well thanks the new error seems to be common in xcode: dyld: Library not loaded: (a long path here) Reason: image not found
happyCoding25
If I remember correctly that is something to due with the XCode not finding the dylib for the framework at runtime. A copy needs to be in the either /Library/Frameworks /System/Library/Frameworks or in the build folder of the product.
Brandon Bodnár
Or, you need to copy the framework into your app. http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html#//apple_ref/doc/uid/20002258-106880-BAJJBIEF
Peter Hosey