Swiftpack.co -  khamitimur/AmazingTargetCommand as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A spin on classic Command design pattern with a Swift version of Target-Action design pattern on top.
.package(url: "https://github.com/khamitimur/AmazingTargetCommand.git", from: "1.0.2")


AmazingTargetCommand is a spin on classic Command design pattern with a Swift version of Target-Action design pattern on top. Together they will enable you to create commands with ease, without unnecessary repetition and no chances of accidentally creating a retencion cycle.


Let's say that you are developing financial application and you have Command pattern already applied. And it works fine for global commands like Transfer and Deposit. But now you want to create a command Export that is specific to one of the application's screens. What do you do? You create a class that implements your command protocol. And here is where the problem arise. You just created a separate class for a command that is tightly coupled with one of many screens in the application. That's where AmazingTargetCommand comes to rescue.


import AmazingTargetCommand

class ExportViewModel {
    var exportCommand: AmazingTargetCommand<ExportViewModel, IndexPath>!
    init() {
        exportCommand = AmazingTargetCommand(target: self,
                                             executeAction: ExportViewModel.export,
                                             canExecuteAction: ExportViewModel.canExport)
    func export(_ parameter: IndexPath) {
        // ...
    func canExport(_ parameter: IndexPath) -> Bool {
        let canExport = true
        // ...
        return canExport

class ExportViewController: UIViewController, UITableViewDelegate {
    let viewModel = ExportViewModel()
    // ...
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    // ...

Check out AmazingTargetCommandButton for more applicable usage example.


  • macOS 10.14+
  • iOS 11.0+
  • tvOS 11.0+
  • watchOS 4.0+
  • Xcode 11+
  • Swift 5.0+



To integrate AmazingTargetCommand into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AmazingTargetCommand', '~> 1.0'

Swift Package Manager

To integrate AmazingTargetCommand into your Xcode project using Swift Package Manager, specify it as dependency in your Package.swift:

dependencies: [
    .package(url: "https://github.com/khamitimur/AmazingTargetCommand.git", .upToNextMajor(from: "1.0.0"))


This project is licensed under the MIT License.



Stars: 0
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Add types aliases
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API