Xcode cannot find/open Assimp model files in OF-0.9.3 examples

Both “3DModelLoaderExample” and “assimpExample” seem to be using a relative path (i.e “…/…/…/data/”) to their model files in their bin/data directory. This path seems to be generated by “file.getEnclosingDirectory()”.

Usually for me, “Build Phases” => “Copy Files” or “Build Phases” => “Copy Bundle Resources” make files in “Resources/Assets” available in the effective build location. But that doesn’t seem to work in either of the above OFx examples.

Any suggestions would really help and be much appreciated.

Can you describe your problem a bit more? Are the examples not compiling because it can’t find the models in the data folder? Are you trying to load models with an absolute file path that aren’t located in the data folder? Are you moving your application and finding that models are no longer linked too?

It might be helpful to right click on the application (assimpExampleDebug) and do “show package contents” and look inside “contents/resources/data” to see where the files are located from the point of view of the application.

Hi, Caroline.

Thank you for responding so quickly. As for describing the problem a bit more, here goes…

The app compiles without problems. Runtime, however, is when the app tries to load, read, and parse the model files and errors out when it can’t find the first model file “asrtroBoy_walk.dae.” Although the file is clearly present in $(SRCROOT)/bin/data/ (which may be the "…/…/…/data/“ location referred to in the error message:

[verbose] ofxAssimpModelLoader: loadModel(): loading “astroBoy_walk.dae” from “…/…/…/data/”
(lldb)

The root cause of the problem is that in Xcode on OS X, all relative files path are inapplicable during build-time & run-time. The reason is that Xcode copies everything it need to build an app from the original app src location into a special location in $(HOME)/Library/Developer/Xcode/DerivedData/Build/Intermediates/.build/Debug/etc/etc/…
Products /Release/etc/etc/…
So, when an app looks in …/…/…/ expecting to find some directory in original app src location, it actually finds some directory up three levels from some directory way down in this build path. To help deal with this problem, Xcode provides a couple of mechanisms with which the programmer can copy files (usually assets/resources or shaders) into the appropriate directory deep down in this build path where they can be found at build- or run-time. Unfortunately, those mechanisms don’t seem to work in openFrameworks’ customized version of Xcode.

I’m no Xcode expert, and perhaps there is an easy fix for this problem. If there is I’d love to hear about it. Meantime, I’ll be going back to GLFW and the standard distro of Xcode.

Thank you, again, for you reply.

Sincerely,
Rexford Gibbs

Thanks for fuller explanation, very interesting to know more about how that works. I wonder if something is different in our Xcode setups then? I am on el capitan with 7.3 Xcode and 9.2 OF and the assimp example finds and loads the models without an issue.

I’m having trouble using this method with Xcode too. I’m not sure if my problem is path related but every time I try to run the ofxBullet customShapes example, it gives me an exception error. This is because its trying to call the aiScene object, which is always a nullptr. I don’t know if this means that it’s not finding the file or if its a bug. I tried changing my working directory in Xcode, and I tried using absolute paths. I recently tried compiling in Ubuntu and it worked fine.

what worked for me was to set the true to false

//not working
model.loadModel("sassafras.stl",true);

//working
model.loadModel("sassafras.stl",false);

Thank you so much. I really should have tried that :open_mouth:

Falling back to version 0.9.2 fixed my problem with the assimp addon’s failure to find files.