Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 3.23 KB

README.md

File metadata and controls

76 lines (56 loc) · 3.23 KB

Autocomplete resources like images, fonts and segues in Swift projects.

Demo

Managing Images

Assets_xcassets

Currently you type:

 let myImage = UIImage(named: "MyImage")

With R.swift it becomes:

 let rImage = R.image.myImage()

Managing Colors

Notification_Center

Currently you type:

  let myColor = UIColor(named: "myColor")

With R.swift it becomes:

 let rColor = R.color.myColor

Managing Localization

Localizable_strings

Currently you type:

  let myString = String(format: NSLocalizedString("Hello", comment: ""))

With R.swift it becomes:

  let rString = R.string.localizable.hello()

1. Install it via CocoaPods by running pod install after adding this line to the Podfile:

pod ‘R.swift’

2. Add a new run script phase as follows:

OtherViews_と_AutomatingAssets_xcodeproj

3. Move it above the “Compile Sources,” as shown below:

The reason for is that the library will generate a R.generated.swift file, which will have all the properties that reference the assets used in our app. We want it generated before the app compiles all the files.

AutomatingAssets_xcodeproj

4. Paste the following script:

if [ $ACTION != "indexbuild" ]; then
  "$PODS_ROOT/R.swift/rswift" generate "$SRCROOT/R.generated.swift"
fi

AutomatingAssets_xcodeproj

5. Add $TEMP_DIR/rswift-lastrun to Input Files and $SRCROOT/R.generated.swift to Output Files like this:

AutomatingAssets_xcodeproj

6. Build the app and open the project’s folder we will see the R.generated.swift file:

AutomatingAssets

7. Drag and drop the file into the Xcode project and leave “Copy items if needed” unchecked:

R_generated_swift_と_Editing_AutomatingAssets_README_md_at_main_·_YamamotoDesu_AutomatingAssets