How to Add, Build and Run existing files onto Xcode C++ Project Command Line - xcode

I am trying to add an existing folder to a project on Xcode. I want to run it on C++ OS Command line tool. I have added the cpp and hpp files on my project. On the Contacts folder, it includes a csv file and I have also included it on my project. The problem is that the program compiles and runs but it does not show any output of the contacts I was expecting to see.
Is there anything I need to do right?
Thanks for the help.
Contacts folder
Project on Xcode

Creating a new project as a Command Line Tool and using the same code called on main. Then try Activate Console command: Cmd+Shift+C or in the Top menu: View -> Debug Area -> Activate Console, then run your project Cmd+Shift+R or the play button shortcut on xCode.

Related

Xcode: how to generate .app file?

I'm porting my game project from Windows to OSX and I finally managed to create a working executable but the problem is I need the .app file for distribution and Xcode does't generate one, only the executable file.
Maybe I created a wrong project at the start? Is it possible to create .app file from Command Line Tool project? Should I create a new target "Applicaton"?
Here is the screenshot from my project settings: http://1.1m.yt/NwlO0PH.png
I'm new to OSX system and how everything works.
Xcode version 4.6
Project Type: C++ command line tool
You've created a Command-Line Tool, when you should be creating a Cocoa Application.
Xcode > File > New > Project... > Cocoa Application
( ⇧ ⌘ N )
This will allow you to build an application bundle (.app)

Project specific .lldbinit in current working directory not read by Xcode

I want to setup project specific .lldbinit files, so that "everything" would be under version control and easily setup in new computers. However it seems like I can read only ~/.lldbinit file and not any ~/git/project/.lldbinit files.
LLDB manual say:
lldb will read settings/aliases/commands from three files at startup, if
they exist.
First, it will read a ~/.lldbinit-debugger command file. If you are
using the lldb command line interface, this is ~/.lldbinit-lldb. If you
are using lldb inside a GUI debugger like Xcode this will be ~/.lldbinit-
Xcode. This is a useful place to put settings that you want to apply
only when a given lldb command interpreter is used.
Second, ~/.lldbinit is read.
Third, an .lldbinit file in the current working directory (where lldb is
started) will be read.
So my question is: how do I setup Xcode or project to use the "third" option i.e. read .lldbinit file from the current working directory? How would I check or change what's Xcode's "current working directory"?
Xcode now (written with the public Xcode 12) has support for setting a scheme-level LLDB Init File. This can be done as part of the Info tab in the Run phase of the scheme.
Open project in Xcode.
⌘ + Shift + , to open scheme editor.
Select Run then the Info tab.
Edit LLDB Init File value.
Use $(PROJECT_DIR) to reference the directory that contains the project.
Use $(SRCROOT) to reference the target's source root directory.
This is the working directory in which you launch whatever process loads the LLDB framework. Xcode doesn't have a useful working directory (it was / last time I looked), so you can't really use the cwd version.
A solution for Xcode project specific lldb settings that will work in many cases is to put a symbolic breakpoint on main, set it to auto-continue, then put the settings you want in the breakpoint commands of that breakpoint.
It would also be great if Xcode had some UI to specify target-specific lldbinit files.
There is now a "Xcode plugin to load project specific .lldbinit" at https://github.com/alloy/lldb-is-it-not
Xcode now has support for Target specific lldb init files. There's an entry form for the path to the file in the Run scheme for the Xcode target.

xcode command line app - where is the executable code?

I'm writing a small command line tool/app in Xcode 6. After a steep learning curve (that I'm still climbing) I've got my code working in main.m without errors. My question is: does Xcode build some executable code that I can run from the command line inside a Terminal? I've tried "Build" and "Run & Build" but I don't see where any executable code is created. I'm very new at Xcode and need some help. I'm running OS X 10.9.5 and Xcode 6.1.1 on a Mac Mini.
If viewing my code would be useful, let me know and I'll put it up.
Thanks for any assistance.
Kevin H.
It's hidden very well. In Xcode 6, when you build an app, there is a folder "Products" in the project navigator (left pane). The name of your project will be there too. Right click, and select "show in finder". It will show you an obscure folder hidden deep in your OS X Library where the executable is located.
To copy the executable to a more convenient location each time you compile go into the project settings and select the Build Phase.
Type in a absolute location such as: ~/Documents/dev/temp. (It does recognize ~ as the current users home directory)
Then Press the '+' Button Under the 'Copy Files' Section and Select Your File (Select Your executable under the Products Folder)
Deselect the 'Copy only when installing' button. Then build and it should be at that location.
To launch just open the terminal app and go to that location. The executable should run unless there are dynamic libraries it calls that are not in the lib path.
Hope this helps
The binary is in a folder under /Users/Username/Library.
Something like:
/Users/<Username>/Library//Developer/Xcode/DerivedData/.../Build/Products/Debug/<ProjectName>
You can easily find it with this command:
find /Users/<Username>/Library/ -name "<ProjectName>"
replace "Username" and "ProjectName" accordingly to reflect your environment.
"Find" works, but you could also view the build log output and look for "CreateBuildDirectory" and copy the path from there.
Example below:
In Xcode 14 the path is nested under the line that says "Create build directory $(DERIVED_DATA_DIR)", but you can see the full path by expanding the icon on the right of the output.

how do I build a single project in code::blocks?

I tried to compile and execute a file outside a project.
But when I hit F9, the main file in the active project was built.
How do I build and run a single file project?
Reading this article it seemed possible, but it didn't tell me how.
Sure you can compile the file outside the project but you can't run it through codeblocks. If project is already open in codeblocks then pressing f9 or build and run button it compile and run the current project. If you have a c/c++ source file outside the project and you want to compile it then at first select the file you want to compile, go to menu and press -> build -> compile current file or press ctrl+shift+F9. But you can't run it through codeblocks so you have to run executable file directly from the directories where .exe file has been build.

Xcode Won't Compile To Simulator

I've just updated Xcode 4.5 via the App Store, from my previous version which I got from my Apple Developer Account. Since the update I can't compile any apps into the Simulator. I can compile onto a device, e.g. my iPhone.
The error I recieve is
fatal error: file
'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/
Developer/SDKs/iPhoneSimulator6.0.sdk/usr/include/Availability.h'
has been modified since the precompiled header was built
1 error generated.
go in ~/Library/Developer/Xcode/DerivedData/{project name + gobly-gook} and delete folder with your project name.
EDIT After suggestion
NOTE:
By default Library Folder is hidden so we can't see it.
So we have three way to use this hidden ~/Library folder
1.Unhide Library folder by following command to unhide ~/Library folder
chflags nohidden ~/Library
Now you can see Library folder as /Users//Library
2. Open GO menu of finder and press Alt key and Library will be visible as new menu item.
Select that to open Library folder
3. You can access ~/Library folder by Terminal.
There's easiest way: Just "clean" project (Product > Clean)
You can just open the Organizer (top-right corner of XCode), go to the Projects tab, select your project on the left and then delete the Derived Data.
This happened when I updated Xcode from 6.0.1 to 6.1
I cleaned the project and could compile successfully!!

Resources