XCode 4.2 and Using a Static Library Causing Problems

后端 未结 2 837
长发绾君心
长发绾君心 2020-12-09 04:59

Like many others here SO, I am having issues using libraries in my XCode workspace. The idea is I have my main project (MyApp) and two libraries (lib1

相关标签:
2条回答
  • 2020-12-09 05:46

    Here is how to create a static library and a project that use it.

    Step 1: Create a workspace: File > New > Workspace. This is not mandatory but it helps organize the projects.

    Step 2: Create a static library project: File > New > Project > Framework and Library > Cocoa Touch Static Library. Lets call it MyLib.

    Step 3: Create an Application Project: File > New > Project > Application> Empty Application, or any other application template. Lets call this project MyApp. If you placed the projects in different folders, you may have to use a different path.

    Now you have the following Projects in the workspace.

    Project structure

    Step 4: Configure the app so that it finds the .h files of the library. To do that, add the parent folder "../" and check the recursive checkbox.

    Header Search Path

    Step 5: Link the app to the library.

    enter image description here

    0 讨论(0)
  • 2020-12-09 06:00
    1. Open Main Project where you would like to add static library.
    2. Save as workspace.
    3. Add library's project package. No need to check copy while adding project package.
    4. Update Xcode preferences location to Custom-Relative to Workspace. Products as 'Build/Products' and Intermediates as Build/Intermediates
    5. In your Main project -> target -> build settings, Add Header and Library Search Path as $(BUILD_PRODUCTS_DIR)
    6. Build Library Project. So a new library will be created in mentioned build path.
    7. Remove existing library from Build Phases and move to trash. Open Build Phases -> Link Binary With Libraries and add newly created library from build directory.
    0 讨论(0)
提交回复
热议问题