-2

I am attempting to create/build/run a second target for a library project in xcode. The library is being consumed by another project in the workspace, and I have:

  1. Created the second target, a console app
  2. Confirmed that the generated main.cpp file is included in the console target
  3. Cleaned and rebuilt, confirming that the library still builds and works

However the console target remains unbuilt. I have not received any errors.

Places I have researched looking for higher resolution steps:

If you think you can help, I'd be much obliged.

Community
  • 1
  • 1
max
  • 716
  • 7
  • 22
  • _' I will add screenshots etc at first request.'_ Research, gather and post any information you think that's relevant to your problem, and post it in your question (without being asked for, we aren't your nannies). – πάντα ῥεῖ Jul 21 '14 at 21:03
  • Etc meant, anything that someone thinks is valuable, because I literally don't know where to start with this issue, having followed documentation in more than one place. You're not my nanny, and I'm not a mindreader. – max Jul 21 '14 at 22:53
  • _'... and I'm not a mindreader.'_ We're neither ... – πάντα ῥεῖ Jul 21 '14 at 22:55
  • I'm sorry you think I didn't (or haven't) provided enough info, but there isn't any info, I've followed the instructions I read (and described) and don't understand the results I've gotten. All my research is potentially unrelated. – max Jul 21 '14 at 23:20
  • @πάνταῥεῖ, I have edited the question per your request/commands, and I also have found the answer, which was very simple and never mentioned once in the sites I listed. I would love to answer the question, can we take it off hold now? – max Jul 23 '14 at 23:33

1 Answers1

1

It might not be the answer you are looking for, but if you are new enough to XCode, that setting up a test.cpp to your library is challange enough, you might try another tool that in the long run might prove to be more useful.

CMake is an excellent cross-platform tool that is capable of generating platform-specific makefiles or project/workspace files for various IDE-s, including XCode. So you need to learn only one tool, and you're good for all platforms and compilers.

CMake has a companion app that ships with it, CTest. It is meant for just the thing you are looking for. It basically adds build targets that build a certain app (test.cpp in your case), and check if the return of int main() is zero or not. Multiple tests can be created (all testing different aspects of your library), and CTest provides nice interface to run all tests, just the specified ones and what not, plus it prints runtime of tests and shows which have failed.

CMake and CTest have good documentation, and there are myriads of tutorials available online. It might take some time to master, but in the 2 days time you spent googling, you could've ported your workspace to CMake easily. In the long run, it pays off.

Meteorhead
  • 480
  • 3
  • 13
  • I appreciate this answer as an alternative, but I was really looking for an xcode solution. I already have a library project consumed by a client project, and created the new target to the library with the associated source--I don't understand what could be so difficult!? Nevertheless, I will look into this solution, so thank you! – max Jul 22 '14 at 19:18
  • Unfortunately I cannot help you with XCode, as I never had an Apple desktop. I'd tell you, that in Visual Studio, you simply create 2 projects: one being the library, and one being a imple executable. This latter is set as the startup project, and that's it. There's also Unit Test capability of VS, but I never tried that. I only used the one generated by CTest, which creates a dummy/utility project that has a custom build-step which invokes CTest in the command line inside VS. XCode must be very similar to this. – Meteorhead Jul 23 '14 at 05:25
  • Right. I had done all my unit testing inside Visual Studio, but I was using C#. :D Having two targets where one is the tests may just be *wrong*, I'll investigate CMake and CTest today. – max Jul 23 '14 at 16:30