0

I found recently that webkit model will be unsupported by Apple in Lion and Safari last release and that everybody is migrating to Firebreath project in order to use NPAPI.

I have a basic Cocoa Application which links with the following native frameworks:

  1. CoreGraphics
  2. CoreData
  3. IOKit
  4. PFEventTaps ( this is a 3 party framework by: Pfiddlesoft.com)

I've never used PlugIns so this is a little new for me, I started with the MAC tutorial written by Richard bateman and after following the guidelines I ends up with a firebreath project template for my personal project. the next step I made was just puting all my Objective-C classes into the Source Files folder adding the linking with the 4 frameworks, finally I added the new public methods I need to expose in the plug-In into the MyProjectPluinApi.h e.g.( registerMethod("MyMethod", make_method(this, &WilmerPlugInAPI::MyMethod ));

When I build the firebreath project I get a lot of compile errors, one of them very repetitive is: NSString was not declared in this scope. The error points to NSObjCRuntime.h

Until now I can't get this build succesfully with XCODE 3.2.6

what is wrong here? I need to change all my code to accomplish the CPP style in this template project? Or I can link my frameworks in some way? Is there some sample I can see?

MORE DETAILS: Nov 7 2011: I was trying to test with a simple project:

  • First I create the project testOfFB
    • it is generated in /users/Me/Firebreath-dev/build/projects/testofFB
  • then I modify the class testFBApi.cpp and rename it to testFBApi.mm.
  • I wrote an Objective-c class named testMath.m and rename it to testMath.mm
  • I add a method Add with the signature:

    -(long) Add:(long)a:(long)b:(long)c;
    
  • Finally I modify the file testFBApi.mm with this:

    registerMethod("add", make_method(this, &testFBAPI::add ));
    
  • In the implementation of add method I create an instance of the objective-c class method "add" to test the calling to my objective-c method. I did the includes and I changed the file /Mac/projectDef.cmake in this way:

    target_link_libraries(${PROJECT_NAME}
        ${PLUGIN_INTERNAL_DEPS}
        ${Cocoa.framework} // added line
        ${Foundation.framework} //added line
    )
    

I run the prepmac.sh script and then build the xcode solution and same errors appear plus some others like testFBApi has not been declared.

taxilian
  • 14,229
  • 4
  • 34
  • 73
willyMon
  • 612
  • 8
  • 19

1 Answers1

0

It's hard to say without a bit more information, but you may need to update your cmake files to import the frameworks you need; if you're doing that by hand in xcode it should probably work as well, but I haven't tried that way. You should know that adding it with cmake will not add it to the framework list in xcode, though it should be there.

If you need to use objective-c code and c++ code in the same file you'll need to use the .mm file extension (objective-c++) rather than the more common .m (objective-c) extension.

Other than this, I'd need to see more of your code to guess what might be wrong for sure; I would guess perhaps you have missing includes, for example. Note that if you had a PCH in your old project it is most likely not being used in the new project.

For more info on adding the frameworks with cmake see http://www.firebreath.org/display/documentation/Using+Libraries

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • I give more details in the original post below under section MORE DETAILS. but basically I did all what is mentioned I don't know if I am missing something or I am doing wrong things with the includes of the frameworks inside XCODE by the way I did everything by hand, I can't figure out another way to do it. With the help of XCODE. – willyMon Nov 07 '11 at 17:06
  • It sounds very much like you are missing include files. I bet your original project has a PCH; when you have a PCH it automatically includes anything in the PCH in every file, but with FireBreath/cmake you can't use that PCH so it no longer works. You probably just need to copy the includes from there into your other files. Do you have #import at the top of your files that are complaining? – taxilian Nov 07 '11 at 19:40
  • Ok Taxilian thanks for your help, at last my project compiles well. Nevertheless, I am wondering why the objective-c classes I have created in the xcode project appear under the "firebreath-dev" folder? this seems so strange because when I close the project and then re-open it again I don't see the objective-c classes but when I browse to the firebreath-dev folder I can see all of them there. by the way if I add another new framework to my project and another objective-c class, do I need to run prepmac.sh again?? – willyMon Nov 08 '11 at 16:34
  • xcode is adding them to the wrong place; it's best to add files to the filesystem where you want them then rerun the prep script. It's a disadvantage to using cmake :/ (advantages outweight the disadvantages, though) – taxilian Nov 08 '11 at 16:35