如何将R.swift添加到XcodeGen项目中?

问题描述 投票:0回答:4

我正在尝试 XcodeGen,但遇到了问题。我无法添加“R.Swift”依赖项。不通过 SPM 不通过 CocoaPods(

对于SPM,我不明白如何将运行构建工具插件“RswiftGeneratesInternalResources (Swift)”添加到目标/构建阶段

对于 R. generated.swift 文件中的 Cocoapods,会出现错误“没有这样的模块‘Rswift’

任何人都可以帮助我并展示如何将 R.swift 添加到 XcodeGen 项目中吗?

swift cocoapods swift-package-manager xcodegen r.swift
4个回答
0
投票

最后,我只是转向了SwiftGen)事实证明,在 XcodeGen 项目中使用它要容易得多。


0
投票

这是我的项目.yml。 (使用 cocoapods,而不是 spm。)

targets:
  MyApp:
    type: application
    platform: iOS 
    sources:
      - MyApp
    preBuildScripts:
      - name: Generate R.swift
        script: |
          "$PODS_ROOT/R.swift/rswift" generate "$SRCROOT/MyApp/R.generated.swift"
        basedOnDependencyAnalysis: false


0
投票

XcodeGen 从 2.37.0 开始支持构建工具插件。

packages:
  Rswift:
    url: https://github.com/mac-cain13/R.swift
    from: 7.4.0
targets:
  MyApp:
    dependencies:
      - package: Rswift
        product: RswiftLibrary
    buildToolPlugins:
      - plugin: RswiftGenerateInternalResources
        package: Rswift

-2
投票

要使用 SPM 将 R.swift 添加到 Xcodegen,您可以执行以下步骤:

  • https://github.com/mac-cain13/R.swift/releases下载已发布的 R.swift 包。解压下载的 .zip 文件,复制
    rswift
    文件并将其放置在
    .xcodeproj
    文件所在的目录中,例如。
    scripts/rswift
  • 打开
    project.yml
    文件并将 R.swift 声明为依赖项。确保添加
    RswiftLibrary
    作为包装的产品。
  • 通过以下更改修改构建运行脚本:

“$SRCROOT/scripts/rswift”生成“$SRCROOT/R. generated.swift”

按照以下步骤,您可以使用 SPM 将 R.swift 集成到 Xcodegen 中。

© www.soinside.com 2019 - 2024. All rights reserved.