@@ -195,13 +195,16 @@ describe('ensureOnsidePodIOS', () => {
195195 '' ,
196196 ] . join ( '\n' ) ;
197197
198- it ( 'adds both OnsideKit and ExpoIap/Onside pods ' , ( ) => {
198+ it ( 'adds OnsideKit pod and post_install hook ' , ( ) => {
199199 const result = ensureOnsidePodIOS ( basePodfile ) ;
200200 expect ( result ) . toContain ( "pod 'OnsideKit'" ) ;
201- expect ( result ) . toContain ( "pod 'ExpoIap/Onside'" ) ;
201+ expect ( result ) . toContain ( '# [expo-iap] Make OnsideKit visible' ) ;
202+ expect ( result ) . toContain ( 'post_install do |installer|' ) ;
203+ expect ( result ) . toContain ( "target.name == 'ExpoIap'" ) ;
204+ expect ( result ) . toContain ( 'SWIFT_INCLUDE_PATHS' ) ;
202205 } ) ;
203206
204- it ( 'inserts pods inside the target block' , ( ) => {
207+ it ( 'inserts OnsideKit pod inside the target block' , ( ) => {
205208 const result = ensureOnsidePodIOS ( basePodfile ) ;
206209 const targetIndex = result . indexOf ( "target 'MyApp' do" ) ;
207210 const onsideKitIndex = result . indexOf ( "pod 'OnsideKit'" ) ;
@@ -210,38 +213,51 @@ describe('ensureOnsidePodIOS', () => {
210213 expect ( onsideKitIndex ) . toBeLessThan ( endIndex ) ;
211214 } ) ;
212215
213- it ( 'skips if both pods already exist ' , ( ) => {
214- const podfileWithBoth = [
216+ it ( 'appends into existing post_install block ' , ( ) => {
217+ const podfileWithPostInstall = [
215218 "target 'MyApp' do" ,
216- " pod 'OnsideKit', :podspec => 'https://example.com'" ,
217- " pod 'ExpoIap/Onside', :path => '../node_modules/expo-iap/ios'" ,
219+ " pod 'ExpoModulesCore'" ,
220+ 'end' ,
221+ '' ,
222+ 'post_install do |installer|' ,
223+ ' # existing hook' ,
218224 'end' ,
219225 ] . join ( '\n' ) ;
220- const result = ensureOnsidePodIOS ( podfileWithBoth ) ;
221- expect ( result ) . toBe ( podfileWithBoth ) ;
226+ const result = ensureOnsidePodIOS ( podfileWithPostInstall ) ;
227+ expect ( result ) . toContain ( "pod 'OnsideKit'" ) ;
228+ expect ( result ) . toContain ( '# [expo-iap] Make OnsideKit visible' ) ;
229+ // Should not create a second post_install block
230+ const postInstallCount = (
231+ result . match ( / p o s t _ i n s t a l l d o \| i n s t a l l e r \| / g) ?? [ ]
232+ ) . length ;
233+ expect ( postInstallCount ) . toBe ( 1 ) ;
222234 } ) ;
223235
224- it ( 'adds missing ExpoIap/Onside when OnsideKit already exists ' , ( ) => {
225- const podfileWithOnsideKit = [
236+ it ( 'skips if OnsideKit and post_install hook already exist ' , ( ) => {
237+ const podfileComplete = [
226238 "target 'MyApp' do" ,
227239 " pod 'OnsideKit', :podspec => 'https://example.com'" ,
228240 'end' ,
241+ '' ,
242+ 'post_install do |installer|' ,
243+ ' # [expo-iap] Make OnsideKit visible' ,
244+ 'end' ,
229245 ] . join ( '\n' ) ;
230- const result = ensureOnsidePodIOS ( podfileWithOnsideKit ) ;
231- expect ( result ) . toContain ( "pod 'ExpoIap/Onside'" ) ;
232- expect ( result ) . not . toContain ( 'raw.githubusercontent' ) ;
246+ const result = ensureOnsidePodIOS ( podfileComplete ) ;
247+ expect ( result ) . toBe ( podfileComplete ) ;
233248 } ) ;
234249
235- it ( 'adds missing OnsideKit when ExpoIap/Onside already exists' , ( ) => {
236- const podfileWithSubspec = [
250+ it ( 'adds post_install hook when OnsideKit already exists' , ( ) => {
251+ const podfileWithOnsideKit = [
237252 "target 'MyApp' do" ,
238- " pod 'ExpoIap/Onside ', :path => '../node_modules/expo-iap/ios '" ,
253+ " pod 'OnsideKit ', :podspec => 'https://example.com '" ,
239254 'end' ,
240255 ] . join ( '\n' ) ;
241- const result = ensureOnsidePodIOS ( podfileWithSubspec ) ;
242- expect ( result ) . toContain ( "pod 'OnsideKit'" ) ;
243- const subspecCount = ( result . match ( / p o d ' E x p o I a p \/ O n s i d e ' / g) ?? [ ] ) . length ;
244- expect ( subspecCount ) . toBe ( 1 ) ;
256+ const result = ensureOnsidePodIOS ( podfileWithOnsideKit ) ;
257+ expect ( result ) . toContain ( '# [expo-iap] Make OnsideKit visible' ) ;
258+ // Should not add a duplicate OnsideKit pod
259+ const onsideKitCount = ( result . match ( / p o d ' O n s i d e K i t ' / g) ?? [ ] ) . length ;
260+ expect ( onsideKitCount ) . toBe ( 1 ) ;
245261 } ) ;
246262
247263 it ( 'returns unchanged content when no target block found' , ( ) => {
@@ -260,7 +276,7 @@ describe('ensureOnsidePodIOS', () => {
260276
261277 expect ( content ) . toBe ( basePodfile ) ;
262278 expect ( content ) . not . toContain ( "pod 'OnsideKit'" ) ;
263- expect ( content ) . not . toContain ( "pod 'ExpoIap/Onside'" ) ;
279+ expect ( content ) . not . toContain ( '# [expo-iap] Make OnsideKit visible' ) ;
264280 } ) ;
265281
266282 it ( 'modifies Podfile when onside is enabled' , ( ) => {
@@ -273,6 +289,6 @@ describe('ensureOnsidePodIOS', () => {
273289
274290 expect ( content ) . not . toBe ( basePodfile ) ;
275291 expect ( content ) . toContain ( "pod 'OnsideKit'" ) ;
276- expect ( content ) . toContain ( "pod 'ExpoIap/Onside'" ) ;
292+ expect ( content ) . toContain ( '# [expo-iap] Make OnsideKit visible' ) ;
277293 } ) ;
278294} ) ;
0 commit comments