您的位置:首页 > 移动开发 > Swift

R.swift安装和问题解决

2020-06-23 04:43 176 查看

安装

官网地址

照着官网配置即可,这里中文翻译下

  1. 添加
    pod 'R.swift'
    执行pod install
  2. TARGETS
    -
    Build Phases
    点击加号添加
    New Run Script Phase
  3. 在新创建的
    Run Script
    拖拽到
    Compile Sources
    上方,添加脚本
    "$PODS_ROOT/R.swift/rswift" generate "$SRCROOT/R.generated.swift"
  4. Input Files
    中添加
    $TEMP_DIR/rswift-lastrun
    Output Files
    中添加
    $SRCROOT/R.generated.swift
  5. Command+B
    编译项目后再项目目录中会生成一个
    R.generated.swift
    文件,将该文件拖拽到项目中
    注意:添加文件时
    Copy items if needed
    不要勾选

可以在

.gitignore
添加一行
*.generated.swift
忽略该文件,避免造成冲突

问题

在编译的时候报错

Cycle inside wjnhub; building could produce unreliable results. This usually can be resolved by moving the target's Headers build phase before Compile Sources.
Cycle details:
→ That command depends on command in Target 'wjnhub': script phase “[CP] Embed Pods Frameworks”
→ Target 'wjnhub' has compile command for Swift source files
○ That command depends on command in Target 'wjnhub': script phase “Run Script”

该问题是由于在运行

complies Source
R.generated.swift
没有完全确定,仔细看一下安装的第三条知道该怎么干了
由于新添加的
Run Script
默认在最下面,此时我们只需要将
Run Script
拖拽到
Compile Sources
上方
即可

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: