@@ -35,6 +35,7 @@ public struct RswiftCore {
3535 let productModuleName : String ?
3636 let infoPlistFile : URL ?
3737 let codeSignEntitlements : URL ?
38+ let omitMainLet : Bool
3839
3940 let sourceTreeURLs : SourceTreeURLs
4041
@@ -49,6 +50,7 @@ public struct RswiftCore {
4950 productModuleName: String ? ,
5051 infoPlistFile: URL ? ,
5152 codeSignEntitlements: URL ? ,
53+ omitMainLet: Bool ,
5254 rswiftIgnoreURL: URL ,
5355 sourceTreeURLs: SourceTreeURLs
5456 ) {
@@ -60,6 +62,7 @@ public struct RswiftCore {
6062 self . productModuleName = productModuleName
6163 self . infoPlistFile = infoPlistFile
6264 self . codeSignEntitlements = codeSignEntitlements
65+ self . omitMainLet = omitMainLet
6366
6467 self . rswiftIgnoreURL = rswiftIgnoreURL
6568
@@ -295,29 +298,28 @@ public struct RswiftCore {
295298 . map { " import \( $0) " }
296299 . joined ( separator: " \n " )
297300
298- let mainLet : String
299- switch bundleSource {
300- case . module:
301+ let mainLet : String ?
302+ switch ( bundleSource, omitMainLet ) {
303+ case ( . module, false ) :
301304 mainLet = " \( accessLevel == . publicLevel ? " public " : " " ) let R = _R(bundle: Bundle.module) "
302- case . finder:
305+ case ( . finder, false ) :
303306 mainLet = """
304- private class BundleFinder {}
305- \( accessLevel == . publicLevel ? " public " : " " ) let R = _R(bundle: Bundle(for: BundleFinder.self))
306- """
307+ private class BundleFinder {}
308+ \( accessLevel == . publicLevel ? " public " : " " ) let R = _R(bundle: Bundle(for: BundleFinder.self))
309+ """
310+ default :
311+ mainLet = nil
307312 }
308313
309314 let str = s. prettyPrint ( )
315+ let body = [ imports, mainLet, str] . compactMap { $0 } . joined ( separator: " \n \n " )
310316 let code = """
311317 //
312318 // This is a generated file, do not edit!
313319 // Generated by R.swift, see https://github.com/mac-cain13/R.swift
314320 //
315321
316- \( imports)
317-
318- \( mainLet)
319-
320- \( str)
322+ \( body)
321323 """
322324
323325 try writeIfChanged ( contents: code, toURL: outputURL)
0 commit comments