@@ -300,6 +300,76 @@ export default async function generateExampleApp({
300300 }
301301 }
302302
303+ // nitro modules on xcode 16.2 requires ios 16 version because of the bug https://github.com/swiftlang/swift/issues/77909
304+ // full thread in https://github.com/mrousavy/nitro/issues/422
305+ if (
306+ config . project . viewConfig === 'nitro-view' ||
307+ config . project . moduleConfig === 'nitro-modules'
308+ ) {
309+ const newTargetVersion = 16.0 ;
310+
311+ const podfile = await fs . readFile (
312+ path . join ( directory , 'ios' , 'Podfile' ) ,
313+ 'utf8'
314+ ) ;
315+
316+ const postInstallLine = 'post_install do |installer|' ;
317+ // set pods deployement min version
318+ const podVersionOverride = `
319+ installer.pods_project.targets.each do |target|
320+ target.build_configurations.each do |config|
321+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '${ newTargetVersion } '
322+ end
323+ end
324+ ` ;
325+
326+ const insertionIndex = podfile . indexOf ( postInstallLine ) ;
327+
328+ if ( insertionIndex !== - 1 ) {
329+ const endOfMarkerLineIndex = podfile . indexOf ( '\n' , insertionIndex ) ;
330+
331+ if ( endOfMarkerLineIndex !== - 1 ) {
332+ const updatedPodfileContent =
333+ podfile . slice ( 0 , endOfMarkerLineIndex ) +
334+ podVersionOverride +
335+ podfile . slice ( endOfMarkerLineIndex ) ;
336+
337+ await fs . writeFile (
338+ path . join ( directory , 'ios' , 'Podfile' ) ,
339+ updatedPodfileContent
340+ ) ;
341+ }
342+ }
343+
344+ // set project deployement min version
345+ const project = await fs . readFile (
346+ path . join (
347+ directory ,
348+ `ios/${ config . project . name } Example.xcodeproj` ,
349+ 'project.pbxproj'
350+ ) ,
351+ 'utf8'
352+ ) ;
353+
354+ // match whole IPHONEOS_DEPLOYMENT_TARGET line
355+ const deployementLineRegex =
356+ / ^ ( \s * ) I P H O N E O S _ D E P L O Y M E N T _ T A R G E T \s * = \s * [ ^ ; ] + ; $ / gm;
357+ const replacementPattern = `$1IPHONEOS_DEPLOYMENT_TARGET = ${ newTargetVersion } ;` ;
358+ const updatedContent = project . replace (
359+ deployementLineRegex ,
360+ replacementPattern
361+ ) ;
362+
363+ await fs . writeFile (
364+ path . join (
365+ directory ,
366+ `ios/${ config . project . name } Example.xcodeproj` ,
367+ 'project.pbxproj'
368+ ) ,
369+ updatedContent
370+ ) ;
371+ }
372+
303373 await fs . writeFile (
304374 path . join ( directory , 'android' , 'gradle.properties' ) ,
305375 gradleProperties
0 commit comments