I have been working on a macOS GUI application using Cocoa framework. Now I want to add a command line interface that can output the same information as my graphical app. This would let me use the data in terminal scripts and display tools.
I think I need to add another target to my Xcode project that creates a separate command line binary. Both the GUI and CLI versions should be able to access the same core functionality. Has anyone done something similar before? What would be the best approach to set this up in Xcode and share code between both versions?
I encountered a similar challenge while developing my application. The solution I found most effective was to create a shared library or framework that houses the common functionality. By isolating the core logic, you can ensure both your GUI application and CLI binary access the same codebase without any redundancy. This approach not only minimizes duplication but also aids in maintaining consistency between versions. Additionally, prioritize designing user-friendly interfaces within the framework to facilitate a straightforward CLI implementation.
for sure! i set up a cli version with my gui too. just make a new target in xcode for the cli. store your common code in shared files so both can use it. make sure those target settings are spot on, and itll work like a charm!
Oh that’s interesting! how do you handle the different output formats between gui and cli? when your gui shows tables or charts, do you just convert everything to plain text for the terminal? also curious about argument parsing - using any specific libraries for that?