
Determine if `-greeting` argument is present. greeting 'Goodbye, pluto!' // main.swift Modify main.swift to replace 'Hello, world!' with a custom greeting using command-line arguments. $ open CommandLineArgumentsDemo.xcodeproj/ Great! Now let's generate an Xcode project so we can start experimenting with command-line arguments in Xcode. We can now build and run this executable in the terminal to see the default implementation in action. We'll use the Swift Package Manager to create an executable project which can be built and run from the terminal.
BUILD XCODE PROJECT FROM COMMAND LINE HOW TO
Let's start by reviewing what command-line arguments are and how to process them in Swift. What we really need is the ability to configure specific dependencies per Xcode scheme or UI test case without running the risk of accidentally shipping a mocked datasource to the App Store. We could use Active Compilation Condition checks at run-time to load dependencies based on debug or release build configurations, but this gets hard to manage quickly because all debug builds get the same dependencies. We could hard code flags in our app and manually change them when testing or debugging, but this is super error prone and virtually guaranteed to result in a mocked datasource shipping to the App Store sooner or later.

However determining which data to mock and under what circumstances can be really challenging, at least in iOS development. I think most developers would agree that using dependency injection to mock data for testing or debugging is a valuable tool in any developers tool belt.

Using Command-Line Arguments to Configure In-App Dependencies
