Pixyzehn
  • About
  • Articles
  • Logs
About Articles Logs

PackageBuilder builds a simple command-line structure by SwiftPM

May 20, 2017 #swift

Recently I created PackageBuilder to build a simple command-line structure easily by SwiftPM. It’s very simple, but it saves a lot your development time if you’d like to create a command line tool like Marathon created by @JohnSundell. This automatic tool is based on his great article. Also, This tool inspired by JohnSundell/SwiftPlate. If you agree with them, I’m sure you’ll like it:)

In its usage, what you have to do is just like this,

$ packagebuilder {PACKAGE_NAME}
$ packagebuilder {PACKAGE_NAME} --path ~/Developer/project

For instance,

$ packagebuilder AwesomePackage

The output is simple.

Executing `swift package init --type executable` at /Users/pixyzehn/Developer/projects/AwesomePackage/
Creating Sources/AwesomePackage...
Creating Sources/AwesomePackageCore...
Creating Tests/AwesomePackageTests...
Deleting original files created by SwiftPM...
Cloning PackageBulder by HTTPS to get files in Templates...
Renaming {PACKAGE_NAME} to AwesomePackage...
Renaming {YOUR_NAME} to Nagasawa Hiroki...
Renaming {THIS_YEAR} to 2017...
Moving files in Templates to a correct position...
Deleting the temp folder...
Executing `swift build` & `swift test --parallel`
Generating xcodeproj...
Enjoy AwesomePackage πŸŽ‰

And then, you will get the executable package like this,

.
β”œβ”€β”€ AwesomePackage.xcodeproj
β”‚Β Β  β”œβ”€β”€ AwesomePackageCore_Info.plist
β”‚Β Β  β”œβ”€β”€ AwesomePackageTests_Info.plist
β”‚Β Β  β”œβ”€β”€ project.pbxproj
β”‚Β Β  └── xcshareddata
β”‚Β Β      └── xcschemes
β”‚Β Β          β”œβ”€β”€ AwesomePackage.xcscheme
β”‚Β Β          └── xcschememanagement.plist
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Package.swift
β”œβ”€β”€ README.md
β”œβ”€β”€ Sources
β”‚Β Β  β”œβ”€β”€ AwesomePackage
β”‚Β Β  β”‚Β Β  └── main.swift
β”‚Β Β  └── AwesomePackageCore
β”‚Β Β      └── AwesomePackage.swift
└── Tests
β”œβ”€β”€ AwesomePackageTests
β”‚Β Β  └── AwesomePackageTests.swift
└── LinuxMain.swift

8 directories, 12 files

The merit of this tool is that you can work on creating a package as soon as you come up with a good idea. Let’s start creating an awesome package by opening xcodeproj in Xcode!

Great new project generation tool by @pixyzehn - it's like SwiftPlate for Swift Package Manager-based command line tools! πŸ‘ #swiftlang https://t.co/bcNQjME3gn

β€” John Sundell (@johnsundell) May 18, 2017

Thank you again, @JohnSundell.

Contributions are more than welcome!


Archives | Tags | RSS

© 2016-2026 Hiroki Nagasawa