Declare issue

I use Jims NSScrollerCanvas and it works fine.

But I got one user that always get this error:

An exception of class FunctionNotFoundException was not handled. The application must shut down.
Exception Message: Could not load objc_allocateClassPair from Cocoa.Framework

He is using OSX10.9.3 and atm he is the only reporting this. I cannot reproduce this either.

Any thoughts?

This is the declare code.

[code]soft declare function initWithFrame lib “Cocoa” selector “initWithFrame:” (obj_id as Ptr, frameRect as NSRect) as Ptr
soft declare function alloc lib “Cocoa” selector “alloc” (classRef as Ptr) as Ptr
soft declare sub release lib “Cocoa” selector “release” (classRef as Ptr)
soft declare sub addSubview lib “Cocoa” selector “addSubview:” (id as Ptr, aView as Ptr)
soft declare sub setAutoresizingMask lib “Cocoa” selector “setAutoresizingMask:” (id as Ptr, mask as uint32)
soft declare sub setDoubleValue lib “Cocoa” selector “setDoubleValue:” (id as Ptr, value as Double)
soft declare sub setKnobProportion lib “Cocoa” selector “setKnobProportion:” (id as Ptr, value as single)
soft declare sub setScrollerStyle lib “Cocoa” selector “setScrollerStyle:” (id as Ptr, value as uint32)
soft declare sub setEnabled lib “Cocoa” selector “setEnabled:” (id as Ptr, value as Boolean)
soft declare sub setAction lib “Cocoa” selector “setAction:” (id as Ptr, value as ptr)
soft declare sub setTarget lib “Cocoa” selector “setTarget:” (id as Ptr, value as ptr)
soft declare sub setKnobStyle lib “Cocoa” selector “setKnobStyle:” (id as Ptr, value as integer)
soft declare sub setControlSize lib “Cocoa” selector “setControlSize:” (id as Ptr, value as uint32)

soft declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
soft declare function class_replaceMethod lib “Cocoa.Framework” (cls as ptr, name as Ptr, imp as Ptr, types as CString) as ptr
soft declare function class_addMethod lib “Cocoa” (cls as Ptr, name as Ptr, imp as Ptr, types as CString) as Boolean
soft declare function method_setImplementation lib “Cocoa.Framework” (cls as ptr, name as Ptr, imp as Ptr) as ptr
soft declare function NSSelectorFromString lib “Cocoa.Framework” (aSelectorName as CFStringRef) as Ptr
soft declare function object_getClass lib “Cocoa.Framework” (obj as Integer) as Ptr
soft declare Function object_setClass lib “Cocoa.Framework” (obj as ptr,c as ptr) as ptr
soft declare function objc_allocateClassPair lib “Cocoa.Framework” (superclass as Ptr, name as CString, extraBytes as Integer) as Ptr
soft declare sub objc_registerClassPair lib “Cocoa.Framework” (cls as Ptr)[/code]

The library should be “libobjc.dylib” (or “libobjc.a.dylib”) for all declares starting with the declare of class_replaceMethod (except for NSSelectorFromString which is correct).

Not sure if I am following here. That should not explain why it is working al but one user. He is running the same OSX version as I do.

Or am I wrong?

Tried it and the user now gets:

Exception Message: Could not load NSSelectorFromString from Cocoa.Framework

:slight_smile:

You made one change too much:

Well, I didn’t changed that.

BTW I removed some declares that are not needed.
This is the new declare code:

But that one user keeps getting:
Exception Message: Could not load NSSelectorFromString from Cocoa.Framework

[code] soft declare function initWithFrame lib “Cocoa” selector “initWithFrame:” (obj_id as Ptr, frameRect as NSRect) as Ptr
soft declare function alloc lib “Cocoa” selector “alloc” (classRef as Ptr) as Ptr
soft declare sub release lib “Cocoa” selector “release” (classRef as Ptr)
soft declare sub addSubview lib “Cocoa” selector “addSubview:” (id as Ptr, aView as Ptr)
soft declare sub setAutoresizingMask lib “Cocoa” selector “setAutoresizingMask:” (id as Ptr, mask as uint32)
soft declare sub setDoubleValue lib “Cocoa” selector “setDoubleValue:” (id as Ptr, value as Double)
soft declare sub setKnobProportion lib “Cocoa” selector “setKnobProportion:” (id as Ptr, value as single)
soft declare sub setScrollerStyle lib “Cocoa” selector “setScrollerStyle:” (id as Ptr, value as uint32)
soft declare sub setEnabled lib “Cocoa” selector “setEnabled:” (id as Ptr, value as Boolean)
soft declare sub setAction lib “Cocoa” selector “setAction:” (id as Ptr, value as ptr)
soft declare sub setTarget lib “Cocoa” selector “setTarget:” (id as Ptr, value as ptr)
soft declare sub setKnobStyle lib “Cocoa” selector “setKnobStyle:” (id as Ptr, value as integer)
soft declare sub setControlSize lib “Cocoa” selector “setControlSize:” (id as Ptr, value as uint32)

soft declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
soft declare function class_addMethod lib “Cocoa” (cls as Ptr, name as Ptr, imp as Ptr, types as CString) as Boolean
soft declare function NSSelectorFromString lib “Cocoa.Framework” (aSelectorName as CFStringRef) as Ptr
soft declare function objc_allocateClassPair lib “libobjc.dylib” (superclass as Ptr, name as CString, extraBytes as Integer) as Ptr
soft declare sub objc_registerClassPair lib “libobjc.dylib” (cls as Ptr)[/code]

OK, it is fixed and you are not going to believe why it was happening on that users system.

The problem is the declare lib name.
It was:
soft declare function NSSelectorFromString lib “Cocoa.Framework” (aSelectorName as CFStringRef) as Ptr

but it should be:
soft declare function NSSelectorFromString lib “Cocoa.framework” (aSelectorName as CFStringRef) as Ptr

Notice the lowercase of ‘f’ in Cocoa.framework.

That user has a HD formatted with Mac OS Extended (Case sensitive, Journaled) ?
So it didn’t find the framework. :slight_smile:

Not sure why people would run OSX with with Mac OS Extended (Case sensitive, Journaled).

Oh my I’l have to fix this… I just had a report of a similar error in piDogScrollingCanvas.

The the .framework extension can be left out.

Me neither! But they do! If you can set-up a machine with case sensitive file system, just to catch these weird errors! Apple do advise Objective-C developers to pay attention to case sensitivity, because they allow this option in the first place.

btw, if you change it from “Cocoa.framework” to “Cocoa” it should auto resolve the .framework for you :slight_smile: