使用Firebreath框架将可可应用程序转换为NPAPI插件 [英] Converting a cocoa application to a NPAPI plugin with the Firebreath framework

查看:140
本文介绍了使用Firebreath框架将可可应用程序转换为NPAPI插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我发现,在Lion和Safari的最后一个版本中,Apple不会支持webkit模型,并且每个人都迁移到Firebreath项目以使用NPAPI。



有一个基本的Cocoa应用程序与以下本地框架链接:


  1. CoreGraphics

  2. li>
  3. IOKit

  4. PFEventTaps(这是一个3方框架:Pfiddlesoft.com)

我从来没有使用PlugIns,所以这对我来说是一个新的,我开始使用由Richard bateman编写的MAC教程,遵循指南后,我的个人项目Firebreath项目模板。我做的下一步只是把我所有的Objective-C类放入源文件文件夹添加与4框架的链接,最后我添加了我需要公开的插件到MyProjectPluinApi.h中的新的公共方法例如( registerMethod(MyMethod,make_method(this,& WilmerPlugInAPI :: MyMethod));



当我构建firebreath项目时,会出现很多编译错误,它们非常重复是:
NSString没有在这个范围内声明。错误指向NSObjCRuntime.h



到现在为止我无法使用XCODE 3.2.6成功地建立这个生成



这里有什么错误?我需要改变所有的代码来完成CPP风格这个模板项目?或者我可以链接我的框架在某些方面?
有一些样品我可以看到



更多细节:2011年11月7日:
我试图用一个简单的项目测试:




  • 首先我创建项目testOfFB

    • 它是在/ users / Me / Firebreath-dev / build / projects / testofFB


  • 中生成

  • 我写了一个名为testMath.m的Objective-c类,并将其重命名为testMath.mm

  • 我添加一个方法添加签名:

       - (长)添加: )b:(长)c; 


  • 最后我修改文件testFBApi.mm:

      registerMethod(add,make_method(this,& testFBAPI :: add)); 


  • 在add方法的实现中,创建一个objective-c类方法添加来测试对我的objective-c方法的调用。我做了包含和我改变文件/Mac/projectDef.cmake这样:

      target_link_libraries($ {PROJECT_NAME} 
    $ {PLUGIN_INTERNAL_DEPS}
    $ {Cocoa.framework} //添加行
    $ {Foundation.framework} //添加行




我运行prepmac.sh脚本,然后生成xcode解决方案,

解决方案

很难说没有更多的信息,但你可能需要更新你的cmake文件导入所需的框架;如果你在xcode中这样做,它应该可能工作,但我没有尝试这种方式。你应该知道,用cmake添加它不会将它添加到xcode中的框架列表,尽管它应该在那里。



如果你需要使用objective-c代码和c ++代码在同一个文件中,你需要使用.mm文件扩展名(objective-c ++)而不是更常见的.m(objective-c)扩展名。



除此之外,我需要看到更多的代码,以猜测可能是错误的肯定;我想你也许你缺少包括,例如。请注意,如果您的旧项目中有PCH,则很可能不会在新项目中使用。



有关使用cmake添加框架的详细信息,请参阅 http://www.firebreath.org/display/documentation/Using+Libraries p>

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.

解决方案

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

这篇关于使用Firebreath框架将可可应用程序转换为NPAPI插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆