I know this is a very simple question but I have been struggling with it for a while. I have read a few threads but still can seem to find the answer.
I am trying to add this DDMathParser library to my existing project. The math parser documentation states
“Simply copy the “DDMathParser” subfolder into your project, #import “DDMathParser.h”, and you’re good to go.”
I added the subfolder to my project and added the header `#import “DDMathParser.h’ to my first view controller. At first Xcode was stating that it can’t find the file. I took the advice from another thread and changed my header to include the folder
#import "DDMathParser/DDMathParser.h"
Xcode seems to find the folder and header file but when I run a test from the documentation such as
NSLog(@"%@", [@"1 + 2" numberByEvaluatingString]);
I am getting the error ‘Thread 1: Program received sginal: “SIGABRT”‘ I can see in the DDMathParser sample file that there is a target, I am wondering if this is my problem.
To clarify the question I am trying to add the DDMathParser library to a simple view controller and run the staement NSLog(@"%@", [@"1 + 2" numberByEvaluatingString]);
Any help/clarification in doing so would be greatly appreciated.
First, please do not add the DDMathParser code to your project via a subfolder copy. Doing so will make it a pain to easily grab any future updates to the code and in general is not a very good approach to including external code in your projects.
Instead, you should add the git repo as a submodule of your project (you are using git, right?) and import the relevant files to your project. Here’s a step-by-step solution:
git submodule add https://github.com/davedelong/DDMathParser.git External/DDMathParser. This will create a new subdirectory named External to your project root directory and inside External the DDMathParser project will be copied.<Your Root Project Dir>/External/DDMathParser/DDMathParserdirectory. Be sure to check the “add to targets” checkbox and not to check the “copy items” checkbox.#import "DDMathParser.h"to your viewcontroller.DDMathParser should now work as you expect. If the author comes out with an update to the code you can just issue the following command from terminal to pull the latest updates from github:
git submodule update.Note: I created a new project from scratch, followed these steps and included your
NSLog()example to ensure that there aren’t any issues.