[R-SIG-Mac] Using R in Objective-C

Shawn Zizzo shawn at zamapps.com
Thu Oct 9 00:32:32 CEST 2014


I have successfully executed some R commands via the command line on my Mac.  I’d like to facilitate those same calls within an Objective-C app I’m creating.  I took a look at the source code for the R Mac App to see how I could do something similar.  I’m not that seasoned with Objective-C, so, I don’t have a full understanding off all that is in there.  However, I did try to bring in the R.Framework into my project and do a simple call to one of the R functions to get things going.  

I ran into some issues, that I can’t figure out how to solve.  I’m sure it is something simple, so, apologies ahead of time.

I'm running into an issue with a fatal error:

	/Library/Frameworks/R.framework/Headers/R_ext/Boolean.h:31:16: Redefinition of enumerator 'FALSE'

Here's what I have in my main.m file

	#import <Foundation/Foundation.h>
	#include <R.h>

	int main(int argc, const char * argv[]) {
	    @autoreleasepool {
        	Rprintf("testing R");
	    return 0;

I suspect it's how I'm including the R.h. I've tried #import as well, but I got the same issue.

This issue is also out on StackOverflow: http://stackoverflow.com/questions/26242020/using-r-framework-in-objective-c

Thanks in advance for your help.

Take care,

More information about the R-SIG-Mac mailing list