-
Notifications
You must be signed in to change notification settings - Fork 215
feat: option to add nitro views #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey @Juozas-Petkelis , remember to add the template to the CI matrix
|
0b45375
to
7799977
Compare
Super nice! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Juozas-Petkelis
Sorry for the delay in the review. Would you be able to fix the conflicts with main?
// nitro modules on xcode 16.2 requires ios 16 version because of the bug https://github.com/swiftlang/swift/issues/77909 | ||
// full thread in https://github.com/mrousavy/nitro/issues/422 | ||
if ( | ||
config.project.viewConfig === 'nitro-view' || | ||
config.project.moduleConfig === 'nitro-modules' | ||
) { | ||
const newTargetVersion = 16.0; | ||
|
||
const podfile = await fs.readFile( | ||
path.join(directory, 'ios', 'Podfile'), | ||
'utf8' | ||
); | ||
|
||
const postInstallLine = 'post_install do |installer|'; | ||
// set pods deployement min version | ||
const podVersionOverride = ` | ||
installer.pods_project.targets.each do |target| | ||
target.build_configurations.each do |config| | ||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '${newTargetVersion}' | ||
end | ||
end | ||
`; | ||
|
||
const insertionIndex = podfile.indexOf(postInstallLine); | ||
|
||
if (insertionIndex !== -1) { | ||
const endOfMarkerLineIndex = podfile.indexOf('\n', insertionIndex); | ||
|
||
if (endOfMarkerLineIndex !== -1) { | ||
const updatedPodfileContent = | ||
podfile.slice(0, endOfMarkerLineIndex) + | ||
podVersionOverride + | ||
podfile.slice(endOfMarkerLineIndex); | ||
|
||
await fs.writeFile( | ||
path.join(directory, 'ios', 'Podfile'), | ||
updatedPodfileContent | ||
); | ||
} | ||
} | ||
|
||
// set project deployement min version | ||
const project = await fs.readFile( | ||
path.join( | ||
directory, | ||
`ios/${config.project.name}Example.xcodeproj`, | ||
'project.pbxproj' | ||
), | ||
'utf8' | ||
); | ||
|
||
// match whole IPHONEOS_DEPLOYMENT_TARGET line | ||
const deployementLineRegex = | ||
/^(\s*)IPHONEOS_DEPLOYMENT_TARGET\s*=\s*[^;]+;$/gm; | ||
const replacementPattern = `$1IPHONEOS_DEPLOYMENT_TARGET = ${newTargetVersion};`; | ||
const updatedContent = project.replace( | ||
deployementLineRegex, | ||
replacementPattern | ||
); | ||
|
||
await fs.writeFile( | ||
path.join( | ||
directory, | ||
`ios/${config.project.name}Example.xcodeproj`, | ||
'project.pbxproj' | ||
), | ||
updatedContent | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not have a workaround for old code. we're testing on newer xcode version so this won't be tested properly. Lets remove this.
@@ -18,13 +18,14 @@ yarn | |||
``` | |||
|
|||
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development. | |||
<% if (project.moduleConfig === 'nitro-modules') { -%> | |||
> <% if (project.moduleConfig === 'nitro-modules' || project.viewConfig === 'nitro-view') { -%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the >
intentional?
|
||
<% } -%> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will add 2 new lines after processing so we should remove this new line - or add a new line above this block and remove the one after.
Summary
Introduces the option to add a Nitro View Component when scaffolding a new library with
create-react-native-library
.Nitro View selection during setup
Updates the example app generation for nitro modules to set the minimum iOS deployment target to 16.0 for both the project and its native dependencies. This change addresses an Xcode 12.2 compatibility issue where Nitro modules failed to build with the previous default target of iOS 15.1.
Updated the fallback Nitro Modules version to
0.25.2
Test plan
bin/create-react-native-library
yarn nitro-codegen
and build example app for both platformsExample App