Skip to content

Commit

Permalink
Merge pull request #22 from rockbruno/homebrew-implementation
Browse files Browse the repository at this point in the history
Homebrew
  • Loading branch information
rockbruno authored May 3, 2019
2 parents b174df1 + d63a78a commit 08469aa
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 67 deletions.
51 changes: 26 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,50 @@
-->

## master
* Added support for installation via Homebrew. - [Cihat Gündüz](https://github.com/Dschee) (Issue [#17](https://github.com/rockbruno/SwiftInfo/issues/17), PR [#20](https://github.com/rockbruno/SwiftInfo/pull/20))

## 2.2.0
* Added LargestAssetProvider - Bruno Rocha
* Changed how SwiftInfo generates summary results to allow custom providers to make use of SwiftInfo-Reader - Bruno Rocha
* Small visual improvements to summaries - Bruno Rocha
* Added LargestAssetProvider - [Bruno Rocha](https://github.com/rockbruno)
* Changed how SwiftInfo generates summary results to allow custom providers to make use of SwiftInfo-Reader - [Bruno Rocha](https://github.com/rockbruno)
* Small visual improvements to summaries - [Bruno Rocha](https://github.com/rockbruno)

## 2.1.0
* Added ArchiveTimeProvider - Bruno Rocha
* SwiftInfo will now continue executing even if a provider fails (the reasons are printed in the final summary) - Bruno Rocha
* Improvements to the durability of many providers and fixing minor bugs related to them - Bruno Rocha
* Fixed many providers silently failing if Xcode's new build system was active - Bruno Rocha
* Fixed many providers reporting empty results when they should have failed - Bruno Rocha
* Added ArchiveTimeProvider - [Bruno Rocha](https://github.com/rockbruno)
* SwiftInfo will now continue executing even if a provider fails (the reasons are printed in the final summary) - [Bruno Rocha](https://github.com/rockbruno)
* Improvements to the durability of many providers and fixing minor bugs related to them - [Bruno Rocha](https://github.com/rockbruno)
* Fixed many providers silently failing if Xcode's new build system was active - [Bruno Rocha](https://github.com/rockbruno)
* Fixed many providers reporting empty results when they should have failed - [Bruno Rocha](https://github.com/rockbruno)

## 2.0.2
* Fixed some providers reporting wrong colors for the result - Bruno Rocha
* Fixed some providers reporting wrong colors for the result - [Bruno Rocha](https://github.com/rockbruno)

## 2.0.1
* Fixed LongestTest's provider not working with non-legacy workspaces - Bruno Rocha
* Fixed LongestTest's provider not working with non-legacy workspaces - [Bruno Rocha](https://github.com/rockbruno)

## 2.0.0
* Added support for arguments - Bruno Rocha
* Updated to Swift 5 - Bruno Rocha
* Improved CodeCoverageProvider and LinesOfCodeProvider - Bruno Rocha
* Added support for arguments - [Bruno Rocha](https://github.com/rockbruno)
* Updated to Swift 5 - [Bruno Rocha](https://github.com/rockbruno)
* Improved CodeCoverageProvider and LinesOfCodeProvider - [Bruno Rocha](https://github.com/rockbruno)

## 1.2.0
* Added LinesOfCodeProvider - Bruno Rocha
* Slightly improved generic summary messages - Bruno Rocha
* Added LinesOfCodeProvider - [Bruno Rocha](https://github.com/rockbruno)
* Slightly improved generic summary messages - [Bruno Rocha](https://github.com/rockbruno)

## 1.1.0
* Linked sourcekitd to allow extraction of code related metrics - Bruno Rocha
* Added OBJCFileCountProvider - Bruno Rocha
* Added LongestTestDurationProvider - Bruno Rocha
* Added TotalTestDurationProvider - Bruno Rocha
* Added LargestAssetCatalogProvider - Bruno Rocha
* Added TotalAssetCatalogsSizeProvider - Bruno Rocha
* Linked sourcekitd to allow extraction of code related metrics - [Bruno Rocha](https://github.com/rockbruno)
* Added OBJCFileCountProvider - [Bruno Rocha](https://github.com/rockbruno)
* Added LongestTestDurationProvider - [Bruno Rocha](https://github.com/rockbruno)
* Added TotalTestDurationProvider - [Bruno Rocha](https://github.com/rockbruno)
* Added LargestAssetCatalogProvider - [Bruno Rocha](https://github.com/rockbruno)
* Added TotalAssetCatalogsSizeProvider - [Bruno Rocha](https://github.com/rockbruno)

## 1.0.0
* Added Unit Tests - Bruno Rocha
* InfoProvider's `extract() -> Self` is now `extract(fromApi api: SwiftInfo) -> Self` - Bruno Rocha
* Revamped logs - Bruno Rocha
* Added Unit Tests - [Bruno Rocha](https://github.com/rockbruno)
* InfoProvider's `extract() -> Self` is now `extract(fromApi api: SwiftInfo) -> Self` - [Bruno Rocha](https://github.com/rockbruno)
* Revamped logs - [Bruno Rocha](https://github.com/rockbruno)

## 0.1.1
* Fixed dylib search paths by using `--driver-mode=swift` when running `swiftc` - Bruno Rocha
* Fixed dylib search paths by using `--driver-mode=swift` when running `swiftc` - [Bruno Rocha](https://github.com/rockbruno)

## 0.1.0
(Initial Release)
16 changes: 0 additions & 16 deletions ExampleProject/Podfile.lock

This file was deleted.

2 changes: 1 addition & 1 deletion ExampleProject/_CDToMeAndRun.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bundle install
bundle exec pod install
bundle exec fastlane beta
./Pods/SwiftInfo/swiftinfo
./Pods/SwiftInfo/bin/swiftinfo
echo "-------"
echo "This bash script runs SwiftInfo outside of fastlane so you can see the output, but check out the Fastfile to see how you could use this in a real project."
18 changes: 18 additions & 0 deletions Formula/swiftinfo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Swiftinfo < Formula
desc "📊 Extract and analyze the evolution of an iOS app's code."
homepage "https://github.com/rockbruno/SwiftInfo"
version "2.3.0"
url "https://github.com/rockbruno/SwiftInfo/releases/download/#{version}/swiftinfo.zip"
# TODO: Try something to provide a SHA automatically

depends_on :xcode => ["10.2", :build]

def install
bin.install Dir["bin/*"]
include.install Dir["include/*"]
end

test do
system bin/"swiftinfo", "-version"
end
end
49 changes: 45 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
prepare:
swift build -c release --disable-sandbox
./prepare_for_release.sh
SHELL = /bin/bash

REPODIR = $(shell pwd)
BUILDDIR = $(REPODIR)/.build
RELEASEBUILDDIR = $(BUILDDIR)/release
TEMPPRODUCTDIR = $(BUILDDIR)/_PRODUCT
PRODUCTDIR = $(RELEASEBUILDDIR)/_PRODUCT

.DEFAULT_GOAL = all

.PHONY: all
all: build

.PHONY: build
build:
@swift build \
-c release \
--disable-sandbox \
--build-path "$(BUILDDIR)"
@rm -rf "$(PRODUCTDIR)"
@rm -rf "$(TEMPPRODUCTDIR)"
@mkdir -p "$(TEMPPRODUCTDIR)"
@mkdir -p "$(TEMPPRODUCTDIR)/include/swiftinfo"
@cp -a "$(RELEASEBUILDDIR)/." "$(TEMPPRODUCTDIR)/include/swiftinfo"
@cp -a "$(TEMPPRODUCTDIR)/." "$(PRODUCTDIR)"
@rm -rf "$(TEMPPRODUCTDIR)"
@mkdir -p "$(PRODUCTDIR)/bin"
@rm -rf $(PRODUCTDIR)/include/swiftinfo/*.build
@rm -rf $(PRODUCTDIR)/include/swiftinfo/*.product
@rm -rf $(PRODUCTDIR)/include/swiftinfo/ModuleCache
@rm -f "$(PRODUCTDIR)/include/swiftinfo/SwiftInfo.swiftdoc"
@rm -f "$(PRODUCTDIR)/include/swiftinfo/SwiftInfo.swiftmodule"
@mv "$(PRODUCTDIR)/include/swiftinfo/swiftinfo" "$(PRODUCTDIR)/bin"
@cp -a "$(REPODIR)/Sources/Csourcekitd/." "$(PRODUCTDIR)/include/swiftinfo/Csourcekitd"
@rm -f "$(RELEASEBUILDDIR)/swiftinfo"
@ln -s "$(PRODUCTDIR)/bin/swiftinfo" "$(RELEASEBUILDDIR)/swiftinfo"
@cp "$(REPODIR)/LICENSE" "$(PRODUCTDIR)/LICENSE"

.PHONY: package
package:
tar -zcvf "swiftinfo-2.2.0.tar.gz" ./bin
rm -f "$(PRODUCTDIR)/swiftinfo.zip"
cd $(PRODUCTDIR) && zip -r ./swiftinfo.zip ./
echo "ZIP created at: $(PRODUCTDIR)/swiftinfo.zip"

.PHONY: clean
clean:
@rm -rf "$(BUILDDIR)"
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SwiftInfo is a simple CLI tool that extracts, tracks and analyzes metrics that a

## Usage

SwiftInfo requires the raw logs of a succesful test/archive build combo to work, so it's better used as the last step of a CI pipeline.
SwiftInfo requires the raw logs of a succesful test/archive build combo to work, so it's better used as the last step of a CI pipeline.

### Retrieving raw logs with Fastlane

Expand All @@ -35,20 +35,20 @@ If you use Fastlane, you can expose the raw logs after building by adding `build
```ruby
desc "Submits a new beta build and runs SwiftInfo"
lane :beta do
# Run tests, copying the raw logs to the project folder
# 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
Expand Down Expand Up @@ -178,11 +178,26 @@ Documentation of useful types and methods from SwiftInfoCore that you can use wh

## Installation

### [Homebrew](https://brew.sh/)

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

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

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

```bash
brew upgrade swiftinfo
```

### CocoaPods

`pod 'SwiftInfo'`

### Manually
### Manual

Download the [latest release](https://github.com/rockbruno/SwiftInfo/releases) and unzip the contents somewhere in your project's folder.

Expand Down
5 changes: 4 additions & 1 deletion Sources/SwiftInfo/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ public struct Main {
static func run() {
let fileUtils = FileUtils()
let toolchainPath = getToolchainPath()
log("SwiftInfo")
log("SwiftInfo 2.3.0")
if ProcessInfo.processInfo.arguments.contains("-version") {
exit(0)
}
log("Dylib Folder: \(fileUtils.toolFolder)", verbose: true)
log("Infofile Path: \(try! fileUtils.infofileFolder())", verbose: true)
log("Toolchain Path: \(toolchainPath)", verbose: true)
Expand Down
12 changes: 8 additions & 4 deletions Sources/SwiftInfoCore/FileUtils/FileUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ public struct FileUtils {
}

public var toolFolder: String {
guard let executionPath = ProcessInfo.processInfo.arguments.first,
let url = URL(string: executionPath)?.deletingLastPathComponent().absoluteString else
{
guard let executablePath = ProcessInfo.processInfo.arguments.first else {
fail("Couldn't determine the folder that's running SwiftInfo.")
}
return url

let executableUrl = URL(fileURLWithPath: executablePath)
if let isAliasFile = try! executableUrl.resourceValues(forKeys: [URLResourceKey.isAliasFileKey]).isAliasFile, isAliasFile {
return try! URL(resolvingAliasFileAt: executableUrl).deletingLastPathComponent().path
} else {
return executableUrl.deletingLastPathComponent().path
}
}

public func infofileFolder() throws -> String {
Expand Down
9 changes: 5 additions & 4 deletions Sources/SwiftInfoCore/Runner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ public enum Runner {
public static func getCoreSwiftCArguments(fileUtils: FileUtils,
toolchainPath: String,
processInfoArgs: [String]) -> [String] {
let include = fileUtils.toolFolder + "/../include/swiftinfo"
return [
"swiftc",
"--driver-mode=swift", // Don't generate a binary, just run directly.
"-L", // Link with SwiftInfoCore manually.
fileUtils.toolFolder,
include,
"-I",
fileUtils.toolFolder,
include,
"-lSwiftInfoCore",
"-Xcc",
"-fmodule-map-file=\(fileUtils.toolFolder)Csourcekitd/include/module.modulemap",
"-fmodule-map-file=\(include)/Csourcekitd/include/module.modulemap",
"-I",
"\(fileUtils.toolFolder)Csourcekitd/include",
"\(include)/Csourcekitd/include",
(try! fileUtils.infofileFolder()) + "Infofile.swift",
"-toolchain",
"\(toolchainPath)"] + Array(processInfoArgs.dropFirst()) // Route SwiftInfo args to the sub process
Expand Down
2 changes: 1 addition & 1 deletion SwiftInfo.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'SwiftInfo'
s.module_name = 'SwiftInfo'
s.version = '2.2.0'
s.version = '2.3.0'
s.license = { type: 'MIT', file: 'LICENSE' }
s.summary = 'Extract and analyze the evolution of an iOS app\'s code.'
s.homepage = 'https://github.com/rockbruno/SwiftInfo'
Expand Down
8 changes: 5 additions & 3 deletions Tests/SwiftInfoTests/CoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ final class CoreTests: XCTestCase {
toolchainPath: toolchainPath,
processInfoArgs: exampleRun)
let executionPath = ProcessInfo.processInfo.arguments.first!
let toolFolder = URL(string: executionPath)!.deletingLastPathComponent().absoluteString
let toolFolder = URL(string: executionPath)!
.deletingLastPathComponent()
.absoluteString + "../include/swiftinfo"
XCTAssertEqual(args, ["swiftc",
"--driver-mode=swift",
"-L", toolFolder, "-I", toolFolder, "-lSwiftInfoCore",
"-Xcc",
"-fmodule-map-file=\(toolFolder)Csourcekitd/include/module.modulemap",
"-I", "\(toolFolder)Csourcekitd/include",
"-fmodule-map-file=\(toolFolder)/Csourcekitd/include/module.modulemap",
"-I", "\(toolFolder)/Csourcekitd/include",
"./Infofile.swift", "-toolchain", "\(toolchainPath)", "-v", "-s"])
}

Expand Down
3 changes: 0 additions & 3 deletions prepare_for_release.sh

This file was deleted.

Binary file removed swiftinfo-2.2.0.tar.gz
Binary file not shown.

0 comments on commit 08469aa

Please sign in to comment.