adding a simple library to an xcode 4 project

后端 未结 2 590
一向
一向 2020-12-30 14:22

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 t

2条回答
  •  再見小時候
    2020-12-30 14:56

    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:

    1. Add the DDMathParser repo as a submodule to your project. Here are instructions on how to add a submodule in your project directory. Take a look at that answer, but for brevity's sake, you'll issue this command from terminal in your project's root directory: 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.
    2. Add the DDMathParser directory to your project. It will be found in /External/DDMathParser/DDMathParser directory. Be sure to check the "add to targets" checkbox and not to check the "copy items" checkbox.
    3. Add #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.

提交回复
热议问题