How do I add Objective C code to a FireBreath Project?
Posted
by
jmort253
on Stack Overflow
See other posts from Stack Overflow
or by jmort253
Published on 2012-09-07T21:20:29Z
Indexed on
2012/09/08
3:38 UTC
Read the original article
Hit count: 256
I am writing a browser plugin for Mac OS that will place a status bar icon in the status bar, which users can use to interface with the browser plugin. I've successfully built a FireBreath 1.6 project in XCode 4.4.1, and can install it in the browser. However, FireBreath uses C++, whereas a large majority of the existing libraries for Mac OS are written in Objective C.
In the /Mac/projectDef.make file, I added the Cocoa Framework and Foundation Framework, as suggested here and in other resources I've found on the Internet:
target_link_libraries(${PROJECT_NAME}
${PLUGIN_INTERNAL_DEPS}
${Cocoa.framework} # added line
${Foundation.framework} # added line
)
I reran prepmac.sh, expecting a new project to be created in XCode with my .mm files, and .m files; however, it seems that they're being ignored. I only see the .cpp and .h files. I added rules for those in the projectDef.make file, but it doesn't seem to make a difference:
file (GLOB PLATFORM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Mac/[^.]*.cpp
Mac/[^.]*.h
Mac/[^.]*.m #added by me
Mac/[^.]*.mm #added by me
Mac/[^.]*.cmake
)
Even if I add the files in manually, I get a series of compilation errors. There are about 20 of them, all related to the file NSObjRuntime.h
file:
Parse Issue - Expected unqualified-id
Parse Issue - Unknown type name 'NSString'
Semantic Issue - Use of undeclared identifier 'NSString'
Parse Issue - Unknown type name 'NSString'
...
...
Semantic Issue - Use of undeclared identifier 'aSelectorName'
...
...
Semantic Issue - Use of undeclared identifier 'aClassName'
...
It continues like this for some time with similar errors...
From what I've read, these errors appear because of dependencies on the Foundation Framework, which I believe I've included in the project. I also tried clicking the project in XCode
I'm to the point now where I'm not sure what to try next. People say it's not hard to use Objective C in C/C++ code, but being new to XCode and Objective C might contribute to my confusion. This is only day 4 for me in this new platform.
What do I need to do to get XCode to compile the Objective C code? Please remember that I'm a little new to this, so I'd appreciate it if you leave detailed answers as opposed to the vague one-liners that are common in the firebreath tag. I'm just a little in over my head, but if you can get me past this hurdle I'm certain I'll be good to go from there.
UPDATE:
I edited projects/MyPlugin/CMakeLists.txt and added in the .m and .mm rules there too. after running prepmac.sh, the files are included in the project, but I still get the same compile errors.
I moved all the .h files and .mm files from the Obj C code to the MyPlugin root folder and reran the prepmac.sh file. Problem still exists. Same compile errors.
© Stack Overflow or respective owner