From Objective-C framework back to Max?
I’m working on a Max port of a fairly large Objective-C project. I decided to do this by creating a framework for my Obj-C stuff, and then calling on the framework methods/classes in my external. Going one way this is fine — that is, from Max to the framework. But I’m not sure how I can communicate with Max from the framework classes. That is, how can I call methods in my Max external from the framework (so that I can, for example, output info generated in the framework out an object’s outlet). Looking at other examples that use Obj-C it seems like the idea is to set a void pointer in the Obj-C class with a reference to the Max class. But I’m not sure how I can do that in my framework. I tried adding the MaxAPI.framework to my project (the framework project, not the external), but I realize it isn’t an ordinary framework (i.e., no headers). I also tried adding the headers separately (with the MaxAPI.framework), but that didn’t seem to work either… Any tips appreciated.
okay, found it. Problem was just in the project search paths. All good now.
Love to see how you accomplished this, as I’m both a C and ObjC noob and am trying to do something similar. Any chance of you sharing your code?
I remember that this was quite a pain to get working, and even now, when Apple updates something it all seems to get (temporarily) broken. But it seems to me the big "tricks" are: 1) to make sure your Header Search Paths (in Build Settings in Xcode) points to your Max SDK folder, and 2) to create User-Defined settings for C74SUPPORT, and C74_SYM_LINKER_FLAGS. For 1) I added "$(C74SUPPORT)/max-includes" to Header Search Paths, and for 2) I went to Editor->Add Build Setting… and added a new item for C74SUPPORT with an entry of "$(SRCROOT)/../../../c74support" and another item for C74_SYM_LINKER_FLAGS with an entry for "@$(C74SUPPORT)/max-includes/c74_linker_flags.txt". To get it to use my Obj-C framework, the easiest way I found was to create a Workspace and add both my framework project and the max external project to the Workspace. That allowed the external to find my framework and everything seems to work. Be warned, though, that this was a highly unscientific and hackish process for me. It works, and I mess with it at my own peril!
Hey, thanks for that….I’m still sussing out the coding conventions, but I do seem to be getting somewhere ;)