version Swift Package Manager Build License

这是什么?

XcodeTargetGraphGen 是一个 Swift 命令行工具,它可以解析 .xcodeproj 文件,并使用 Mermaid 图表语法创建模块级内部依赖关系的可视化表示。通过支持多种包管理器,它允许用户以可视化的方式映射 Xcode 项目在各种环境中的结构和依赖关系,从而提供清晰易懂的图形化表示这些关系。

支持的包管理器如下:

安装

Swift Package Manager

作为 CLI 使用

git clone https://github.com/CuriositySoftware/XcodeTargetGraphGen.git
cd XcodeTargetGraphGen
swift run xcgraphgen [project-file-path]

用法

只需运行

xcgraphgen [project-file-path] [OPTIONS...] 
$ xcgraphgen -h
OVERVIEW: Output Xcode Target Dependency Graph.

USAGE: xcgraphgen [<options>] <project-file-path>

ARGUMENTS:
  <project-file-path>     .xcodeproj file path.

OPTIONS:
  --output-file-path <output-file-path>
                          Output file path. (default: ./dependencies.md)
  --mermaid-theme <mermaid-theme>
                          Select Mermaid theme type (eg: neutral, forest, dark, base). (default: dark)
  --mermaid-syntax-type <mermaid-syntax-type>
                          Select Mermaid syntax type. (default: flowchart)
  --mermaid-chart-direction <mermaid-chart-direction>
                          Select Mermaid graph/flowchart direction. (default: TD)
  --enable-swift-package-output/--disable-swift-package-output
                          Targeting Swift Package Product for output. (default: --disable-swift-package-output)
  --enable-apple-sdk-output/--disable-apple-sdk-output
                          Targeting Apple SDKs for output. (default: --disable-apple-sdk-output)
  --enable-carthage-output/--disable-carthage-output
                          Targeting Carthage for output. (default: --enable-carthage-output)
  --enable-cocoa-pods-output/--disable-cocoa-pods-output
                          Targeting CocoaPods SDKs for output (only old format without .xcfilelist). (default: --enable-cocoa-pods-output)
  --enable-vendor-output/--disable-vendor-output
                          Targeting vendor project for output. (default: --disable-vendor-output)
  --dry-run               Output to console without file output
  --version               Show the version.
  -h, --help              Show help information.

示例

swift run -c release xcgraphgen ./Samples/SampleiOSApp/SampleiOSApp.xcodeproj/
%%{init: {'theme':'dark'}}%%
flowchart TD
style SampleiOSApp stroke-width:4px
subgraph Swift Package
Algorithms["Algorithms"]
end
subgraph Swift Package Local
Utility["Utility"]
end
subgraph Carthage
APIKit.xcframework["APIKit.xcframework"]
end
subgraph Native Target
APIClient["APIClient"]
AppFeature["AppFeature"]
FeatureA["FeatureA"]
FeatureB["FeatureB"]
SampleiOSApp["SampleiOSApp"]
SampleiOSAppTests["SampleiOSAppTests"]
SampleiOSAppUITests["SampleiOSAppUITests"]
end
FeatureB --> APIClient
FeatureB --> Algorithms
AppFeature --> FeatureA
AppFeature --> FeatureB
SampleiOSAppTests --> SampleiOSApp
SampleiOSAppUITests --> SampleiOSApp
FeatureA --> APIClient
SampleiOSApp --> AppFeature
APIClient --> Utility
APIClient --> APIKit.xcframework
加载

其他库

Swift 和 iOS 社区还有其他 Xcode 工具,它们与 XcodeTargetGraphGen 相比,有不同的优先级和权衡。