How to change my project API class extension - objective-c++

I created a firebreath project with "OpenOnDesktopPlugin" name. I need to change the "OpenOnDesktopPluginAPI" extension from .cpp to .mm, because I need to add some objective c code.
I added the "Mac/[^.]*.mm" line to my ".cmake" files.
The problem is, when I change the extension to ".mm" to my "OpenOnDesktopPluginAPI.cpp" and I run the "prepmac" command, the file is not displayed in my firebreath project tree, but if I go to my finder, the file is there.

You need to edit your CMakeLists.txt file to tell it to include *.mm files from that directory as well.
"Mac/*.mm" won't work because your OpenOnDesktopPluginAPI.mm file isn't in the Mac/ directory.
Is this supposed to be a cross-platform project? if not, then you're okay; if so, then you will probably want to subclass your JSAPI file for mac and put that in a .mm file in your Mac/ directory; Mac/projectDef.cmake is the cmake commands specific to mac. CMakeLists.txt is the cmake commands that are cross platform (unless you don't care about anything but mac, in which case you can put it in both places.
Then of course (if you create a mac-specific subclass) you'll need to either subclass your plugincore class or use "#if FB_MACOSX" preprocessor macros to decide whether to return the mac specific version or not. There are lots of options for how you can do all of this, of course, but this is the way I'd do it.
Hope that helps.

Related

Can you create a file or folder by path in VS Code?

In Atom, hitting Cmd+N brings up a window where you can type in basically any path to create any file or folder anywhere in the project. In VSCode, hitting Cmd+N brings up a dialog where you can create a file in the currently focused folder, and I believe you can type a path to create a file in a subfolder (whether it exists or not), but not as flexibly as in Atom.
Is there way to do it Atom-style in VSCode?
I don't know for sure whether this is what you're looking for, but still there exists this plugin which can emulate the file/directory creation feature of Atom.
Since i use vscode-vim it's fairly easy to create new folders and files using command mode. If you're familiar with using terminal, then you can use shell commands to create file/dir.
I have no idea whether one could do what you had mentioned the proper way with vanilla vscode.
Hope this helps you somehow.

Correct way to copy Swift project without altering old project?

I was wondering if there was a correct way to make a copy of a Swift project?
I realised that when I want to make a copy of a project (so that I can have a backup working copy when I continue with my project and I make a mistake) and I use that copy; the copy alters the build folder of my original file. Not only that but if I re-name classes or change IBLabels/IBOutlets, and although the change isn't reflected in the original code; when I compile the original file there will an error associated to an undefined class or the xib file would be changed which would also throw an error. At the start the original file compiled, but after working on the copy of the original file and running into an error. The original file also wouldn't compile, any ideas on why this happens? And how to fix it?
Though #Daij-Djan's answer is correct you need to watch for added files with relative paths. So what I do for a backup is to use git. That works better than any backup.
If you really want a copy, just copy the folder with the project with CMD-D which creates a <folder> Copy (or whatever is your localization). You can rename the copy, but leave the contents untouched. Also do leave it in the same folder as the original one to avoid conflicts with relative paths.
Just copy the whole folder from a to b!
IF you used absolute paths in your xcode project though .. bad for you :/ your project references the original files no matter what
what you can try is fixing the project.pbxproj xml file manually. this is doable but not supported by xcode really :/
IMHO if a copy isn't enough because you messed up the project with absolute paths, readd all files MANUALLY and make sure all is relative to the project location
Just zip your current project & extract it inside your new project folder & enjoy....

How to compile Object(*.o) files added with iPhone app?

I have created a simple native iPhone app. This project contains with c,c++ source files for doing some operations. Its radio tuning app, thats work fine. I want to give a source code to some one, and want hide all of source code c,cpp file (Because strangers don't want to see my code). So what i did is , i have compiled iPhone app and collect all (.o) files from build path and added to my resource folder.
For example if my application have these two files
radio.c
radio.h
when i build radio.o present on build path directory. my build path is (/Users/Macuser/Projects/Radio//build/Radio.build/Release-iphoneos/HDRadio.build/Objects-normal/armv7/radio.o).
So i copied radio.o file and added to my source code directory, and i removed the radio.c and radio.h file. When i compile it gives a error, radio.h file not found.
What could be the problem here? please let me know. Thanks in advance..
Note:
When i add radio.h file to my project it compiles successfully. I don't want to see my radio.h and radio.m file. is this possible?
There must be some other file in your project that is importing or including radio.h. Your .o file is used for linking but import/include dependencies are resolved when compiling the source. (A .o file is not source.)
If you don't want to provide .h files, the way around that is to create a static library to contain all the .o files that depend on each other. (However, to call any functions inside your library, the person still needs a .h with the declaration of public functions.)

Any way to disable syntax checking for a project?

I created a project "Sample Code"... here I just paste sample code... much of it is snippets that won't compile.
Is there some project-specific setting I can make so that Eclipse doesn't try to compile it?
I would prefer not to have the source code littered with red error markers.
Put your code in a non-java project, ie a general project.
Downside: you will have to create package directory structure (unless you can copy and paste from somewhere else).
Upside: it won't try to compile.
MY SOLUTION
ok, this is not an exact solution to my problem... but it is another way to do it and I kinda like it now...
I simply forget about using Eclipse to store the sample java files!
I found a good program CodeBox for Mac to store code snippets and I'm sure there exist such things for Windows, Linux too...
there interesting thing is that when I choose from this program to open the java snippet file (.java) in an external editor (Eclipse), it will open in Eclipse without any Syntax checking... wohoo! no squiggly lines
Because of this, it is not full blown code highlighting... classes and variables same color... but that's ok.. still quite readable. Much more than if it was in Eclipse with syntax highlighting running on it...
So basically, if you want to get rid of these red squiggles... one way to do it is don't keep sample .java (or other language) files in a project in Eclipse... simply keep them in the filesystem or code storage app and open them with Eclipse when you want to view them.
Depending on how you prefer to structure your project:
you could put your java files into a separate folder that is not configured as a source folder. There is an entry in the eclipse help on how to configure your build path.
or you can set exclusion-patterns in the build configuration, so that specific packages or files that follow a pattern you define don't get compiled.
Yet another way to handle your snippets could be to use a Scrapbook page.
Eclipse won't highlight anything in a scrapbook page but you can select code parts inside the page and execute them isolated. That's nice if you're experimenting and don't want to set up a whole class with imports and methods just to see if a specific snippet works as expected.

Minimizing the use of Xcode - how to quickly build and go from source code?

I realize I have to use Xcode to develop for the iphone, but I'm trying to build apps from raw source code generated outside of Xcode.
For example, I would like to "Build and Go" the apple demo "TheElements" (here). (I use this example because it has no .xib files - so Xcode is not needed for the UI).
It works to just unzip and open the .xcodeproj in there, but what if I had generated this code elsewhere and haven't yet used xcode? I.e., I have a directory of files (the contents of the .zip without the xcodeproj stuff):
./Default.png
./Images/*.png
./Classes/*.{h,m}
./Icon.png
./main.m
./Elements.plist
./Info.plist
./TheElements_Prefix.pch
Can I quickly (automatically?) get this built and running in the simulator?
I guess the question also relates to what information is really stored in the xcodeproj. Ideally, there would be some scriptable method for generating the project.pbxproj file, but sadly can't find this.
You might think of the Xcode project file as a glorified Makefile (if you're coming from the Unix world) or a VC solution file (if you're coming from Windows). It's a description of the dependencies between components and the steps required to build, link, and deploy those components. There is no more fundamental "Build and Go" than that.
On the iPhone, Xcode is required to build a viable application (technically, you could chain up the command line invocations used by Xcode—check the build log—but you'd be pretty crazy to bother). You can use a command line invocation (xcodebuild) instead of using the Xcode GUI app, but you still need a project file.