Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-cain13 committed Dec 12, 2016
1 parent 9d2fe72 commit 67d837e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
Binary file added Documentation/Images/CustomImport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Documentation/QandA.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ The reason this happens is because of the availability of the var `R.image.setti

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.

## How to use classes with the same name as their module?

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).

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.

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

Yes, just add R.swift as a buildstep in your library project and it will work just like normal. 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.
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Runtime validation with [`R.validate()`](Documentation/Examples.md#runtime-valid
- [What are the requirements to run R.swift?](Documentation/QandA.md#what-are-the-requirements-to-run-rswift)
- [How to use methods with a `Void` argument?](Documentation/QandA.md#how-to-use-methods-with-a-void-argument)
- [How to fix missing imports in the generated file?](Documentation/QandA.md#how-to-fix-missing-imports-in-the-generated-file)
- [How to use classes with the same name as their module?](Documentation/QandA.md#how-to-use-classes-with-the-same-name-as-their-module)
- [Can I ignore resources?](Documentation/Ignoring.md)
- [Can I use R.swift in a library?](Documentation/QandA.md#can-i-use-rswift-in-a-library)
- [How does R.swift work?](Documentation/QandA.md#how-does-rswift-work)
Expand Down
2 changes: 1 addition & 1 deletion ResourceApp/ResourceApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"$SRCROOT/rswift\" \"--import\" \"SWRevealViewController\" \"$SRCROOT\" > \"$SRCROOT/rswift.log\"";
shellScript = "\"$SRCROOT/rswift\" \"--import\" \"SomeType\" \"$SRCROOT\"";
};
DEF559A61CA487D6009B8C51 /* R.swift */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion ResourceApp/ResourceApp/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<!--Reveal View Controller-->
<scene sceneID="d0u-kX-nCz">
<objects>
<viewController storyboardIdentifier="swRevealViewController" id="uQ3-nU-KEn" customClass="SWRevealViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="swRevealViewController" id="uQ3-nU-KEn" customClass="SWRevealViewController" customModule="SWRevealViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="f16-cV-z5y"/>
<viewControllerLayoutGuide type="bottom" id="soX-IP-S1A"/>
Expand Down

0 comments on commit 67d837e

Please sign in to comment.