IMerin
IMerin

Reputation: 75

Build/Run two targets in Xcode at the same time

I'm building a simple client-server application in C, and using Xcode as an IDE to develop it. It's my first time using Xcode for anything, so i'm a little green with the options.

I've created two targets, one for the client and one for the server. I can build and run either one just fine. However when I want to build and run both (IE execute client while server is running) the client build immediately disappears.

If i try to run two instances of the same target, say server and server, I will get a prompt as to whether I want to stop the original process or add the new process. I don't get the same prompt trying to run client while server is running.

The odd thing is when I set a breakpoint somewhere in the client source, the whole thing runs as expected. How can I get this to be the default behavior?

Thanks

Upvotes: 3

Views: 3540

Answers (2)

Mark A. Donohoe
Mark A. Donohoe

Reputation: 30368

I think the accepted answer is outdated. In Xcode 9, as long as you have two targets, one per app, you can select the first target and press 'run' to start that debugging session, and while that's running, change to the second target and press 'run' again and the second app will start.

In the debugger pane, you'll see a dropdown that lets you select which target you want to see the output from.

What I haven't yet found is how to automatically start them both from the same scheme. It's still a manual process, but it doesn't require multiple instances of Xcode or using the command-line.

Upvotes: 7

Michael Dautermann
Michael Dautermann

Reputation: 89509

The Xcode debugger can only be hooked to one application at one time.

In my own Client / Server debugging, what I usually do is either have two machines running Xcode, where one is testing with the Server and other is testing with the Client.

If you have only one machine, what I usually do is run an instance of the server or client from the command line (you can launch any app by going to the "Products" folder where the built products are kept, and then typing in "ProductName.app/Contents/MacOS/ProductName"; the application binary is kept inside the application's package) and then I run the Xcode debugger on the actual thing I'm targeting for debugging.

Hopefully this makes sense!

Upvotes: 0

Related Questions