How to start Xcode debugger for a project without any executable? - xcode

I have a Xcode project that is building a library and I want to be able to debug the library when it is loaded by the main application.
Run and Debug options from Run menu are disabled and if i try to use attach to process option I get "No launchable executable present at path". When looking at Active Executable I see but I don't know how to tell xcode what to run/debug.
So how should I debug the application? I'm looking for something similar to the project configuration of Visual Studio but I wasn't able to locate this option yet.

Add a custom executable to your project.
It is under the Project -> New Custom Executable... menu item.
From there, you can add your application as the custom executable and that will give you the ability to debug the application and the plug-in.
One additional helpful hint; in Xcode's build preferences set up a single common products directory. This will put the symbol files for building your application in the same directory as your application (assuming your main application is one you build) and, thus, you'll be able to step through frames in both your library and your application.

For those using Xcode 4:
Project > Scheme > Edit Scheme...
Select the Run phase > Info
And set an Executable

Related

What target is build when I just Build my Xcode project

If I just build my Xcode 4 project (using the cmd-B) command, which target is built?
I'm having trouble understanding the new scheme setup. When I look at the currently selected scheme, under the "Build" tab, all my different build types are checked (ie: Analyze, Test, Run, Profile, Archive). However, when I build, it seems like only "Run" is built. And for the *.app file that is produced, is this built using the "Build Configuration" set under the "Run" tab?
Thanks!
Sunny
Whichever target that is in selection next to your Run, Stop button in your Xcode.

How to change Xcode build setup without modifying project files?

I would like to know if it is possible to change compile settings without modifying the xcode projects.
Example, adding -Wno-unused-parameter to CFLAGS in such way that it will be used by Xcode when building projects.
This has to work in both case: build made from xcode in GUI or from the console.
If someone asks about why, let's say that the number of projects is quite big and that you may want to alter the options only temporary.
Put the compiler settings you want to change in a configuration settings file. You can create a new one by choosing File > New > New File. The configuration settings file is in the Other group under both iOS and Mac OS X.
To tell an Xcode project to use the configuration settings file, select the project file from the project navigator to open the project editor. Select the project from the left side of the editor. Click the Info button at the top of the editor. You should see a list of build configurations in the editor. Click the disclosure triangle next to a build configuration to have it use a configuration settings file.

How to debug a bundle in XCode?

I wrote a nice little program. At some point, it is required to load a bundle with some additional functionality. I, too, am the author of the bundle, so I have the source code and Xcode-projects for both the main application and the bundle.
Until now, I simply dragged the bundle into the resources-folder in the main application, which works fine for running it, but I can't debug it (and of course there is an error in it).
Is there a way to set up Xcode so that I can debug the bundle?
In your bundle project, you should add a custom executable. That executable will launch in the debugger when you do a Build & Debug.
To do this in Xcode 3, right-click on the Executables section in the Groups and Files list in your project and choose Add > New Custom Executable…
You can then select your application in the open dialog.
In Xcode 4, you need to go to Product > Manage Schemes, select your Debug scheme and in the Info tab for the Debug action you should use the Executable popup to choose a custom executable.
You will also need to change your build settings for your Debug scheme so that the build products are placed in your application's plug-ins folder when the plug-in is built, so that when you Build & Debug the application contains the latest version of your bundle.

Command line tool to add resources to an Xcode project

I've got an Xcode project that creates a standard application that can be branded in multiple ways and contain some custom content. At the moment I have a Resource "Resources > Tour Packages" with the custom files under this. At the moment every time I want to brand the app a different way I have to delete the old files from this resource and then manually add the new versions via the XCode UI. I can't post and image but it is here - http://img.skitch.com/20100121-xub48r6e1p857c84hdrgg25dw6.jpg).
My Question: Is there a command line tool that performs the same operation?
You'd probably be better off just creating multiple targets in your Xcode project, and associating the resources for each branded version of the app with one target.
To do this, just right-click on your target and select Duplicate. You should then remove the custom resources from the Copy bundle resources build phase. You can then add a new set of resources to the Copy bundle resources build phase that are specific to the new target. You can then build any target you like by selecting it from the Active Target popup in the Xcode toolbar or by selecting it in the Project > Set Active Target menu.
This way, you can easily build different versions of your app without having complete duplicates of all your source, difference Xcode projects etc.
Yes, the xcodeproj ruby gem allows you to add resources. https://rubygems.org/gems/xcodeproj/versions/0.28.2

Bundle framework with application in XCode

I am an XCode novice. I am trying to follow these instructions. Clearly I am missing something because while I can see that the framework I want has been copied into the app bundle, I can't reference it.
When I start the application from a machine other than mine (or if I remove OpenCV from /Library/Frameworks/ ) I get the following error:
Dyld Error Message: Library not
loaded:
/Users/david/Library/Frameworks/OpenCV.framework/Versions/A/OpenCV
Referenced from:
/Users/g/Demo/Slates/ClipSplitter/build/Release/ClipSplitter.app/Contents/MacOS/ClipSplitter
Reason: image not found
There is no user "david" on my system if that makes any difference. Also this is a prebuilt OpenCV downloaded from the internet. (Here’s a screenshot of the project as requested in comments.)
When the OpenCV.framework has been build it has been configured to use an install path of /Users/david/Library/Frameworks/.
Since you want to use the library as a private framework (installed in the application wrapper at ClipSplitter.app/Contents/Frameworks/OpenCV.framework) you have to change its install path. This can be done easily using the terminal as follows:
$ install_name_tool -id #executable_path/../Frameworks/OpenCV.framework/OpenCV <your_path>/OpenCV.framework/OpenCV
Of course you have to adjust the path of the last argument.
Now, when linking your application, your modified framework tells the linker that dyld has to search for the OpenCV.framework in the app wrapper of your application (in the ClipSplitter.app/Contents/Frameworks directory).
Now you have to copy the OpenCV.framework to your application wrapper. You can do this as part of your build process by adding a copy files build phase: Right-click on your target, select Add->New Build Phase->New Copy Files Build Phase. Select "Frameworks" from the "Destination" pop up and close the dialog.
Your target will now contain a new phase to which you can add the OpenCV.framework by dragging the icon from the Project Navigator on the left side of Xcode window. Note that Xcode won't allow you to add a folder to the Copy Files phase by using the '+' button so in order to copy the framework you'll have to drag&drop it.
You need to set the build setting "Installation directory" to #executable_path/../Frameworks
See the chapter about Embedding a Private Framework in Your Application Bundle in https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
Regards
Using Xcode 5, you can facilitate this using the Build Phases panel of your application target.
The default appearance of this panel is
By pressing the "+" button underneath Copy Files, you can add your framework as a file that will be copied into Frameworks in your app bundle.
Now, when you build, your Framework(s) will be copied into your bundle.

Resources