# OS X: Am I in an app bundle?

**URL:** <https://discourse.libsdl.org/t/os-x-am-i-in-an-app-bundle/20357>\
**Category:** SDL Development\
**Created:** [February 6, 2014, 8:44pm UTC](https://discourse.libsdl.org/t/os-x-am-i-in-an-app-bundle/20357 "2014-02-06T20:44:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Labbe](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/michael_labbe/32/100_2.png) [@Michael\_Labbe](https://discourse.libsdl.org/u/Michael_Labbe)\
**Post date:** [February 6, 2014, 8:44pm UTC](https://discourse.libsdl.org/t/os-x-am-i-in-an-app-bundle/20357/1 "2014-02-06T20:44:27Z")

</div>

How do I detect I am in an app bundle?

Why this is relevant:

I am trying to locate my game assets directory in a cross platform manner. This is usually $EXE\_DIR/assets. OS X is throwing a curveball, because the app bundle puts it in a different location.

If I am not in an app bundle, I take the return of SDL\_GetBasePath() and append ?assets?.

If I am in the bundle, I need to append a different string, depending on the SDL\_FILESYSTEM\_BASE\_DIR\_TYPE plist. Both ?resource? and ?parent? settings are okay for my needs.

So then, how do I detect that I am in the app bundle? The string I append has to change, and this needs to happen at runtime or I sacrifice robustness.

SDL\_GetBasePath() can?t be used to construct a path to assets without this test.

What I am getting:  
OS X inside of a bundle with SDL\_FILESYSTEM\_BASE\_DIR=?bundle":  
"/Applications/Some Game.app/? \<- Need to append “Contents/Resources/assets/”

“/Users/mlabbe/dev/game/? \<- need to append ?assets/”

Michael Labb?

---

<div class="post-metadata">

**Author:** ![icculus](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/icculus/32/81_2.png) [@icculus](https://discourse.libsdl.org/u/icculus)\
**Post date:** [February 6, 2014, 8:47pm UTC](https://discourse.libsdl.org/t/os-x-am-i-in-an-app-bundle/20357/2 "2014-02-06T20:47:45Z")

</div>

> ```
> OS X inside of a bundle with SDL_FILESYSTEM_BASE_DIR=?bundle":
> "/Applications/Some Game.app/? <- Need to append
> 
> ```
> 
> “Contents/Resources/assets/”
> 
> ```
> "/Users/mlabbe/dev/game/? <- need to append ?assets/"
> 
> ```

I’m probably misunderstanding the problem, but you should get  
“myapp.app/Contents/Resources/” by default without the hint, making it  
so you just have to append “assets/” in either case.

–ryan.

---

<div class="post-metadata">

**Author:** ![Michael\_Labbe](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/michael_labbe/32/100_2.png) [@Michael\_Labbe](https://discourse.libsdl.org/u/Michael_Labbe)\
**Post date:** [February 6, 2014, 8:54pm UTC](https://discourse.libsdl.org/t/os-x-am-i-in-an-app-bundle/20357/3 "2014-02-06T20:54:47Z")

</div>

Upon re-reading, that would definitely solve my problem as written. Unfortunately, I oversimplified the explanation for the email. In practice, I actually have no ?assets? subdirectory under ?Contents/Resources?.

Given that it is pretty trivial for me to update my bundle creation script to do so, that?s what I?ll do. It beats ducking into a .m file and doing a quick test for the existence of the plist.

Michael Labb?On Feb 6, 2014, at 12:47 PM, Ryan C. Gordon wrote:

> > OS X inside of a bundle with SDL\_FILESYSTEM\_BASE\_DIR=?bundle":  
> > "/Applications/Some Game.app/? ← Need to append  
> > “Contents/Resources/assets/”
> > 
> > “/Users/mlabbe/dev/game/? ← need to append ?assets/”
> 
> I’m probably misunderstanding the problem, but you should get “myapp.app/Contents/Resources/” by default without the hint, making it so you just have to append “assets/” in either case.
> 
> –ryan.
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
