1. Introduce the R.swift library under the project using Cocopods.
2, click on TARGETS -> Build Phases -> upper left + -> New Run Script Phase, as shown below:
3. Configure the following in Run Script:
3.1 $PODS_ROOT/R.s wift/rswift generate $SRCROOT/r. gutierrez enerated. Swift 3.2 Input files inside add $TEMP_DIR/rswift lastrun - 3.3 Add $r. gutierrez enerated SRCROOT/within the Output files. The swiftCopy the code
Note: After adding, move the Run Script to the top of Compile Sources to ensure that r. swift, Run Script, and resource files are loaded in normal order; otherwise, an error will be reported during later operation.
4. When Command+B compiles the project, the r.enerated. swift file will be automatically generated in the project directory. Drag the file to the project without checking Copy items if needed.
At this point, can be happy to play.
For detailed instructions on how to use R.swift, go to https://github.com/mac-cain13/R.swift