Skip to content

Commit dadaa8e

Browse files
authored
Merge pull request #696 from 9race/master
Update QandA doc
2 parents afa97b7 + a4c39be commit dadaa8e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Documentation/QandA.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@
22

33
## Why was R.swift created?
44

5-
Swift is a beautiful language and one of it's main advantages is that more and more is typed. This catches a lot of errors at compile time. It feels very strange to refer to resources with strings that will always compile and then fail at runtime. It makes refactoring hard and it's to easy to create bugs like missing images etc.
5+
Swift is a beautiful language and one of it's main advantages is its increasing popularity. However, it can be frustrating to deal with errors that compile but fail during runtime due to missing resources. This makes refactoring difficult while making it easy to create bugs (e.g. missing images etc).
66

7-
In Android there is a generated R class that kind of solves this problem. That was why I decided to make something like it for us Swift developers and called the project R.swift. It was well received by colleagues, friends and Github stargazers, so here we are now.
7+
Android tackles this problem by generating something called the R class. It inspired me to create this very project, R.swift, which, thankfully, was well received by colleagues, friends and Github stargazers, so here we are now.``
88

99
## Why should I choose R.swift over alternative X or Y?
1010

11-
There are many nice R.swift alternatives like [SwiftGen](https://github.com/AliSoftware/SwiftGen), [Shark](https://github.com/kaandedeoglu/Shark) and [Natalie](https://github.com/krzyzanowskim/Natalie). I believe R.swift has important advantages over all of them:
11+
There are many nice R.swift alternatives like [SwiftGen](https://github.com/AliSoftware/SwiftGen), [Shark](https://github.com/kaandedeoglu/Shark) and [Natalie](https://github.com/krzyzanowskim/Natalie). However, I believe R.swift has these important advantages:
1212
- R.swift inspects your Xcodeproj file for resources instead of scanning folders or asking you for files
1313
- R.swift supports a lot of different assets
14-
- R.swift stays very close to the vanilla Apple API's, it's a minimal code change with maximum impact
14+
- R.swift stays very close to the vanilla Apple API's, having minimal code change with maximum impact
1515

1616
## What are the requirements to run R.swift?
1717

1818
R.swift works with Xcode 10 for apps targetting iOS 8 and tvOS 9 and higher.
1919

20-
## How to use methods with a `Void` argument?
20+
## How do I use methods with a `Void` argument?
2121

22-
Xcode might autocomplete a function with a `Void` argument (`R.image.settingsIcon(Void)`), just remove the `Void` argument and you're good to go: `R.image.settingsIcon()`.
22+
Xcode might autocomplete a function with a `Void` argument (`R.image.settingsIcon(Void)`); to solve this, simply remove the `Void` argument and you're good to go: `R.image.settingsIcon()`.
2323

2424
The reason this happens is because of the availability of the var `R.image.settingsIcon.*` for information about the image and also having a function with named the same name.
2525

26-
## How to fix missing imports in the generated file?
26+
## How do I fix missing imports in the generated file?
2727

28-
If you get errors like `Use of undeclared type 'SomeType'` in the `R.generated.swift` file most of the time this can be fixed by [explicitly stating the module in your xib or storyboard](Images/ExplicitCustomModule.png). This will make R.swift recognize that an import is necessary.
28+
If you get errors like `Use of undeclared type 'SomeType'` in the `R.generated.swift` file, this can usually be fixed by [explicitly stating the module in your xib or storyboard](Images/ExplicitCustomModule.png). This will make R.swift recognize that an import is necessary.
2929

30-
## How to use classes with the same name as their module?
30+
## How do I use classes with the same name as their module?
3131

32-
If you get errors like `'SomeType' is not a member type of 'SomeType'` you're using a module that contains a class/struct/enum with the same name as the module itself. This is a known [Swift issue](https://bugs.swift.org/browse/SR-898).
32+
If you get errors like `'SomeType' is not a member type of 'SomeType'`, that means you are using a module that contains a class/struct/enum with the same name as the module itself. This is a known [Swift issue](https://bugs.swift.org/browse/SR-898).
3333

34-
Work around this problem by [*emptying* the module field in the xib or storyboard](Images/ExplicitCustomModule.png). Then [add `--import SomeType` as a flag](Images/CustomImport.png) to the R.swift build phase to make sure R.swift imports the module in the generated file.
34+
You can work around this problem by [*emptying* the module field in the xib or storyboard](Images/ExplicitCustomModule.png) and then [adding `--import SomeType` as a flag](Images/CustomImport.png) to the R.swift build phase to ensure R.swift imports the module in the generated file.
3535

3636
## Can I use R.swift in a library?
3737

3838
Yes, just add R.swift as a buildstep in your library project and it will work just like normal. This works best if you have a dedicated Xcode project you can use to add the build script to. For Cocoapod users: this is [not the case](https://github.com/mac-cain13/R.swift/issues/430#issue-344112657) if you've used `pod lib create MyNewLib` to scaffold your library.
3939

40-
If you want to expose the resources to users of your library you have to make the generated code public, you can do this by adding `--accessLevel public` to the call to R.swift. For example, if you included R.swift as a cocoapod dependency to your library project, you would change your build step to: `"$PODS_ROOT/R.swift/rswift" generate --accessLevel public "$SRCROOT"`
40+
If you want to expose the resources to users of your library, you have to make the generated code public, you can do this by adding `--accessLevel public` to the call to R.swift. For example, if you included R.swift as a cocoapod dependency to your library project, you would change your build step to: `"$PODS_ROOT/R.swift/rswift" generate --accessLevel public "$SRCROOT"`
4141

4242
## How does R.swift work?
4343

4444
During installation you add R.swift as a Build phase to your target, basically this means that:
4545
- Every time you build R.swift will run
4646
- It takes a look at your Xcode project file and inspects all resources linked with the target currently build
47-
- It generates a `R.generated.swift` file that contains a struct with types references to all of your resources
47+
- It generates a `R.generated.swift` file that contains a struct with types references to all of your resources
4848

0 commit comments

Comments
 (0)