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

  • Home
  • SEARCH
  • 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
  • 0 Views
  • 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

Ask A Question

Stats

  • Questions 262k
  • Answers 262k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It looks like this dotted border around selected cell you're… May 13, 2026 at 11:45 am
  • Editorial Team
    Editorial Team added an answer Im sorry I misread, i thought you wanted to call… May 13, 2026 at 11:45 am
  • Editorial Team
    Editorial Team added an answer You should have something like this: The UI calls BL.SaveUsernameAndPassword(string… May 13, 2026 at 11:45 am

Related Questions

There are numerous post over the net that detail how relative paths don't work
When replying to a post (for example on Craiglist) that asks for sample code,
Problem, I want to use sessions, but I am having issues with implementing sessions
I'm working on a 10 page web site with a database back-end. There are
I've seen numerous examples of create actions in articles, books, and examples. It seem

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.