How to import assimp to my my Xcode project?

2.1k views Asked by At

I have downloaded assimp source code. How to import assimp to Xcode project - ARToolKit5 downloaded from ARToolkit official website? I am trying to load external models - made by blender,maya,3dmax - to this project. (ps: I am a beginner of Xcode, so please explain it in detail. ) Thank you! :)

2

There are 2 answers

0
Andy Ray On

Assimp is available in homebrew. After installing it, add assimp to your Library Search Paths and link it in the build phase tab.

  1. brew install assimp
  2. In your Xcode project, click your Project name in the sidebar > Build Settings tab > Library Search Paths
  3. Double click on the third column of "Library Search Paths" to edit it
  4. Click "+" and add /usr/local/Cellar/assimp/VERSION/lib/. Replace VERSION with your version.
  5. At the top, click on the "build phases" tab
  6. Open "Link Binary With Libraries"
  7. Click the "+"
  8. On the bottom click "Add Other" > "Add Files..."
  9. Add the file /usr/local/Cellar/assimp/VERSION/lib/libassimp.VERSION.dylib, replacing VERSION with your version.

Also make sure you have /usr/local/include in the Header search paths, found before "Library Search Paths" in the instructions above.

1
Harshit Kumar On

I know it's late, but it might benefit someone else.

Here are the steps :

  1. Download and extract the source code from(for version 3.3.1) https://github.com/assimp/assimp/archive/v3.3.1.zip

  2. Download CMake Gui, and select source as the folder you got after extracting above. Create a build folder inside the assimp folder, and select it to be the build directory.

  3. Select Configure and select XCode. Then Click on generate to generate build files in the build folder.

  4. Open Assimp.xcodeproj file in build folder in XCode and build it.

  5. Now you have got the library and include files. The library files are located in assimp(which you extracted)/build/code/Debug, and the include files are at two locations, one set is at assimp/include and other at assimp/build/include. Make a separate folders library and include at your desired location and copy all these files in the corresponding folders you created.

  6. Now open your project in XCode. Select your project from the left panel, and click on Build phases, click on + inside 'Link Binary with libraries', and click on add other, now select the libassimp.4.0.1.dylib(select the latest version) file.

  7. Now click on Build settings, inside search paths, add your include folder(which you created) to the header search paths, and the library folder to library search paths.

If you followed the steps correctly, you could use these statements inside your project

#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>