@@ -77,13 +77,15 @@ struct PropertyListGenerator: ExternalOnlyStructGenerator {
7777
7878 private func propertyFromInfoString( key: String , value: String , path: [ String ] , at externalAccessLevel: AccessLevel ) -> Let {
7979
80+ let steps = path. map { " \" \( $0. escapedStringLiteral) \" " } . joined ( separator: " , " )
81+
8082 let isKey = key == " _key "
8183 let letValue : String = isKey
8284 ? " \" \( value. escapedStringLiteral) \" "
83- : " _infoDictionary?[ \ "\( key) \" ] as? String ?? \" \( value. escapedStringLiteral) \" "
85+ : " infoPlistString(path: [ \( steps ) ], key: \ "\( key. escapedStringLiteral ) \" ) ?? \" \( value. escapedStringLiteral) \" "
8486
8587 return Let (
86- comments: isKey ? [ ] : [ value ] ,
88+ comments: [ ] ,
8789 accessModifier: externalAccessLevel,
8890 isStatic: true ,
8991 name: SwiftIdentifier ( name: key) ,
@@ -99,35 +101,18 @@ struct PropertyListGenerator: ExternalOnlyStructGenerator {
99101 var ps = path
100102 ps. append ( key)
101103
102- let info = path. reduce ( " hostingBundle.infoDictionary " , { ( source, step) in
103- " ( \( source) ?[ \" \( step) \" ] as? [String: Any]) "
104- } )
105- let object = Let (
106- comments: [ ] ,
107- accessModifier: . privateLevel,
108- isStatic: true ,
109- name: " _infoDictionary " ,
110- typeDefinition: . inferred( nil ) ,
111- value: info
112- )
113-
114104 switch value {
115105 case let array as [ String ] :
116- var props = array. map { item in
117- propertyFromInfoString ( key: item, value: item, path: ps, at: externalAccessLevel)
118- }
119- if !props. isEmpty {
120- props. append ( object)
121- }
122-
123106 return Struct (
124107 availables: [ ] ,
125108 comments: [ ] ,
126109 accessModifier: externalAccessLevel,
127110 type: Type ( module: . host, name: SwiftIdentifier ( name: key) ) ,
128111 implements: [ ] ,
129112 typealiasses: [ ] ,
130- properties: props,
113+ properties: array. map { item in
114+ propertyFromInfoString ( key: item, value: item, path: ps, at: externalAccessLevel)
115+ } ,
131116 functions: [ ] ,
132117 structs: [ ] ,
133118 classes: [ ] ,
@@ -136,10 +121,6 @@ struct PropertyListGenerator: ExternalOnlyStructGenerator {
136121
137122 case var dict as [ String : Any ] :
138123 dict [ " _key " ] = key
139- var props = propertiesFromInfoPlist ( contents: dict, path: ps, at: externalAccessLevel)
140- if !props. isEmpty {
141- props. append ( object)
142- }
143124
144125 return Struct (
145126 availables: [ ] ,
@@ -148,7 +129,7 @@ struct PropertyListGenerator: ExternalOnlyStructGenerator {
148129 type: Type ( module: . host, name: SwiftIdentifier ( name: key) ) ,
149130 implements: [ ] ,
150131 typealiasses: [ ] ,
151- properties: props ,
132+ properties: propertiesFromInfoPlist ( contents : dict , path : ps , at : externalAccessLevel ) ,
152133 functions: [ ] ,
153134 structs: structsFromInfoPlist ( contents: dict, path: ps, at: externalAccessLevel) ,
154135 classes: [ ] ,
0 commit comments