开发者

Xcode: multiple projects, more than one main executable

Hi I'm new to Xcode. I'm trying to learn c++ and I was wondering if it is possible to have multi projects and choose which project should run. I used ms visual studios before and I like how under a solution I can create multiple projects and choose which one is the executable one. Xcode also has targets not exactly sure what they are maybe they play a role? I tried messing around but I constantly have issue because of duplicate mains. I'm going th开发者_JAVA百科rough a chapter and there are case studies. I'm trying to keep every chapter organized in one project well something like that. Any help thanks!


Xcode targets are probably what you are looking for. You can have many targets in a single project, and whichever one you select as active will be used when you tell Xcode to compile or run. If you are having problems with duplicate mains, you probably have all of your .cpp files in all of your targets. If you have main1.cpp and main2.cpp in the same target, Xcode will attempt to use both of them and run into a conflict. Including all common files in all targets, but only the appropriate main files will likely solve your problems.


for creating a new main.cpp file you should go to

File-New-target.

After it gets created just select your file here to choose which file you want to execute:

Xcode: multiple projects, more than one main executable


Actually you can create a workspace, then create each exercise as a project or as a target inside a root project, the second option is preferred if the exercises need to share the same libs and setup.

To select the active scheme to debug and run you can use this selection menu close to debug controls.

Xcode: multiple projects, more than one main executable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜