In fact I want to port my wxWidgets-based application over to Mac using OS X 10.8 and Xcode 5. My application at this point will consist of the main executable and couple of dylib's.
So, after opening the XCode and going to the "File->New", I see there are "Project" and "Workspace" submenus.
I'm at a loss to:
- presume I need to create a workspace, and then in there create 1 project for the main executable and 1 project for each dylib library.
- forget about the "Workspace" and just start with the project for my main binary and then continue with another project on the same level for the library
Could someone shed some experience please?
Best Answer
This is an example of where a simple C++ command line application and dynamic library are created. The version of Xcode is 7.2.1 which requires at least OS X 10.10.5 execute, but can generate applications that only require OS X 10.7 or newer.
Part I: Create the Workspace, Projects and Source Code Files.
For "Product Name:", "Framework:" and "Type:", I used "simplelib", "None (Plain C/C++ library)" and "Dynamic", respectively. Click the "Next" button.
Part II: Configure Project Dependences
Project "simple" has to be able to find the headers from project "simplelib". Highlight project "simple", then "Build Settings". Change "Header Search Paths" to "../simplelib". An illustration is shown below.
Project "simple" has to be able to link to the library created by project "simplelib". Highlight project "simple", then "Build Phases". Under "Link Binary With Libraries" click on the + sign and add "libsimplelib.dylib. An illustration is shown below.
Remove the library search paths added by step 2. Highlight project "simple", then "Build Settings". Under "Library Search Paths", delete paths "$(inherited)" and "$(PROJECT_DIR)lib/build/Debug". An illustration before the deletions is shown below.
When finished, "Library Search Paths" should show no paths as shown in the image included in step 1.
Part III: Build and Run the Application
Ask Different is not about programming. However, I will include the code that I entered.
simplelib.h
simplelib.cpp
main.cpp
To build the application first select Product->Scheme->Simple from the menu bar. The sets the focus on application project "Simple".