Description
Hi everyone! 👋
We are currently upgrading our application from version .73.8 to .75.4 and we've noticed something weird.
With the new version, if we run pod install, now Codegen gets executed differently than before.
This would be fine if we actually enabled the new architecture, but we didn't and it breaks the pods install phase because some libraries are compatible with the new architecture but present issues in the Spec file that Codegen refers to.
So we can't install pods using the old architecture with libraries that present issues on Spec files because Codegen can't properly parse them (I guess)
I took the time to look into the changes between version .73.x and .75.x and I've noticed that this commit was included: Defragment Codegen in OSS between Old and New Architecture and it changes the following file: codegen.rb by removing the new_arch_enabled check in the run_codegen function.
Doing so means that if we run the same project on version .73 it works fine, but if we run it from version .74 onward it breaks on the old architecture with any library that has a Spec file that is broken
I don't have a complete overview of how Codegen gets executed, by I think that we should revert this check for the sake of any project that can't migrate right away due to lock-ins: may them be by libraries or vendor code such as third party sdks.
Steps to reproduce
- Init a new project with
npx @react-native-community/cli@latest init RN75 --version 0.74 --pm npm;
- Install any library such as
npm install --save-dev react-native-webview;
- Break the Spec file in any way, in our case we can break:
react-native-webview's Spec file by adding a Tuple that isn't supported yet; (Example down below)
- Run
pod install;
- See Codegen error;
Example:
// node_modules/react-native-webview/src/NativeRNCWebViewModule.ts
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
export interface Spec extends TurboModule {
isFileUploadSupported(): Promise<boolean>;
shouldStartLoadWithLockIdentifier(
shouldStart: boolean,
lockIdentifier: [Double] // We change this type from Double to [Double]
): void;
}
export default TurboModuleRegistry.getEnforcing<Spec>('RNCWebViewModule');
React Native Version
0.74.0+
Affected Platforms
Build - MacOS
Output of npx react-native info
System:
OS: macOS 14.6
CPU: (8) arm64 Apple M3
Memory: 108.92 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.8.0
path: ~/.nvm/versions/node/v22.8.0/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v22.8.0/bin/yarn
npm:
version: 10.8.2
path: ~/.nvm/versions/node/v22.8.0/bin/npm
Watchman:
version: 2024.09.09.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/user/.gem/ruby/3.3.0/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.12
path: /usr/bin/javac
Ruby:
version: 3.3.5
path: /Users/user/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.5
wanted: 0.74.5
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
info React Native v0.75.4 is now available (your project is running on v0.74.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.75.4
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.74.5
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
/Users/user/Documents/Projects/ReactNative/RN74/vendor/bundle/ruby/3.3.0/gems/concurrent-ruby-1.3.4/lib/concurrent-ruby/concurrent/concern/deprecation.rb:1: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.
/Users/user/Documents/Projects/ReactNative/RN74/vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.8.4/lib/active_support/core_ext/big_decimal.rb:3: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add bigdecimal to your Gemfile or gemspec to silence this warning.
/Users/user/Documents/Projects/ReactNative/RN74/vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.8.4/lib/active_support/notifications.rb:4: warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add mutex_m to your Gemfile or gemspec to silence this warning.
(node:64099) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Auto-linking React Native module for target `RN74`: react-native-webview
Framework build type is static library
[Codegen] Adding script_phases to React-Codegen.
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[!] Invalid `Podfile` file: [!] /Users/user/.nvm/versions/node/v22.8.0/bin/node ./../node_modules/react-native/scripts/generate-codegen-artifacts.js -p /Users/user/Documents/Projects/ReactNative/RN74/ios/.. -o /Users/user/Documents/Projects/ReactNative/RN74/ios -t ios
[Codegen] Analyzing /Users/user/Documents/Projects/ReactNative/RN74/package.json
[Codegen] Searching for codegen-enabled libraries in the app.
[Codegen] The "codegenConfig" field is not defined in package.json. Assuming there is nothing to generate at the app level.
[Codegen] Searching for codegen-enabled libraries in the project dependencies.
[Codegen] Found react-native
[Codegen] Found react-native-webview
[Codegen] >>>>> Searching for codegen-enabled libraries in react-native.config.js
[Codegen] Processing FBReactNativeSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing rncore
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing RNCWebViewSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos, visionos for RNCWebViewSpec
[Codegen] Done.
UnsupportedTypeAnnotationParserError: Module NativeRNCWebViewModule: TypeScript type annotation 'TSTupleType' is unsupported in NativeModule specs.
at translateTypeAnnotation (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/typescript/modules/index.js:376:15)
at /Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:373:11
at guard (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/utils.js:26:14)
at translateFunctionTypeAnnotation (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:367:25)
at buildPropertySchema (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:484:7)
at /Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:705:24
at guard (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/utils.js:26:14)
at /Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:702:14
at Array.map (<anonymous>)
at buildModuleSchema (/Users/user/Documents/Projects/ReactNative/RN74/node_modules/@react-native/codegen/lib/parsers/parsers-commons.js:699:6) {
nodes: [
Node {
type: 'TSTupleType',
start: 342,
end: 350,
loc: [SourceLocation],
elementTypes: [Array]
}
],
typeAnnotationType: 'TSTupleType'
}
.
# from /Users/user/Documents/Projects/ReactNative/RN74/ios/Podfile:20
# -------------------------------------------
#
> use_react_native!(
# :path => config[:reactNativePath],
# -------------------------------------------
[!] [Codegen] warn: using experimental new codegen integration
Reproducer
https://github.com/gladiuscode/codegen-breaks-pod-install-on-old-arch
Screenshots and Videos
No response
Description
Hi everyone! 👋
We are currently upgrading our application from version .73.8 to .75.4 and we've noticed something weird.
With the new version, if we run
pod install, now Codegen gets executed differently than before.This would be fine if we actually enabled the new architecture, but we didn't and it breaks the pods install phase because some libraries are compatible with the new architecture but present issues in the Spec file that Codegen refers to.
I took the time to look into the changes between version .73.x and .75.x and I've noticed that this commit was included: Defragment Codegen in OSS between Old and New Architecture and it changes the following file: codegen.rb by removing the
new_arch_enabledcheck in therun_codegenfunction.I don't have a complete overview of how Codegen gets executed, by I think that we should revert this check for the sake of any project that can't migrate right away due to lock-ins: may them be by libraries or vendor code such as third party sdks.
Steps to reproduce
npx @react-native-community/cli@latest init RN75 --version 0.74 --pm npm;npm install --save-dev react-native-webview;react-native-webview's Spec file by adding a Tuple that isn't supported yet; (Example down below)pod install;Example:
React Native Version
0.74.0+
Affected Platforms
Build - MacOS
Output of
npx react-native infoStacktrace or Logs
Reproducer
https://github.com/gladiuscode/codegen-breaks-pod-install-on-old-arch
Screenshots and Videos
No response