【问题标题】:Use SwiftGen 6.1.0 for multiple assets in multiple directories对多个目录中的多个资产使用 SwiftGen 6.1.0
【发布时间】:2019-02-28 14:54:33
【问题描述】:

我有一个包含多个模块的非常大的项目。我在每个模块中使用单独的 Assets.xcassets。是否可以使用通用 .yml 声明来使用图像? 现在我的 .yml 如下所示:

xcassets:
inputs: 
    - /Assets.xcassets

outputs:
    - templateName: swift4
    output: /UIImage+Assets.swift

但是当我尝试构建项目时遇到问题:

[31mMissing entry for key xcassets.paths.[0m
Command /bin/sh failed with exit code 1

我需要创建正确的 .yml 以便通过一个方案在不同模块中通用。

【问题讨论】:

    标签: ios swift assets swiftgen


    【解决方案1】:

    好的,谷歌,谢谢你的回答=)

    FILENAMES = "assetPaths.txt"
    EXTENSION = ".xcassets"
    
    find . -name *$EXTENSION -print > $FILENAMES
    
    while read assetsPath; do
    if [[ $assetsPath != *"Pods"* ]]; then
    
    dir = `dirname "$assetsPath"`
    fileName = `basename "$assetsPath" "$EXTENSION"`
    outputFile = $dir"/"$fileName".swift"
    swiftgen xcassets "$assetsPath" -t swift4 --output "$outputFile"
    
    fi
    done < $FILENAMES
    
    rm $FILENAMES
    

    效果很好!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-02
      • 1970-01-01
      • 2013-10-29
      • 1970-01-01
      相关资源
      最近更新 更多