Installing command line tools for xcode9/10/2023 ![]() This is needed to be able to use our executable as an actual command-line tool from the terminal.Īs we can now make use of the ArgumentParser framework we can start writing the code to generate the banners.įor this, we first need to create our main banner command: Note that we’ve also added a product in the Package.swift file. The package will be imported into Xcode after which you can use it in the main.swift file after building the project: testTarget(name: "BannerTests", dependencies: ), Open the Package.swift file which will open the Package in Xcode and adjust the file to match the following result: We can make use of the ArgumentParser framework after adding it as a dependency in our Package file. If you’re unfamiliar with Property Wrappers, you can check out my blog post Property wrappers to remove boilerplate code in Swift. It’s a great framework for code inspiration as it makes use of a lot of Property Wrappers. The framework makes it a lot easier to add subcommands and arguments for your command-line tool. We can do this by making use of Apple’s open-sourced ArgumentParser framework. In our case, we would like to add an argument for the blog post title and the week number which is used in the banner’s filename. The next step is adding arguments to allow user input. This is the very basic setup for our command-line tool! You can see this by building and running the code: ![]() The created code is very simple and only contains a “Hello, world!” print statement. gitignore file that is adjusted for working a Swift Package. The command will print out the following lines:Ĭreating Tests/BannerTests/BannerTests.swiftĬreating Tests/BannerTests/XCTestManifests.swiftĪs you can see, it automatically took the folder name as the name of the executable. We first created a new folder called Banner, changed directory to this new folder, and then initialized the new package with the type set to executable. In this example, I’m going to use the name Banner for creating the blog post banners. We initialize a new project by making use of the Swift Package Manager. Once you’ve found something you can automate or replace by a command-line tool, it’s time to dive in and start creating it. If you’re unfamiliar with the Swift Package Manager, I highly encourage you to first read my blog post called Swift Package framework creation in Xcode. GitBuddy: Your buddy in managing and maintaining GitHub repositories.Ĭreating a command-line tool using the Swift Package Manager. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |