Cocoa Framework Development: Project Sharing

I am currently developing several similar Cocoa desktop applications. To share the code between them, I defined a set of core classes and functions that can be common to all of these applications. I would like to combine this common code into a structure to which all my current applications (and any future ones) can bind.

Now, here's the hard part: I'm going to develop this framework while I work, so I need each of my desktop applications to have a link to it, but I want to be able to edit the source code of the environment from within each of the application projects and automatically if necessary rebuild the structure.

For example, let's say I have an Xcode project for DesktopAppNumberOne open, and I decided that one of my infrastructure classes needed to be changed. I would like to:

  • Open and edit the source file for this framework class without opening the framework project in Xcode.
  • Click "build" on DesktopAppNumberOne and see how the infrastructure was first restored (since one of its sources was changed), and then look at the parts of DesktopAppNumberOne rebuilt (because one of the frameworks with which it refers has changed).

I see how to do this with only one application and one framework, but it’s hard for me to figure out how to do this with several applications that use the same infrastructure.

Has anyone had success with this approach? Maybe I'm wrong? Any help would be appreciated.

+4
source share
1 answer

Make an Xcode project for your framework.

In the Groups & Files panel> See the Blue Project icon in the upper left corner of the screen? Drag it to the Groups and Files panel of any other project that you like.

So, create an application project and drag the project icon from the framework project.

CMD-i in the target application . Here you set the dependency on the structure and the link against it.

Several points

Linking multiple applications to a single framework can be stressful. You need to either install your framework in / Library / Frameworks, or the equivalent or package in each application.

For development purposes, I find installing a custom shared layout directory for each of the projects, which makes work easier. I installed each project in / Code / Build / Debug . This means that the database search path for the debug build can be $ CONFIGURATION_BUILD_DIR. For your releases, you will still work on installations, rpath, etc. Pain in the Ass!

XConfig files are your friends. A good example of how to use them is the open source google mac toolbox. You will probably need at least Project_debug.xconfig , Project_release.xconfig , Target_framework.xconfig , Target_application.xconfig .

+4
source

Source: https://habr.com/ru/post/1309501/


All Articles