Skip to content

Latest commit

 

History

History
186 lines (117 loc) · 5.98 KB

PlatformTools.md

File metadata and controls

186 lines (117 loc) · 5.98 KB

iOS Platform Tools

Overview

This article covers some existing useful dev-tools specifically for iOS Platform Team to improve dependency analysis, build-time measurement, and so on.

See Also:


Table of Contents

Dependency Graph Visualiser

Build Time Measurement

Others


Dependency Graph Visualiser

Guide: Home · PaulTaykalo/objc-dependency-visualizer Wiki

objc-dependency-visualizer is written in Ruby which searches for Xcode-generated .swiftdeps files in DerivedData to collect all dependencies to create a beautiful graph visualisation using d3.js .

Each node corresponds to either type or global variable / function.

DOT format with graphviz rendering is also supported.

Output

Script

TARGET='BabylonCore'

# Update origin.js (dependency graph dataset)
# -s PROJECT_NAME -f FORMAT --path path-to-swiftdeps-dir
./generate-objc-dependencies-to-json.rb \
    --swift-dependencies \
    -f json-var \
    -s "Babylon" \
    --target "$(TARGET)" \
    > origin.js
open index.html
# Generate PNG image from DOT file.
./generate-objc-dependencies-to-json.rb \
    --swift-dependencies \
    -f dot \
    -s "Babylon" \
    --target "$(TARGET)" \
    > output/dot/$(TARGET).dot
dot -Tpng output/dot/$(TARGET).dot -o output/dot/$(TARGET).png

Guide: swift-code-metrics/GUIDE.md

swift-code-metrics is a code metrics analyzer written in Python that parses Swift source code to generate "1 framework per node" dependency graph as well as other metrics such as code distribution, component stability, number of classes / imports / commetns / LoC, etc.

Output

Internal graph

Internal & External graph

Code Distribution

Script

# pip3 install swift-code-metrics
# swift-code-metrics --source ./ --artifacts output --generate-graphs

git clone https://github.com/matsoftware/swift-code-metrics

# NOTE: Latest code works better.
python3 swift-code-metrics-runner.py \
    --source ./path/to/babylon-ios/ \
    --artifacts output \
    --generate-graphs

Build Time Measurement

xcode-build-times-rendering creates a build-time gantt chart by injecting timestap logging in Run Script Build Phase. This will also support 3rd party libraries using CocoaPods.

Output

(NOTE: Some texts are manually added for more visibility)

Script

# NOTE: clean DerivedData first

# Setup Xcode script build phases.
./bin/xcode-build-times \
    --events-file output.txt \
    install ./path/to/babylon-ios

# Generate gantt chart.
./bin/xcode-build-times generate --events-file output.txt

open xcode-build-times-chart/gantt.html

spotify/XCLogParser is a log parser for Xcode-generated xcactivitylog to unzip its gunzip-ed file and measure build-time, warnings and errors, slowest file compilation, etc.

Output

Script

git clone https://github.com/spotify/XCLogParser
rake build[release]

# Parses `xcactivitylog` and report in html/json format.
xclogparser parse --project Babylon --reporter html

# Dumps the whole content of an xcactivitylog file as JSON.
xclogparser dump --project Babylon --output activity.json --redacted

# Outputs the contents of LogStoreManifest.plist.
xclogparser manifest --project Babylon

Others

Introducing Uber Poet, an Open Source Mock App Generator for Determining Faster Swift Builds | Uber Engineering Blog

Doc: uber-poet/layer_types.md

uber-poet is a mock-app generator with tons of frameworks being linked in many different dependency graph styles that builds on top of facebook/buck build system.

While this tool is not for measuring real-app dependency graph, it is useful to measure the build-time difference depending on the graph configuration before actually starting modularisation refactoring.

According to the above blog post, there was no significant difference among each graph.