Convert cocoa application to NPAPI plugin with Firebreath framework

I recently discovered that the webkit model will not be supported by Apple in the latest release of Lion and Safari, and that everyone is migrating to the Firebreath project to use NPAPI.

I have a Cocoa base application that references the following built-in frameworks:

  • Coregraphics
  • CoreData li>
  • Iokit
  • PFEventTaps (this is a 3-way structure: Pfiddlesoft.com)

I have never used PlugIns, so for me this is a little new, I started with a MAC tutorial written by Richard Batemant, and after I follow the recommendations, I end the firebreath project template for my personal project. The next step I took was to simply put all my Objective-C classes in the Source Files folder, adding a link to 4 frameworks, and finally I added new public methods that I need to open in the MyProjectPluinApi.h plugin, for example (registerMethod ("MyMethod", make_method (this, and WilmerPlugInAPI :: MyMethod));

When I create a firebreath project, I get many compilation errors, one of which is very repetitive: NSString was not declared in this scope. The error points to NSObjCRuntime.h

So far, I cannot get this assembly successfully with XCODE 3.2.6

what's wrong here? Do I need to change all my code to execute CPP style in this template project? Or can I somehow tie my framework? Is there any pattern that I can see?

LEARN MORE: November 7, 2011: I tried to check out a simple project:

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

     -(long) Add:(long)a:(long)b:(long)c; 
  • Finally, I modify the testFBApi.mm file as follows:

     registerMethod("add", make_method(this, &testFBAPI::add )); 
  • In the implementation of the add method, I create an instance of the method of the Objective-C class "add" to test the call to my Objective-C method. I made inclusions, and I changed the file /Mac/projectDef.cmake 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 create an xcode solution, and the same errors appear, and some others like testFBApi were not declared.

0
source share
1 answer

It's hard to say without additional information, but you may need to update your cmake files to import the frameworks you need; if you do it manually in xcode, it probably should work, but I have not tried this. You should know that adding it with cmake will not add it to the frame list in xcode, although it should be there.

If you need to use objective-c code and C ++ code in the same file, you need to use the .mm file extension (objective-c ++), and not the more common .m (objective-c) extension.

Other than that, I will need to see more of your code to guess what might be wrong; I would suggest that perhaps you are missing, for example, a number. Please note that if you had PCH in your old project, most likely it will not be used in the new project.

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

0
source

Source: https://habr.com/ru/post/1433058/


All Articles