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 7668229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:18:35+00:00 2026-05-31T15:18:35+00:00

This is my first time using Xcode and it is appalling to me how

  • 0

This is my first time using Xcode and it is appalling to me how completely non intuitive this IDE is. I heard it was better in the past and I really hope it was.

My problem is that the resources my program loads, a data file and an .ini file, it automatically searches for these file in my Home folder. I want for it to search for these files in the Resource folder of the .app. I am using C++ and all of the examples I have found are for Objective-C.

Any idea on how to fix this?

  • 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. Editorial Team
    Editorial Team
    2026-05-31T15:18:36+00:00Added an answer on May 31, 2026 at 3:18 pm

    You are probably assuming that, when your app launches, the current working directory of the process is your app’s bundle. It isn’t. (Nothing to do with Xcode particularly — that’s just how OS X works.)

    Typically you would use NSBundle (Objective-C) or CFBundle (C)
    to find resources in your app bundle. Since you’re using C++, let’s use the C API.

    To find the URL to a file “myFile.ini” in the Resources directory in your app bundle:

    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef url = CFBundleCopyResourceURL(mainBundle, CFSTR("myFile"), CFSTR("ini"), NULL);
    UInt8 filePath[PATH_MAX];
    if (CFURLGetFileSystemRepresentation(url, true, filePath, sizeof(filePath)))
    {
        // use your API of choice to open and read the file at filePath
    }
    

    Or, to just change the CWD to your app bundle:

    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef url = CFBundleCopyBundleURL(mainBundle);
    UInt8 bundlePath[PATH_MAX];
    if (CFURLGetFileSystemRepresentation(url, true, bundlePath, sizeof(bundlePath)))
    {
        if (chdir((const char*)bundlePath) == 0)
        {
            // now the CWD is your app bundle, and you can use relative path names to access files inside it
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first time of using icon composer and I'm completely lost. I
This is my first time using joomla. I don't know if I'm using the
this is my first time using StAX for parsing XML documents (still in the
Sorry, this is my first time using this forum. Apparently people can edit my
I'm fairly new to both Django and Python. This is my first time using
This is the first time ever I'm using AJAX, and I want to do
This is my first time to create a report using iReport plugin in Netbeans
This is my first time doing mobile development with twitter. I'm using Adobe Flash
I'm using this XML classes for the first time and can't find this piece
I am using $SUB for the first time and have come across this problem.

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.