Swift tool to generate Module Interfaces for Swift projects.

Overview

ModuleInterface

Build Status GitHub release (latest by date) License Swift version Twitter Follow

Swift tool to generate Module Interfaces for Swift projects.

What is a Module Interface

A Module Interface is what we commonly get using the CMD+click on an import statement in our codebases. SourceKit generates the code on demand. It can be a great tool and source of documentation.

asciicast

Examples

Usage

To generate the module interface from your project, or library, run the moduleinterface command directly from the root your project.

$ cd ~/path/to/MyAppOrFramework
$ moduleinterface generate

This command will analyze your MyAppOrFramework project and generate the module interface for the types that have the minimum access level defined. The module interface is written to the directory Documentation relative to the root of your project repository.

Usage options

$ moduleinterface help
Available commands:

clean      Delete the output folder and quit.
generate   Generates the Module Interface
help       Display general or command-specific help
version    Display the current version of ModuleInterface

Typing moduleinterface help <command> we get a list of all options for that command:

Generates the Swift Module Interface.

[--spm-module (string)]
	Generate documentation for Swift Package Manager module.

[--module-name (string)]
	Generate documentation for a Swift module.

[--input-folder (string)]
	Path to the input directory (defaults to /Users/minuscorp/Documents/GitHub/ModuleInterface).

[--output-folder (string)]
	Output directory (defaults to Documentation).

[--min-acl (string)]
	The minimum access level to generate documentation. Defaults to public.

--clean|-c
	Delete output folder before generating documentation.

[[]]
	List of arguments to pass to xcodebuild.

Usually, for most Xcode projects, no parameters are needed at all. xcodebuild should be able to find the default project and scheme.

If the command fails, try specifying the scheme (-scheme SchemeName) or the workspace. Any arguments passed to moduleinterface after -- will be passed to xcodebuild without modification.

$ moduleinterface generate -- -scheme MyScheme

For Swift Package Manager modules, you can the module name using the --spm-module parameter.

$ moduleinterface generate --spm-module ModuleInterface

Installation

Download Binary

$ curl -Ls https://github.com/minuscorp/ModuleInterface/releases/download/latest/moduleinterface.macos.zip -o /tmp/moduleinterface.macos.zip
$ unzip -j -d /usr/local/bin /tmp/moduleinterface.macos.zip 

From Sources

Requirements:

Swift 5.1 runtime and Xcode installed in your computer.

Using Homebrew

brew tap minuscorp/moduleinterface brew install moduleinterface

Building with Swift Package Manager

$ git clone https://github.com/minuscorp/ModuleInterface.git
$ cd ModuleInterface
$ make

Contact

Follow and contact me on Twitter at @minuscorp.

Contributions

If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.

License

ModuleInterface is licensed under the Apache 2.0. See LICENSE for more info.

Acknowledegments

  • To @eneko for giving me the tooling idea.
  • To SourceKitten for providing such an awesome Framework for dealing with SourceKit.
  • To BQ for all the mentoring.
You might also like...
A nifty command-line tool to customize macOS icons

iconset A nifty command line tool to manage macOS icons iconset is a new command line tool for macOS that allows you to change icons for macOS apps (e

🕳 A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image.

HolePunch NAME holepunch -- A simple command line tool to punch hole to reduce disk usage on APFS volume for such as a raw disk image. SYNOPSIS holepu

The best command-line tool to install and switch between multiple versions of Xcode.
The best command-line tool to install and switch between multiple versions of Xcode.

The best command-line tool to install and switch between multiple versions of Xcode.

Command Line Tool for interacting with MachO binaries on OSX/iOS

inject inject is a tool which interfaces with MachO binaries in order to insert load commands. Below is its help. ➜ ./inject -h OVERVIEW: inject v1.0.

CLI tool for macOS that transcribes speech from the microphone using Apple’s speech recognition API, SFSpeechRecognizer. (help.)
CLI tool for macOS that transcribes speech from the microphone using Apple’s speech recognition API, SFSpeechRecognizer. (help.)

CLI tool for macOS that uses SFSpeechRecognizer to transcribe speech from the microphone. The recognition result will be written to the standard output as JSON string.

CookCLI is provided as a command-line tool to make Cook recipe management easier

CookCLI is provided as a command-line tool to make Cook recipe management easier, and enable automation and scripting workflows for the CookLa

A Mac command-line tool that automatically downloads macOS Installers / Firmwares.
A Mac command-line tool that automatically downloads macOS Installers / Firmwares.

MIST - macOS Installer Super Tool A Mac command-line tool that automatically downloads macOS Installers / Firmwares: Features List all available macOS

macOS command line tool to return the available disk space on APFS volumes

diskspace Returns available disk space With the various APFS features the value for free disk space returned from tools such as du or df will not be a

A powerful command line tool for performing stoichiometry calculations on checmicals and chemical equations.

Stoichiometry Stoichiometry is a powerful command line tool for preforming stoichiometry chemicals and chemical equations. Its subcommands are listed

Comments
  • Installation problem (brew)

    Installation problem (brew)

    image

    ### Rakefile:

    require 'open3'
    
    task default: %w[setup]
    
    task :setup => [:brew, :precommit]
    
    task(:brew) do
    
      raise '`brew` is required. Please install brew. https://brew.sh/' unless system('which brew')
    
      puts('➡️  Brew')
      sh('brew bundle')
    
      puts('➡️  Bundle')
      sh('bundle install')
    
      puts('➡️  Cocoapods')
      sh('bundle exec pod install')
    end
    
    task(:precommit) do
      puts('Deleting other installed hooks to avoid collision...')
      puts('Checking overcommit installation...')
      if system('which overcommit')
        puts('Found system-wide overcommit installation, uninstalling hooks...')
        stdout, _, _ = Open3.capture3('overcommit --uninstall')
        puts(stdout) unless stdout.empty?
      elsif system('bundle show overcommit')
        puts('Found bundle-wide overcommit installation, uninstalling hooks...')
        stdout, _, _ = Open3.capture3('overcommit --uninstall')
        puts(stdout) unless stdout.empty?
      end
      puts('➡️  pre-commit 👮‍♀️')
      sh('pre-commit install -f')
      sh('pre-commit install --hook-type commit-msg')
    end
    
    task(:docs) do
      sh('sourcedocs generate --min-acl public --output-folder Docs -- -workspace REDACTED.xcworkspace -scheme REDACTED-Release')
      sh('moduleinterface generate --min-acl public --output-folder Docs -- -workspace REDACTED.xcworkspace -scheme REDACTED-Release')
    end
    
    
    bug 
    opened by canedo2 3
  • Update dependencies

    Update dependencies

    Hi, This PR updates the dependencies of ModuleInterface. This was an attempt to fix https://github.com/minuscorp/ModuleInterface/issues/6, but it didn't fixed it. Anyways here is a PR with the dependencies updated. Thanks

    opened by 4brunu 1
  • Xcode 14 error generating module interface

    Xcode 14 error generating module interface

    Hey, first of all thanks for this amazing tool.

    Since I updated to Xcode 14, ModuleInterface stoped working.

    moduleinterface generate --clean --module-name Example --output-folder Docs/API/ -- -scheme Example -workspace Example.xcworkspace -configuration Debug -destination "platform=iOS Simulator,name=iPhone 13,OS=latest" -verbose
    2022-10-10 14:38:30.370 xcodebuild[33775:5188973] Requested but did not find extension point with identifier Xcode.InterfaceBuilderBuildSupport.PlatformDefinition
    Running xcodebuild
    Checking xcodebuild -showBuildSettings
    Running xcodebuild
    The operation couldn’t be completed. (SourceKittenFramework.Request.Error error 2.)
    

    Do you have any idea what's wrong? Maybe the dependency SourceKitten needs to be updated? Thanks

    opened by 4brunu 0
  • Only generates Swift interface for mixed source

    Only generates Swift interface for mixed source

    We have internal tooling that publishes Swift interfaces for comment and review. For Swift-only frameworks our tooling works fine simply getting the abstract syntax tree of the Swift source code. However, this approach doesn't work when the source contains, or is primarily, Objective-C.

    We have an alternate process that will process *.swiftinterface files, but we have yet to find a process that works for generating these files from Objective-C or mixed source except for using the internal Xcode Generated interface. We are searching for a programmatic solution.

    Based on comments here (https://github.com/jpsim/SourceKitten/issues/405) I was hoping that this tool might solve our issue. However, when I run it on a simple dummy framework, which contains a SwiftClass object and an ObjCClass object, the generated interface only includes the SwiftClass interface even though the bridged ObjCClass is exposed.

    Is ModuleInterface intended to work with mixed source, or is it strictly for Swift-only frameworks (or the Swift-only portion of mixed frameworks)?

    enhancement 
    opened by tjprescott 7
Releases(v0.0.4)
Owner
Jorge Revuelta
Swift enthusiast. Senior iOS Developer. Machine learning lover in my spare time.
Jorge Revuelta
A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

A command line tool to parse pricing from a pdf and generate an updated csv file for House Call Pro

hhe-dev 10 Feb 17, 2022
Compose beautiful command line interfaces in Swift

Commander is a small Swift framework allowing you to craft beautiful command line interfaces in a composable way. Usage Simple Hello World i

Kyle Fuller 1.5k Dec 29, 2022
CommandLineKit - A pure Swift library for creating command-line interfaces

CommandLineKit A pure Swift library for creating command-line interfaces. Note: This project is no longer maintained. It's preserved here for historic

Ben Gollmer 1.1k Dec 1, 2022
Simple & Elegant Command Line Interfaces in Swift

An elegant pure Swift library for building command line applications. Features Tons of class, but no classes. 100% organic pure value types. Auto gene

hypertalk 52 Nov 9, 2022
Simple & Elegant Command Line Interfaces in Swift

An elegant pure Swift library for building command line applications. Features Tons of class, but no classes. 100% organic pure value types. Auto gene

hypertalk 52 Nov 9, 2022
Generate Markdown documentation from source code

SourceDocs SourceDocs is a command line tool that generates markdown documentation files from inline source code comments. Similar to Sphinx or Jazzy,

Eneko Alonso 349 Dec 10, 2022
Josephus - A command line tool to solve Josephus problem in Swift

josephus A command line tool to solve Josephus problem in Swift

Masahiro Oono 0 Jan 25, 2022
A Mac command-line tool that generates kick-ass Jamf Pro reports.

KMART - Kick-Ass Mac Admin Reporting Tool A command-line utility generating kick-ass Jamf Pro reports: Features Reporting on the following Jamf Pro ob

Nindi Gill 86 Dec 15, 2022
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

Majd Alfhaily 3k Dec 30, 2022
iOS command-line tool that allows searching and downloading ipa files from the iOS App Store

ipatool for iOS This is a port of Majd Alfhaily's ipatool adapted to run on iOS Build / Installation To build this, make sure you have AppSync install

dan 21 Sep 13, 2022