All Projects β†’ rockbruno β†’ Swiftinfo

rockbruno / Swiftinfo

Licence: mit
πŸ“Š Extract and analyze the evolution of an iOS app's code.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftinfo

Phpinsights
πŸ”° Instant PHP quality checks from your console
Stars: ✭ 4,442 (+404.77%)
Mutual labels:  cli, hacktoberfest, analytics
Mod Pbxproj
A python module to manipulate XCode projects
Stars: ✭ 959 (+8.98%)
Mutual labels:  cli, hacktoberfest, xcode
Terjira
Terjira is a very interactive and easy to use CLI tool for Jira.
Stars: ✭ 713 (-18.98%)
Mutual labels:  cli, hacktoberfest
Jenkinsfile Runner
A command line tool to run Jenkinsfile as a function
Stars: ✭ 727 (-17.39%)
Mutual labels:  cli, hacktoberfest
Executor
Watch for file changes and then execute command. Very nice for test driven development.
Stars: ✭ 14 (-98.41%)
Mutual labels:  cli, hacktoberfest
Mevn Cli
Light speed setup for MEVN(Mongo Express Vue Node) Apps
Stars: ✭ 696 (-20.91%)
Mutual labels:  cli, hacktoberfest
Bat
A cat(1) clone with wings.
Stars: ✭ 30,833 (+3403.75%)
Mutual labels:  cli, hacktoberfest
Archisteamfarm
C# application with primary purpose of idling Steam cards from multiple accounts simultaneously.
Stars: ✭ 7,219 (+720.34%)
Mutual labels:  cli, hacktoberfest
Faas Cli
Official CLI for OpenFaaS
Stars: ✭ 633 (-28.07%)
Mutual labels:  cli, hacktoberfest
Namecheck
Check your name idea availability with CLI
Stars: ✭ 19 (-97.84%)
Mutual labels:  cli, tools
Swiftkit
Start your next Open-Source Swift Framework πŸ“¦
Stars: ✭ 785 (-10.8%)
Mutual labels:  cli, xcode
Clifx
Declarative framework for building command line interfaces
Stars: ✭ 900 (+2.27%)
Mutual labels:  cli, hacktoberfest
Backslide
πŸ’¦ CLI tool for making HTML presentations with Remark.js using Markdown
Stars: ✭ 679 (-22.84%)
Mutual labels:  cli, hacktoberfest
Buildxl
Microsoft Build Accelerator
Stars: ✭ 676 (-23.18%)
Mutual labels:  cli, xcode
Rotki
A portfolio tracking, analytics, accounting and tax reporting application that protects your privacy
Stars: ✭ 689 (-21.7%)
Mutual labels:  hacktoberfest, analytics
Wbot
A simple Web based BOT for WhatsAppβ„’ in NodeJS 😜. Working as of πŸ“… Feb 14th, 2020
Stars: ✭ 638 (-27.5%)
Mutual labels:  cli, hacktoberfest
Glow
Render markdown on the CLI, with pizzazz! πŸ’…πŸ»
Stars: ✭ 7,596 (+763.18%)
Mutual labels:  cli, hacktoberfest
Laminas Cli
Console command runner, exposing commands written in Laminas MVC and Mezzio components and applications
Stars: ✭ 25 (-97.16%)
Mutual labels:  cli, hacktoberfest
Badgehub
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
Stars: ✭ 592 (-32.73%)
Mutual labels:  hacktoberfest, xcode
Micro Dev
The development environment for `micro`
Stars: ✭ 630 (-28.41%)
Mutual labels:  cli, tools

πŸ“Š SwiftInfo

GitHub release

SwiftInfo is a CLI tool that extracts, tracks and analyzes metrics that are useful for Swift apps. Besides the default tracking options that are shipped with the tool, you can also customize SwiftInfo to track pretty much anything that can be conveyed in a simple .swift script.

By default SwiftInfo will assume you're extracting info from a release build and send the final results to Slack, but it can be used to extract info from individual pull requests as well with the danger-SwiftInfo danger plugin.

Available Providers

Type Name Description
πŸ“¦ IPASizeProvider Size of the .ipa archive (not the App Store size!)
πŸ“Š CodeCoverageProvider Code coverage percentage
πŸ‘Ά TargetCountProvider Number of targets (dependencies)
🎯 TestCountProvider Sum of all test target's test count
⚠️ WarningCountProvider Number of warnings in a build
πŸ§™β€β™‚οΈ OBJCFileCountProvider Number of OBJ-C files and headers (for mixed OBJ-C / Swift projects)
⏰ LongestTestDurationProvider The name and duration of the longest test
πŸ› TotalTestDurationProvider Time it took to build and run all tests
πŸ–Ό LargestAssetCatalogProvider The name and size of the largest asset catalog
🎨 TotalAssetCatalogsSizeProvider The sum of the size of all asset catalogs
πŸ’» LinesOfCodeProvider Executable lines of code
🚚 ArchiveDurationProvider Time it took to build and archive the app
πŸ“· LargestAssetProvider The largest asset in the project. Only considers files inside asset catalogs.

Each provider may have a specific set of requirements in order for them to work. Check their documentation to learn more.

Usage

SwiftInfo extracts information by analyzing the logs that your build system generates when you build and/or test your app. Because it requires these logs to work, SwiftInfo is meant to be used alongside a build automation tool like fastlane. The following topics describe how you can retrieve these logs and setup SwiftInfo itself.

We'll show how to get the logs first as you'll need them to configure SwiftInfo.

Note: This repository contains an example project. Check it out to see the tool in action -- just go to the example project folder and run make swiftinfo in your terminal.

Retrieving raw logs with fastlane

If you use fastlane, you can expose raw logs to SwiftInfo by adding the buildlog_path argument to scan (test logs) and gym (build logs). Here's a simple example of a fastlane lane that runs tests, submits an archive to TestFlight and runs SwiftInfo (make sure to edit the folder paths to what's being used by your project):

desc "Submits a new beta build and runs SwiftInfo"
lane :beta do
  # Run tests, copying the raw logs to the project folder
  scan(
    scheme: "MyScheme",
    buildlog_path: "./build/tests_log"
  )

  # Archive the app, copying the raw logs to the project folder and the .ipa to the /build folder
  gym(
    workspace: "MyApp.xcworkspace",
    scheme: "Release",
    output_directory: "build",
    buildlog_path: "./build/build_log"
  )

  # Send to TestFlight
  pilot(
      skip_waiting_for_build_processing: true
  )

  # Run the CocoaPods version of SwiftInfo
  sh("../Pods/SwiftInfo/bin/swiftinfo")

  # Commit and push SwiftInfo's output
  sh("git add ../SwiftInfo-output/SwiftInfoOutput.json")
  sh("git commit -m \"[ci skip] Updating SwiftInfo Output JSON\"")
  push_to_git_remote
end

Retrieving raw logs manually

An alternative that doesn't require fastlane is to simply manually run xcodebuild / xctest and pipe the output to a file. We don't recommend doing this in a real project, but it can be useful if you just want to test the tool without having to setup fastlane.

xcodebuild -workspace ./Example.xcworkspace -scheme Example 2>&1 | tee ./build/build_log/Example-Release.log

Configuring SwiftInfo

SwiftInfo itself is configured by creating a Infofile.swift file in your project's root. Here's an example one with a detailed explanation:

import SwiftInfoCore

// Use `FileUtils` to configure the path of your logs. 
// If you're retrieving them with fastlane and don't know what the name of the log files are going to be, 
// just run it once to have it create them.

FileUtils.buildLogFilePath = "./build/build_log/MyApp-MyConfig.log"
FileUtils.testLogFilePath = "./build/tests_log/MyApp-MyConfig.log"

// Now, create a `SwiftInfo` instance by passing your project's information.

let projectInfo = ProjectInfo(xcodeproj: "MyApp.xcodeproj",
                              target: "MyTarget",
                              configuration: "MyConfig")

let api = SwiftInfo(projectInfo: projectInfo)

// Use SwiftInfo's `extract()` method to extract and append all the information you want into a single property.

let output = api.extract(IPASizeProvider.self) +
             api.extract(WarningCountProvider.self) +
             api.extract(TestCountProvider.self) +
             api.extract(TargetCountProvider.self, args: .init(mode: .complainOnRemovals)) +
             api.extract(CodeCoverageProvider.self, args: .init(targets: ["NetworkModule", "MyApp"])) +
             api.extract(LinesOfCodeProvider.self, args: .init(targets: ["NetworkModule", "MyApp"]))

// Lastly, process the output.

if isInPullRequestMode {
    // If called from danger-SwiftInfo, print the results to the pull request
    api.print(output: output)
} else {
    // If called manually, send the results to Slack...
    api.sendToSlack(output: output, webhookUrl: url)
    // ...and save the output to your repo so it serves as the basis for new comparisons.
    api.save(output: output)
}

Saving and visualizing the data

After successfully extracting data, you should call api.save(output: output) to have SwiftInfo add/update a json file in the {Infofile path}/SwiftInfo-output folder. It's important to add this file to version control after the running the tool as this is what SwiftInfo uses to compare new pieces of information.

You can then use SwiftInfo-Reader to transform this output into a more visual static HTML page.

Customizing Providers

To be able to support different types of projects, SwiftInfo provides customization options to some providers. See the documentation for each provider to see what it supports. If you wish to track something that's not handled by the default providers, you can also create your own providers. Click here to see how.

Customizing Runs

Any arguments you pass to SwiftInfo can be inspected inside your Infofile. This allows you to pass any custom information you want to the binary and use it to customize your runs.

For example, if you run SwiftInfo by calling swiftinfo --myCustomArgument, you can use ProcessInfo to check for its presence inside your Infofile.

if ProcessInfo.processInfo.arguments.contains("--myCustomArgument") {
    print("Yay, custom arguments!")
}

If the argument has a value, you can also fetch that value with UserDefaults.

Installation

CocoaPods

pod 'SwiftInfo'

Homebrew

To install SwiftInfo with Homebrew the first time, simply run these commands:

brew tap rockbruno/SwiftInfo https://github.com/rockbruno/SwiftInfo.git
brew install rockbruno/SwiftInfo/swiftinfo

To update to the newest Homebrew version of SwiftInfo when you have an old version already installed, run:

brew upgrade swiftinfo

Manually

Download the latest release and unzip the contents somewhere in your project's folder.

Swift Package Manager

SwiftPM is currently not supported due to the need of shipping additional files with the binary, which SwiftPM does not support. We might find a solution for this, but for now there's no way to use the tool with it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].