Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:16:37+00:00 2026-05-11T06:16:37+00:00

There are numerous post over the net that detail how relative paths don’t work

  • 0

There are numerous post over the net that detail how relative paths don’t work in Xcode. I do have an Xcode template that I downloaded where the relative paths DO work, however I have not been able to figure out why nor replicate it in other projects.

Firstly, I am using C++ in Xcode 3.1. I am not using Objective-C, nor any Cocoa/Carbon frameworks, just pure C++.

Here is the code that works in my other Xcode template:

sound->LoadMusic( (std::string) 'Resources/Audio/Pop.wav' ); 

This relative path works for me also in Windows. Running the following command gives me an absolute path to the application’s full path:

std::cout << 'Current directory is: ' << getcwd( buffer, 1000) << '\n'; 

/Applications/myApp

How can we get relative paths to work in an Xcode .app bundle?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:16:38+00:00Added an answer on May 11, 2026 at 6:16 am

    Took me about 5 hours of Google and trying different things to FINALLY find the answer!

    #ifdef __APPLE__ #include 'CoreFoundation/CoreFoundation.h' #endif  // ---------------------------------------------------------------------------- // This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle #ifdef __APPLE__         CFBundleRef mainBundle = CFBundleGetMainBundle();     CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);     char path[PATH_MAX];     if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))     {         // error!     }     CFRelease(resourcesURL);      chdir(path);     std::cout << 'Current Path: ' << path << std::endl; #endif // ---------------------------------------------------------------------------- 

    I’ve thrown some extra include guards because this makes it compile Apple only (I develop cross platform) and makes the code nicer.

    I thank the other 2 guys for your answers, your help ultimately got me on the right track to find this answer so i’ve voted you both up. Thanks guys!!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are numerous post regarding LINQ and multiple joins. I have however not found
There have been many threads started over the confusion in the way that Math.Round
In the method below there are numerous case statements (many have been removed) that
We host our own private NuGet Feed. I've noticed that when there are numerous
My understanding is that ASP.NET MVC only allows you to POST objects to Actions
I have read this post thoroughly: How does Visual Studio's source control integration work
There are numerous Agile software development methods. Which ones have you used in practice
In my app there are numerous view controllers which have their own purposes. However,
In a C# Winform application (3.5) there are numerous forms each with different listview
There is a moment in my app, that I need to force to show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.