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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:56:21+00:00 2026-05-13T12:56:21+00:00

Does anyone know how to obtain the path to the current directory when running

  • 0

Does anyone know how to obtain the path to the current directory when running xcodebuild (mainly, the project directory) and write files to it? I’m trying to save the results of some unit tests to disk from my obj-c code, but I’d rather not dump them deep in the app’s document path if possible. I might be able to append ‘../../..’ etc. to the document path, but I was hoping there might be a more elegant method.

*This is relevant only to the simulator, of course… but perhaps even the simulator attempts to maintain the iPhone file system sandbox? I’ve had no luck writing to other random locations on my Mac, so I suspect that might be the case.

Thanks for your input!

  • 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-13T12:56:21+00:00Added an answer on May 13, 2026 at 12:56 pm

    I figured this out – the answer is embarrassingly simple. With an emphasis on “embarrassing”.

    If you use something like NSString’s writeToFile methods, all you need to do is think of your path as relative to wherever you’re running xcodebuild from – no NSSearchPathForDirectoriesInDomains needed.

    Example:

    (if running in ~/src/awesomeapp)

    [myString writeToFile:@"awesome.file" atomically:YES encoding:NSUTF8StringEncoding error:&error];
    

    Will output to:
    ~/src/awesomeapp/awesome.file

    Yes, I am an idiot. I actually tried this first, but I was attempting to write to a relative directory that didn’t exist, thus resulting in an unhelpful “Cannot do this” style error that led me all around the internets and eventually to stackoverflow… (you need to use FileManager#createDirectoryAtPath! There is no automatic path creation, unfortunately.)

    FYI, as should be apparent, you are free to write files wherever you wish on your hard drive when running via xcodebuild – no sandboxing occurs. If you run in the simulator, though, it might be a different story.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Plug-in spy (Alt+Shift+F1) is integrated directly in Eclipse (since Eclipse3.4,… May 14, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer The compiler is complaining because you're defining a new function… May 14, 2026 at 6:54 am
  • Editorial Team
    Editorial Team added an answer IIS7 (or any other version) does not have the concept… May 14, 2026 at 6:54 am

Related Questions

Does anyone know how to programmatically obtain the server version number under JBossAS 5.1?
I've been researching how to interact with the MSN messenger / Live messenger service
I'm using the INFORMATION_SCHEMA views in Sql Server 2005 & 2008 to obtain metadata
I'm in the process of internationalising some JSF files so am externalising strings (and
We've been programming an iPhone application under iPhone OS 3.1, but the client has

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.