@@ -21,6 +21,22 @@ function nonComments(obj) {
2121 return newObj ;
2222}
2323
24+ function librarySearchPaths ( proj ) {
25+ var configs = nonComments ( proj . pbxXCBuildConfigurationSection ( ) ) ,
26+ allPaths = [ ] ,
27+ ids = Object . keys ( configs ) , i , buildSettings ;
28+
29+ for ( i = 0 ; i < ids . length ; i ++ ) {
30+ buildSettings = configs [ ids [ i ] ] . buildSettings ;
31+
32+ if ( buildSettings [ 'LIBRARY_SEARCH_PATHS' ] ) {
33+ allPaths . push ( buildSettings [ 'LIBRARY_SEARCH_PATHS' ] ) ;
34+ }
35+ }
36+
37+ return allPaths ;
38+ }
39+
2440exports . setUp = function ( callback ) {
2541 proj . hash = cleanHash ( ) ;
2642 callback ( ) ;
@@ -134,35 +150,52 @@ exports.addStaticLibrary = {
134150 } ,
135151 'should ensure LIBRARY_SEARCH_PATHS inherits defaults correctly' : function ( test ) {
136152 var newFile = proj . addStaticLibrary ( 'libGoogleAnalytics.a' ) ,
137- configs = nonComments ( proj . pbxXCBuildConfigurationSection ( ) ) ,
138- ids = Object . keys ( configs ) , i , current , buildSettings ;
139-
140- for ( i = 0 ; i < ids . length ; i ++ ) {
141- buildSettings = configs [ ids [ i ] ] . buildSettings ;
142-
143- if ( buildSettings [ 'PRODUCT_NAME' ] == '"KitchenSinktablet"' ) {
144- current = buildSettings [ 'LIBRARY_SEARCH_PATHS' ] ;
153+ libraryPaths = librarySearchPaths ( proj ) ,
154+ expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""' ,
155+ i , current ;
145156
146- test . ok ( current . indexOf ( '"$(inherited)"' ) >= 0 )
147- }
157+ for ( i = 0 ; i < libraryPaths . length ; i ++ ) {
158+ current = libraryPaths [ i ] ;
159+ test . ok ( current . indexOf ( '"$(inherited)"' ) >= 0 ) ;
148160 }
149161
150162 test . done ( ) ;
151163 } ,
152164 'should ensure the new library is in LIBRARY_SEARCH_PATHS' : function ( test ) {
153165 var newFile = proj . addStaticLibrary ( 'libGoogleAnalytics.a' ) ,
154- configs = nonComments ( proj . pbxXCBuildConfigurationSection ( ) ) ,
166+ libraryPaths = librarySearchPaths ( proj ) ,
155167 expectedPath = '"\\"$(SRCROOT)/KitchenSinktablet\\""' ,
156- ids = Object . keys ( configs ) , i , current , buildSettings ;
168+ i , current ;
157169
158- for ( i = 0 ; i < ids . length ; i ++ ) {
159- buildSettings = configs [ ids [ i ] ] . buildSettings ;
170+ for ( i = 0 ; i < libraryPaths . length ; i ++ ) {
171+ current = libraryPaths [ i ] ;
172+ test . ok ( current . indexOf ( expectedPath ) >= 0 ) ;
173+ }
160174
161- if ( buildSettings [ 'PRODUCT_NAME' ] == '"KitchenSinktablet"' ) {
162- current = buildSettings [ 'LIBRARY_SEARCH_PATHS' ] ;
175+ test . done ( ) ;
176+ } ,
177+ 'should add to the Plugins group, optionally' : function ( test ) {
178+ var newFile = proj . addStaticLibrary ( 'libGoogleAnalytics.a' ,
179+ { plugin : true } ) ,
180+ plugins = proj . pbxGroupByName ( 'Plugins' ) ;
163181
164- test . ok ( current . indexOf ( expectedPath ) >= 0 )
165- }
182+ test . equal ( plugins . children . length , 1 ) ;
183+ test . done ( ) ;
184+ } ,
185+ 'should add the right LIBRARY_SEARCH_PATHS entry for plugins' : function ( test ) {
186+ plugins = proj . pbxGroupByName ( 'Plugins' ) ;
187+ plugins . path = '"Test200/Plugins"' ;
188+
189+ var newFile = proj . addStaticLibrary ( 'libGoogleAnalytics.a' ,
190+ { plugin : true } ) ,
191+ libraryPaths = librarySearchPaths ( proj ) ,
192+ expectedPath = '"\\"$(SRCROOT)/Test200/Plugins\\""' ,
193+ i , current ;
194+
195+ for ( i = 0 ; i < libraryPaths . length ; i ++ ) {
196+ current = libraryPaths [ i ] ;
197+ test . ok ( current . indexOf ( expectedPath ) >= 0 ,
198+ expectedPath + ' not found in ' + current ) ;
166199 }
167200
168201 test . done ( ) ;
0 commit comments