danger-localizationlinter 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +12 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +167 -0
- data/Guardfile +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +25 -0
- data/danger-localizationlinter.gemspec +60 -0
- data/ext/localizationlinter/helper/validate_wording_cli.rb +21 -0
- data/ext/localizationlinter/localizationlinter.rb +331 -0
- data/ext/localizationlinter/swiftgen_localizables_check.stencil +36 -0
- data/lib/danger_localizationlinter.rb +3 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/localizationlinter/gem_version.rb +5 -0
- data/lib/localizationlinter/plugin.rb +96 -0
- data/spec/Test/Podfile +6 -0
- data/spec/Test/Podfile.lock +16 -0
- data/spec/Test/Pods/SwiftGen/CHANGELOG.md +1357 -0
- data/spec/Test/Pods/SwiftGen/LICENCE +21 -0
- data/spec/Test/Pods/SwiftGen/README.md +892 -0
- data/spec/Test/Pods/SwiftGen/bin/swiftgen +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Commander +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/A/Commander +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/Current/Commander +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Commander.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Kanna +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/A/Kanna +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/Current/Kanna +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Kanna.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/PathKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/A/PathKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/Current/PathKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/PathKit.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Stencil +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/A/Stencil +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/Current/Stencil +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Stencil.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/StencilSwiftKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/A/StencilSwiftKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/Current/StencilSwiftKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/StencilSwiftKit.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/SwiftGenKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/A/SwiftGenKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/Current/SwiftGenKit +0 -0
- data/spec/Test/Pods/SwiftGen/lib/SwiftGenKit.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/A/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/A/Yams +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/A/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/Current/Resources/Info.plist +48 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/Current/Yams +0 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Versions/Current/_CodeSignature/CodeResources +132 -0
- data/spec/Test/Pods/SwiftGen/lib/Yams.framework/Yams +0 -0
- data/spec/Test/Pods/SwiftGen/templates/colors/literals-swift4.stencil +43 -0
- data/spec/Test/Pods/SwiftGen/templates/colors/literals-swift5.stencil +43 -0
- data/spec/Test/Pods/SwiftGen/templates/colors/swift4.stencil +84 -0
- data/spec/Test/Pods/SwiftGen/templates/colors/swift5.stencil +84 -0
- data/spec/Test/Pods/SwiftGen/templates/coredata/swift4.stencil +211 -0
- data/spec/Test/Pods/SwiftGen/templates/coredata/swift5.stencil +211 -0
- data/spec/Test/Pods/SwiftGen/templates/fonts/swift4.stencil +110 -0
- data/spec/Test/Pods/SwiftGen/templates/fonts/swift5.stencil +113 -0
- data/spec/Test/Pods/SwiftGen/templates/ib/scenes-swift4.stencil +157 -0
- data/spec/Test/Pods/SwiftGen/templates/ib/scenes-swift5.stencil +159 -0
- data/spec/Test/Pods/SwiftGen/templates/ib/segues-swift4.stencil +60 -0
- data/spec/Test/Pods/SwiftGen/templates/ib/segues-swift5.stencil +60 -0
- data/spec/Test/Pods/SwiftGen/templates/json/inline-swift4.stencil +82 -0
- data/spec/Test/Pods/SwiftGen/templates/json/inline-swift5.stencil +82 -0
- data/spec/Test/Pods/SwiftGen/templates/json/runtime-swift4.stencil +112 -0
- data/spec/Test/Pods/SwiftGen/templates/json/runtime-swift5.stencil +112 -0
- data/spec/Test/Pods/SwiftGen/templates/plist/inline-swift4.stencil +82 -0
- data/spec/Test/Pods/SwiftGen/templates/plist/inline-swift5.stencil +82 -0
- data/spec/Test/Pods/SwiftGen/templates/plist/runtime-swift4.stencil +117 -0
- data/spec/Test/Pods/SwiftGen/templates/plist/runtime-swift5.stencil +117 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/flat-swift4.stencil +97 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/flat-swift5.stencil +97 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/objc-h.stencil +66 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/objc-m.stencil +90 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/structured-swift4.stencil +102 -0
- data/spec/Test/Pods/SwiftGen/templates/strings/structured-swift5.stencil +102 -0
- data/spec/Test/Pods/SwiftGen/templates/xcassets/swift4.stencil +266 -0
- data/spec/Test/Pods/SwiftGen/templates/xcassets/swift5.stencil +274 -0
- data/spec/Test/Pods/SwiftGen/templates/yaml/inline-swift4.stencil +92 -0
- data/spec/Test/Pods/SwiftGen/templates/yaml/inline-swift5.stencil +92 -0
- data/spec/Test/Test.xcodeproj/project.pbxproj +406 -0
- data/spec/Test/Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/spec/Test/Test.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/spec/Test/Test.xcworkspace/contents.xcworkspacedata +10 -0
- data/spec/Test/Test.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/spec/Test/Test/AppDelegate.swift +36 -0
- data/spec/Test/Test/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- data/spec/Test/Test/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- data/spec/Test/Test/Assets.xcassets/Contents.json +6 -0
- data/spec/Test/Test/ContentView.swift +21 -0
- data/spec/Test/Test/Info.plist +62 -0
- data/spec/Test/Test/SceneDelegate.swift +63 -0
- data/spec/Test/Test/all_target_main_language.yml +1 -0
- data/spec/Test/Test/en.lproj/LaunchScreen.storyboard +25 -0
- data/spec/Test/Test/en.lproj/localizable.strings +3 -0
- data/spec/Test/Test/fr.lproj/LaunchScreen.storyboard +25 -0
- data/spec/Test/Test/fr.lproj/localizable.strings +3 -0
- data/spec/localizationofficer_spec.rb +116 -0
- data/spec/spec_helper.rb +67 -0
- data/spec/support/fixtures/all_target_main_language.yml +1 -0
- data/spec/support/fixtures/resources/TEST/en.lproj/Localizable.strings +8 -0
- data/spec/support/fixtures/resources/TEST/en.lproj/Localizable.stringsdict +30 -0
- data/spec/support/fixtures/resources/TEST_KO/en.lproj/Localizable.strings +11 -0
- data/spec/support/fixtures/resources/TEST_KO/en.lproj/Localizable.stringsdict +30 -0
- data/spec/support/fixtures/resources/TEST_KO/fr.lproj/Localizable.strings +11 -0
- data/spec/support/fixtures/resources/TEST_KO/fr.lproj/Localizable.stringsdict +30 -0
- metadata +491 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// swiftlint:disable all
|
|
2
|
+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
|
3
|
+
|
|
4
|
+
{% if families %}
|
|
5
|
+
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
|
|
6
|
+
{% set fontType %}{{param.fontTypeName|default:"FontConvertible"}}{% endset %}
|
|
7
|
+
#if os(OSX)
|
|
8
|
+
import AppKit.NSFont
|
|
9
|
+
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
10
|
+
import UIKit.UIFont
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
// Deprecated typealiases
|
|
14
|
+
@available(*, deprecated, renamed: "{{fontType}}.Font", message: "This typealias will be removed in SwiftGen 7.0")
|
|
15
|
+
{{accessModifier}} typealias {{param.fontAliasName|default:"Font"}} = {{fontType}}.Font
|
|
16
|
+
|
|
17
|
+
// swiftlint:disable superfluous_disable_command
|
|
18
|
+
// swiftlint:disable file_length
|
|
19
|
+
// swiftlint:disable implicit_return
|
|
20
|
+
|
|
21
|
+
// MARK: - Fonts
|
|
22
|
+
|
|
23
|
+
// swiftlint:disable identifier_name line_length type_body_length
|
|
24
|
+
{% macro transformPath path %}{% filter removeNewlines %}
|
|
25
|
+
{% if param.preservePath %}
|
|
26
|
+
{{path}}
|
|
27
|
+
{% else %}
|
|
28
|
+
{{path|basename}}
|
|
29
|
+
{% endif %}
|
|
30
|
+
{% endfilter %}{% endmacro %}
|
|
31
|
+
{{accessModifier}} enum {{param.enumName|default:"FontFamily"}} {
|
|
32
|
+
{% for family in families %}
|
|
33
|
+
{{accessModifier}} enum {{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
|
|
34
|
+
{% for font in family.fonts %}
|
|
35
|
+
{{accessModifier}} static let {{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{fontType}}(name: "{{font.name}}", family: "{{family.name}}", path: "{% call transformPath font.path %}")
|
|
36
|
+
{% endfor %}
|
|
37
|
+
{{accessModifier}} static let all: [{{fontType}}] = [{% for font in family.fonts %}{{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{{ ", " if not forloop.last }}{% endfor %}]
|
|
38
|
+
}
|
|
39
|
+
{% endfor %}
|
|
40
|
+
{{accessModifier}} static let allCustomFonts: [{{fontType}}] = [{% for family in families %}{{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.all{{ ", " if not forloop.last }}{% endfor %}].flatMap { $0 }
|
|
41
|
+
{{accessModifier}} static func registerAllCustomFonts() {
|
|
42
|
+
allCustomFonts.forEach { $0.register() }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// swiftlint:enable identifier_name line_length type_body_length
|
|
46
|
+
|
|
47
|
+
// MARK: - Implementation Details
|
|
48
|
+
|
|
49
|
+
{{accessModifier}} struct {{fontType}} {
|
|
50
|
+
{{accessModifier}} let name: String
|
|
51
|
+
{{accessModifier}} let family: String
|
|
52
|
+
{{accessModifier}} let path: String
|
|
53
|
+
|
|
54
|
+
#if os(OSX)
|
|
55
|
+
{{accessModifier}} typealias Font = NSFont
|
|
56
|
+
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
57
|
+
{{accessModifier}} typealias Font = UIFont
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
{{accessModifier}} func font(size: CGFloat) -> Font! {
|
|
61
|
+
return Font(font: self, size: size)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
{{accessModifier}} func register() {
|
|
65
|
+
// swiftlint:disable:next conditional_returns_on_newline
|
|
66
|
+
guard let url = url else { return }
|
|
67
|
+
CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fileprivate var url: URL? {
|
|
71
|
+
{% if param.lookupFunction %}
|
|
72
|
+
return {{param.lookupFunction}}(name, family, path)
|
|
73
|
+
{% else %}
|
|
74
|
+
return {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil)
|
|
75
|
+
{% endif %}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{{accessModifier}} extension {{fontType}}.Font {
|
|
80
|
+
convenience init?(font: {{fontType}}, size: CGFloat) {
|
|
81
|
+
#if os(iOS) || os(tvOS) || os(watchOS)
|
|
82
|
+
if !UIFont.fontNames(forFamilyName: font.family).contains(font.name) {
|
|
83
|
+
font.register()
|
|
84
|
+
}
|
|
85
|
+
#elseif os(OSX)
|
|
86
|
+
if let url = font.url, CTFontManagerGetScopeForURL(url as CFURL) == .none {
|
|
87
|
+
font.register()
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
self.init(name: font.name, size: size)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
{% if not param.bundle and not param.lookupFunction %}
|
|
95
|
+
|
|
96
|
+
// swiftlint:disable convenience_type
|
|
97
|
+
private final class BundleToken {
|
|
98
|
+
static let bundle: Bundle = {
|
|
99
|
+
#if SWIFT_PACKAGE
|
|
100
|
+
return Bundle.module
|
|
101
|
+
#else
|
|
102
|
+
return Bundle(for: BundleToken.self)
|
|
103
|
+
#endif
|
|
104
|
+
}()
|
|
105
|
+
}
|
|
106
|
+
// swiftlint:enable convenience_type
|
|
107
|
+
{% endif %}
|
|
108
|
+
{% else %}
|
|
109
|
+
// No fonts found
|
|
110
|
+
{% endif %}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// swiftlint:disable all
|
|
2
|
+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
|
3
|
+
|
|
4
|
+
{% if families %}
|
|
5
|
+
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
|
|
6
|
+
{% set fontType %}{{param.fontTypeName|default:"FontConvertible"}}{% endset %}
|
|
7
|
+
#if os(OSX)
|
|
8
|
+
import AppKit.NSFont
|
|
9
|
+
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
10
|
+
import UIKit.UIFont
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
// Deprecated typealiases
|
|
14
|
+
@available(*, deprecated, renamed: "{{fontType}}.Font", message: "This typealias will be removed in SwiftGen 7.0")
|
|
15
|
+
{{accessModifier}} typealias {{param.fontAliasName|default:"Font"}} = {{fontType}}.Font
|
|
16
|
+
|
|
17
|
+
// swiftlint:disable superfluous_disable_command
|
|
18
|
+
// swiftlint:disable file_length
|
|
19
|
+
|
|
20
|
+
// MARK: - Fonts
|
|
21
|
+
|
|
22
|
+
// swiftlint:disable identifier_name line_length type_body_length
|
|
23
|
+
{% macro transformPath path %}{% filter removeNewlines %}
|
|
24
|
+
{% if param.preservePath %}
|
|
25
|
+
{{path}}
|
|
26
|
+
{% else %}
|
|
27
|
+
{{path|basename}}
|
|
28
|
+
{% endif %}
|
|
29
|
+
{% endfilter %}{% endmacro %}
|
|
30
|
+
{{accessModifier}} enum {{param.enumName|default:"FontFamily"}} {
|
|
31
|
+
{% for family in families %}
|
|
32
|
+
{{accessModifier}} enum {{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}} {
|
|
33
|
+
{% for font in family.fonts %}
|
|
34
|
+
{{accessModifier}} static let {{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}} = {{fontType}}(name: "{{font.name}}", family: "{{family.name}}", path: "{% call transformPath font.path %}")
|
|
35
|
+
{% endfor %}
|
|
36
|
+
{{accessModifier}} static let all: [{{fontType}}] = [{% for font in family.fonts %}{{font.style|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{{ ", " if not forloop.last }}{% endfor %}]
|
|
37
|
+
}
|
|
38
|
+
{% endfor %}
|
|
39
|
+
{{accessModifier}} static let allCustomFonts: [{{fontType}}] = [{% for family in families %}{{family.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}.all{{ ", " if not forloop.last }}{% endfor %}].flatMap { $0 }
|
|
40
|
+
{{accessModifier}} static func registerAllCustomFonts() {
|
|
41
|
+
allCustomFonts.forEach { $0.register() }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// swiftlint:enable identifier_name line_length type_body_length
|
|
45
|
+
|
|
46
|
+
// MARK: - Implementation Details
|
|
47
|
+
|
|
48
|
+
{{accessModifier}} struct {{fontType}} {
|
|
49
|
+
{{accessModifier}} let name: String
|
|
50
|
+
{{accessModifier}} let family: String
|
|
51
|
+
{{accessModifier}} let path: String
|
|
52
|
+
|
|
53
|
+
#if os(OSX)
|
|
54
|
+
{{accessModifier}} typealias Font = NSFont
|
|
55
|
+
#elseif os(iOS) || os(tvOS) || os(watchOS)
|
|
56
|
+
{{accessModifier}} typealias Font = UIFont
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
{{accessModifier}} func font(size: CGFloat) -> Font {
|
|
60
|
+
guard let font = Font(font: self, size: size) else {
|
|
61
|
+
fatalError("Unable to initialize font '\(name)' (\(family))")
|
|
62
|
+
}
|
|
63
|
+
return font
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
{{accessModifier}} func register() {
|
|
67
|
+
// swiftlint:disable:next conditional_returns_on_newline
|
|
68
|
+
guard let url = url else { return }
|
|
69
|
+
CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fileprivate var url: URL? {
|
|
73
|
+
// swiftlint:disable:next implicit_return
|
|
74
|
+
{% if param.lookupFunction %}
|
|
75
|
+
return {{param.lookupFunction}}(name, family, path)
|
|
76
|
+
{% else %}
|
|
77
|
+
return {{param.bundle|default:"BundleToken.bundle"}}.url(forResource: path, withExtension: nil)
|
|
78
|
+
{% endif %}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
{{accessModifier}} extension {{fontType}}.Font {
|
|
83
|
+
convenience init?(font: {{fontType}}, size: CGFloat) {
|
|
84
|
+
#if os(iOS) || os(tvOS) || os(watchOS)
|
|
85
|
+
if !UIFont.fontNames(forFamilyName: font.family).contains(font.name) {
|
|
86
|
+
font.register()
|
|
87
|
+
}
|
|
88
|
+
#elseif os(OSX)
|
|
89
|
+
if let url = font.url, CTFontManagerGetScopeForURL(url as CFURL) == .none {
|
|
90
|
+
font.register()
|
|
91
|
+
}
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
self.init(name: font.name, size: size)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
{% if not param.bundle and not param.lookupFunction %}
|
|
98
|
+
|
|
99
|
+
// swiftlint:disable convenience_type
|
|
100
|
+
private final class BundleToken {
|
|
101
|
+
static let bundle: Bundle = {
|
|
102
|
+
#if SWIFT_PACKAGE
|
|
103
|
+
return Bundle.module
|
|
104
|
+
#else
|
|
105
|
+
return Bundle(for: BundleToken.self)
|
|
106
|
+
#endif
|
|
107
|
+
}()
|
|
108
|
+
}
|
|
109
|
+
// swiftlint:enable convenience_type
|
|
110
|
+
{% endif %}
|
|
111
|
+
{% else %}
|
|
112
|
+
// No fonts found
|
|
113
|
+
{% endif %}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// swiftlint:disable all
|
|
2
|
+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
|
3
|
+
|
|
4
|
+
{% if platform and storyboards %}
|
|
5
|
+
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
|
|
6
|
+
{% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
|
|
7
|
+
{% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
|
|
8
|
+
{% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
|
|
9
|
+
// swiftlint:disable sorted_imports
|
|
10
|
+
import Foundation
|
|
11
|
+
{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
|
|
12
|
+
import {{module}}
|
|
13
|
+
{% endfor %}
|
|
14
|
+
|
|
15
|
+
// swiftlint:disable superfluous_disable_command
|
|
16
|
+
// swiftlint:disable file_length implicit_return
|
|
17
|
+
|
|
18
|
+
// MARK: - Storyboard Scenes
|
|
19
|
+
|
|
20
|
+
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
|
|
21
|
+
{% macro moduleName item %}{% filter removeNewlines %}
|
|
22
|
+
{% if item.moduleIsPlaceholder %}
|
|
23
|
+
{{ env.PRODUCT_MODULE_NAME|default:param.module }}
|
|
24
|
+
{% else %}
|
|
25
|
+
{{ item.module }}
|
|
26
|
+
{% endif %}
|
|
27
|
+
{% endfilter %}{% endmacro %}
|
|
28
|
+
{% macro className item %}{% filter removeNewlines %}
|
|
29
|
+
{% set module %}{% call moduleName item %}{% endset %}
|
|
30
|
+
{% if module and ( not param.ignoreTargetModule or module != env.PRODUCT_MODULE_NAME and module != param.module ) %}
|
|
31
|
+
{{module}}.
|
|
32
|
+
{% endif %}
|
|
33
|
+
{{item.type}}
|
|
34
|
+
{% endfilter %}{% endmacro %}
|
|
35
|
+
{{accessModifier}} enum {{param.enumName|default:"StoryboardScene"}} {
|
|
36
|
+
{% for storyboard in storyboards %}
|
|
37
|
+
{% set storyboardName %}{{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}{% endset %}
|
|
38
|
+
{{accessModifier}} enum {{storyboardName}}: StoryboardType {
|
|
39
|
+
{{accessModifier}} static let storyboardName = "{{storyboard.name}}"
|
|
40
|
+
{% if storyboard.initialScene %}
|
|
41
|
+
|
|
42
|
+
{% set sceneClass %}{% call className storyboard.initialScene %}{% endset %}
|
|
43
|
+
{{accessModifier}} static let initialScene = InitialSceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self)
|
|
44
|
+
{% endif %}
|
|
45
|
+
{% for scene in storyboard.scenes %}
|
|
46
|
+
|
|
47
|
+
{% set sceneID %}{{scene.identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset %}
|
|
48
|
+
{% set sceneClass %}{% call className scene %}{% endset %}
|
|
49
|
+
{{accessModifier}} static let {{sceneID}} = SceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self, identifier: "{{scene.identifier}}")
|
|
50
|
+
{% endfor %}
|
|
51
|
+
}
|
|
52
|
+
{% endfor %}
|
|
53
|
+
}
|
|
54
|
+
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
|
|
55
|
+
|
|
56
|
+
// MARK: - Implementation Details
|
|
57
|
+
|
|
58
|
+
{{accessModifier}} protocol StoryboardType {
|
|
59
|
+
static var storyboardName: String { get }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
{{accessModifier}} extension StoryboardType {
|
|
63
|
+
static var storyboard: {{prefix}}Storyboard {
|
|
64
|
+
let name = {% if isAppKit %}NSStoryboard.Name({% endif %}self.storyboardName{% if isAppKit %}){% endif %}
|
|
65
|
+
{% if param.lookupFunction %}
|
|
66
|
+
return {{param.lookupFunction}}(name)
|
|
67
|
+
{% else %}
|
|
68
|
+
return {{prefix}}Storyboard(name: name, bundle: {{param.bundle|default:"BundleToken.bundle"}})
|
|
69
|
+
{% endif %}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
{{accessModifier}} struct SceneType<T{% if not isAppKit %}: UIViewController{% endif %}> {
|
|
74
|
+
{{accessModifier}} let storyboard: StoryboardType.Type
|
|
75
|
+
{{accessModifier}} let identifier: String
|
|
76
|
+
|
|
77
|
+
{{accessModifier}} func instantiate() -> T {
|
|
78
|
+
let identifier = {% if isAppKit %}NSStoryboard.SceneIdentifier({% endif %}self.identifier{% if isAppKit %}){% endif %}
|
|
79
|
+
guard let controller = storyboard.storyboard.instantiate{{controller}}(withIdentifier: identifier) as? T else {
|
|
80
|
+
fatalError("{{controller}} '\(identifier)' is not of the expected class \(T.self).")
|
|
81
|
+
}
|
|
82
|
+
return controller
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
{% if isAppKit %}
|
|
86
|
+
@available(macOS 10.15, *)
|
|
87
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
|
|
88
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@available(macOS 10.15, *)
|
|
92
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
|
|
93
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
94
|
+
}
|
|
95
|
+
{% else %}
|
|
96
|
+
@available(iOS 13.0, tvOS 13.0, *)
|
|
97
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
|
|
98
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
99
|
+
}
|
|
100
|
+
{% endif %}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
{{accessModifier}} struct InitialSceneType<T{% if not isAppKit %}: UIViewController{% endif %}> {
|
|
104
|
+
{{accessModifier}} let storyboard: StoryboardType.Type
|
|
105
|
+
|
|
106
|
+
{{accessModifier}} func instantiate() -> T {
|
|
107
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}() as? T else {
|
|
108
|
+
fatalError("{{controller}} is not of the expected class \(T.self).")
|
|
109
|
+
}
|
|
110
|
+
return controller
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
{% if isAppKit %}
|
|
114
|
+
@available(macOS 10.15, *)
|
|
115
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
|
|
116
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
117
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
118
|
+
}
|
|
119
|
+
return controller
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@available(macOS 10.15, *)
|
|
123
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
|
|
124
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
125
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
126
|
+
}
|
|
127
|
+
return controller
|
|
128
|
+
}
|
|
129
|
+
{% else %}
|
|
130
|
+
@available(iOS 13.0, tvOS 13.0, *)
|
|
131
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
|
|
132
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
133
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
134
|
+
}
|
|
135
|
+
return controller
|
|
136
|
+
}
|
|
137
|
+
{% endif %}
|
|
138
|
+
}
|
|
139
|
+
{% if not param.bundle and not param.lookupFunction %}
|
|
140
|
+
|
|
141
|
+
// swiftlint:disable convenience_type
|
|
142
|
+
private final class BundleToken {
|
|
143
|
+
static let bundle: Bundle = {
|
|
144
|
+
#if SWIFT_PACKAGE
|
|
145
|
+
return Bundle.module
|
|
146
|
+
#else
|
|
147
|
+
return Bundle(for: BundleToken.self)
|
|
148
|
+
#endif
|
|
149
|
+
}()
|
|
150
|
+
}
|
|
151
|
+
// swiftlint:enable convenience_type
|
|
152
|
+
{% endif %}
|
|
153
|
+
{% elif storyboards %}
|
|
154
|
+
// Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
|
|
155
|
+
{% else %}
|
|
156
|
+
// No storyboard found
|
|
157
|
+
{% endif %}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// swiftlint:disable all
|
|
2
|
+
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
|
|
3
|
+
|
|
4
|
+
{% if platform and storyboards %}
|
|
5
|
+
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
|
|
6
|
+
{% set isAppKit %}{% if platform == "macOS" %}true{% endif %}{% endset %}
|
|
7
|
+
{% set prefix %}{% if isAppKit %}NS{% else %}UI{% endif %}{% endset %}
|
|
8
|
+
{% set controller %}{% if isAppKit %}Controller{% else %}ViewController{% endif %}{% endset %}
|
|
9
|
+
// swiftlint:disable sorted_imports
|
|
10
|
+
import Foundation
|
|
11
|
+
{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %}
|
|
12
|
+
import {{module}}
|
|
13
|
+
{% endfor %}
|
|
14
|
+
|
|
15
|
+
// swiftlint:disable superfluous_disable_command
|
|
16
|
+
// swiftlint:disable file_length implicit_return
|
|
17
|
+
|
|
18
|
+
// MARK: - Storyboard Scenes
|
|
19
|
+
|
|
20
|
+
// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name
|
|
21
|
+
{% macro moduleName item %}{% filter removeNewlines %}
|
|
22
|
+
{% if item.moduleIsPlaceholder %}
|
|
23
|
+
{{ env.PRODUCT_MODULE_NAME|default:param.module }}
|
|
24
|
+
{% else %}
|
|
25
|
+
{{ item.module }}
|
|
26
|
+
{% endif %}
|
|
27
|
+
{% endfilter %}{% endmacro %}
|
|
28
|
+
{% macro className item %}{% filter removeNewlines %}
|
|
29
|
+
{% set module %}{% call moduleName item %}{% endset %}
|
|
30
|
+
{% if module and ( not param.ignoreTargetModule or module != env.PRODUCT_MODULE_NAME and module != param.module ) %}
|
|
31
|
+
{{module}}.
|
|
32
|
+
{% endif %}
|
|
33
|
+
{{item.type}}
|
|
34
|
+
{% endfilter %}{% endmacro %}
|
|
35
|
+
{{accessModifier}} enum {{param.enumName|default:"StoryboardScene"}} {
|
|
36
|
+
{% for storyboard in storyboards %}
|
|
37
|
+
{% set storyboardName %}{{storyboard.name|swiftIdentifier:"pretty"|escapeReservedKeywords}}{% endset %}
|
|
38
|
+
{{accessModifier}} enum {{storyboardName}}: StoryboardType {
|
|
39
|
+
{{accessModifier}} static let storyboardName = "{{storyboard.name}}"
|
|
40
|
+
{% if storyboard.initialScene %}
|
|
41
|
+
|
|
42
|
+
{% set sceneClass %}{% call className storyboard.initialScene %}{% endset %}
|
|
43
|
+
{{accessModifier}} static let initialScene = InitialSceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self)
|
|
44
|
+
{% endif %}
|
|
45
|
+
{% for scene in storyboard.scenes %}
|
|
46
|
+
|
|
47
|
+
{% set sceneID %}{{scene.identifier|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset %}
|
|
48
|
+
{% set sceneClass %}{% call className scene %}{% endset %}
|
|
49
|
+
{{accessModifier}} static let {{sceneID}} = SceneType<{{sceneClass}}>(storyboard: {{storyboardName}}.self, identifier: "{{scene.identifier}}")
|
|
50
|
+
{% endfor %}
|
|
51
|
+
}
|
|
52
|
+
{% endfor %}
|
|
53
|
+
}
|
|
54
|
+
// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name
|
|
55
|
+
|
|
56
|
+
// MARK: - Implementation Details
|
|
57
|
+
|
|
58
|
+
{{accessModifier}} protocol StoryboardType {
|
|
59
|
+
static var storyboardName: String { get }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
{{accessModifier}} extension StoryboardType {
|
|
63
|
+
static var storyboard: {{prefix}}Storyboard {
|
|
64
|
+
let name = {% if isAppKit %}NSStoryboard.Name({% endif %}self.storyboardName{% if isAppKit %}){% endif %}
|
|
65
|
+
{% if param.lookupFunction %}
|
|
66
|
+
return {{param.lookupFunction}}(name)
|
|
67
|
+
{% else %}
|
|
68
|
+
return {{prefix}}Storyboard(name: name, bundle: {{param.bundle|default:"BundleToken.bundle"}})
|
|
69
|
+
{% endif %}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
{{accessModifier}} struct SceneType<T{% if not isAppKit %}: UIViewController{% endif %}> {
|
|
74
|
+
{{accessModifier}} let storyboard: StoryboardType.Type
|
|
75
|
+
{{accessModifier}} let identifier: String
|
|
76
|
+
|
|
77
|
+
{{accessModifier}} func instantiate() -> T {
|
|
78
|
+
let identifier = {% if isAppKit %}NSStoryboard.SceneIdentifier({% endif %}self.identifier{% if isAppKit %}){% endif %}
|
|
79
|
+
guard let controller = storyboard.storyboard.instantiate{{controller}}(withIdentifier: identifier) as? T else {
|
|
80
|
+
fatalError("{{controller}} '\(identifier)' is not of the expected class \(T.self).")
|
|
81
|
+
}
|
|
82
|
+
return controller
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
{% if isAppKit %}
|
|
86
|
+
@available(macOS 10.15, *)
|
|
87
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
|
|
88
|
+
let identifier = NSStoryboard.SceneIdentifier(self.identifier)
|
|
89
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@available(macOS 10.15, *)
|
|
93
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
|
|
94
|
+
let identifier = NSStoryboard.SceneIdentifier(self.identifier)
|
|
95
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
96
|
+
}
|
|
97
|
+
{% else %}
|
|
98
|
+
@available(iOS 13.0, tvOS 13.0, *)
|
|
99
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
|
|
100
|
+
return storyboard.storyboard.instantiate{{controller}}(identifier: identifier, creator: block)
|
|
101
|
+
}
|
|
102
|
+
{% endif %}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
{{accessModifier}} struct InitialSceneType<T{% if not isAppKit %}: UIViewController{% endif %}> {
|
|
106
|
+
{{accessModifier}} let storyboard: StoryboardType.Type
|
|
107
|
+
|
|
108
|
+
{{accessModifier}} func instantiate() -> T {
|
|
109
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}() as? T else {
|
|
110
|
+
fatalError("{{controller}} is not of the expected class \(T.self).")
|
|
111
|
+
}
|
|
112
|
+
return controller
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
{% if isAppKit %}
|
|
116
|
+
@available(macOS 10.15, *)
|
|
117
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSViewController {
|
|
118
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
119
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
120
|
+
}
|
|
121
|
+
return controller
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@available(macOS 10.15, *)
|
|
125
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T where T: NSWindowController {
|
|
126
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
127
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
128
|
+
}
|
|
129
|
+
return controller
|
|
130
|
+
}
|
|
131
|
+
{% else %}
|
|
132
|
+
@available(iOS 13.0, tvOS 13.0, *)
|
|
133
|
+
{{accessModifier}} func instantiate(creator block: @escaping (NSCoder) -> T?) -> T {
|
|
134
|
+
guard let controller = storyboard.storyboard.instantiateInitial{{controller}}(creator: block) else {
|
|
135
|
+
fatalError("Storyboard \(storyboard.storyboardName) does not have an initial scene.")
|
|
136
|
+
}
|
|
137
|
+
return controller
|
|
138
|
+
}
|
|
139
|
+
{% endif %}
|
|
140
|
+
}
|
|
141
|
+
{% if not param.bundle and not param.lookupFunction %}
|
|
142
|
+
|
|
143
|
+
// swiftlint:disable convenience_type
|
|
144
|
+
private final class BundleToken {
|
|
145
|
+
static let bundle: Bundle = {
|
|
146
|
+
#if SWIFT_PACKAGE
|
|
147
|
+
return Bundle.module
|
|
148
|
+
#else
|
|
149
|
+
return Bundle(for: BundleToken.self)
|
|
150
|
+
#endif
|
|
151
|
+
}()
|
|
152
|
+
}
|
|
153
|
+
// swiftlint:enable convenience_type
|
|
154
|
+
{% endif %}
|
|
155
|
+
{% elif storyboards %}
|
|
156
|
+
// Mixed AppKit and UIKit storyboard files found, please invoke swiftgen with these separately
|
|
157
|
+
{% else %}
|
|
158
|
+
// No storyboard found
|
|
159
|
+
{% endif %}
|