Fail to start fresh project
Description
Today I just tested creating new project, with Nitro modules.
after the setup up, I run:
yarn ->> successful
yarn example ios -> failed
error below:
✖ Installing Ruby Gems
error Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/me/Code/Personal/react-native/test-nitro/example/vendor/bundle/ruby/2.6.0/gems/nkf-0.2.0/ext/nkf
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20250411-17857-nuxxw9.rb extconf.rb
creating Makefile
current directory:
/Users/me/Code/Personal/react-native/test-nitro/example/vendor/bundle/ruby/2.6.0/gems/nkf-0.2.0/ext/nkf
make "DESTDIR=" clean
current directory:
/Users/me/Code/Personal/react-native/test-nitro/example/vendor/bundle/ruby/2.6.0/gems/nkf-0.2.0/ext/nkf
make "DESTDIR="
make: *** No rule to make target
`/Applications/Xcode-16.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin23/ruby/config.h',
needed by `nkf.o'. Stop.
make failed, exit code 2
Gem files will remain installed in
/Users/me/Code/Personal/react-native/test-nitro/example/vendor/bundle/ruby/2.6.0/gems/nkf-0.2.0
for inspection.
Results logged to
/Users/me/Code/Personal/react-native/test-nitro/example/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-23/2.6.0/nkf-0.2.0/gem_make.out
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:99:in
`run'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:51:in
`block in make'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in
`each'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in
`make'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:62:in
`block in build'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tempfile.rb:295:in
`open'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in
`build'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:185:in
`block in build_extension'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/monitor.rb:235:in
`mon_synchronize'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:181:in
`build_extension'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:229:in
`block in build_extensions'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in
`each'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in
`build_extensions'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/installer.rb:830:in
`build_extensions'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/source/rubygems.rb:207:in
`install'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/installer/gem_installer.rb:54:in
`install'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/worker.rb:62:in
`apply_func'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/worker.rb:57:in
`block in process_queue'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/worker.rb:54:in
`loop'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/worker.rb:54:in
`process_queue'
/Users/me/.gem/ruby/2.6.0/gems/bundler-2.3.27/lib/bundler/worker.rb:91:in
`block (2 levels) in create_threads'
An error occurred while installing nkf (0.2.0), and Bundler cannot continue.
In Gemfile:
cocoapods was resolved to 1.15.2, which depends on
xcodeproj was resolved to 1.25.1, which depends on
CFPropertyList was resolved to 3.0.7, which depends on
nkf
✖ Installing Ruby Gems
error Something when wrong while installing CocoaPods. Please run pod install manually.
I didn't change anything from the generated project, it's just fresh new
Packages
- [x] create-react-native-library
- [ ] react-native-builder-bob
Selected options
➜ react-native npx create-react-native-library@latest test-nitro
✔ What is the name of the npm package? … react-native-test-nitro
✔ What is the description for the package? … asdad
✔ What is the name of package author? … aasdasd
✔ What is the email address for the package author? … [email protected]
✔ What is the URL for the package author? … http://localhost
✔ What is the URL for the repository? … http://localhost
✔ What type of library do you want to develop? › Nitro module
✔ Project created successfully at test-nitro!
Get started with the project:
$ yarn
Run the example app on iOS:
$ yarn example ios
Run the example app on Android:
$ yarn example android
See CONTRIBUTING.md for more details. Good luck!
➜ react-native
Link to repro
https://github.com/maitrungduc1410/test-nitro
Environment
Macbook M2 Apple chip
I tried on a Macbook Intel chip still failing, but with different errors:
➜ test-nitro git:(main) ✗ yarn example ios
✔ Installing Ruby Gems
✖ Installing CocoaPods dependencies (this may take a few minutes)
error
[!] Invalid `Podfile` file:
[!] Invalid `TestNitro.podspec` file: cannot load such file -- nitrogen/generated/ios/TestNitro+autolinking.rb.
# from /Users/ductrungmai/Code/react-native/test-nitro/TestNitro.podspec:18
# -------------------------------------------
#
> load 'nitrogen/generated/ios/TestNitro+autolinking.rb'
# add_nitrogen_files(s)
# -------------------------------------------
.
# from /Users/ductrungmai/Code/react-native/test-nitro/example/ios/Podfile:20
# -------------------------------------------
# target 'TestNitroExample' do
> config = use_native_modules!
#
# -------------------------------------------
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Something when wrong while installing CocoaPods. Please run pod install manually.
info Run CLI with --verbose flag for more details.
➜ test-nitro git:(master) ✗
It seems to be an issue with ruby on your system. I found this issue which looks related https://github.com/CocoaPods/CocoaPods/issues/12326
@maitrungduc1410, @mrousavy, @satya164
FINALLY I figured out this error. There is a zero percent chance that I figure this out without the help of GPT.
@maitrungduc1410 I couldn't get nitro's example to build for the life of me (this is part of the reason why I created this issue with Nitro Modules.
I tried following the ruby guide that @satya164 suggested and I did everything it said meticulously and I still got the error above when I tried to run yarn example ios.
The solution for me:
-
npx create-react-native-library@latest react-native-package-name - Respond to all the questions from the cli
-
cd react-native-package-name -
cd example/ios -
pod install&&bundle install<------- THIS SOLVED THE ERROR ABOVE -
cd ../../ -
yarn -
yarn prepare<-------- If you don't do this step, you get the following error:
[!] Invalid `Podfile` file:
[!] Invalid `AudioManager.podspec` file: cannot load such file -- nitrogen/generated/ios/AudioManager+autolinking.rb.
# from /Users/christophergabba/react-native-audio-manager/AudioManager.podspec:18
# -------------------------------------------
#
> load 'nitrogen/generated/ios/AudioManager+autolinking.rb'
# add_nitrogen_files(s)
# -------------------------------------------
.
# from /Users/christophergabba/react-native-audio-manager/example/ios/Podfile:20
# -------------------------------------------
# target 'AudioManagerExample' do
> config = use_native_modules!
#
# -------------------------------------------
✖ Installing CocoaPods dependencies (this may take a few minutes)
-
yarn example ios
You should then get this error:
error Signing for "AudioManagerExample" requires a development team. Select a development team in the Signing & Capabilities editor. (in target 'AudioManagerExample' from project 'AudioManagerExample')
error Failed to build ios project. "xcodebuild" exited with error code '65'. To debug build logs further, consider building your app with Xcode.app, by opening 'AudioManagerExample.xcworkspace'.
info Run CLI with --verbose flag for more details.
-
xed example/iosand fill in your development team.
Now yarn example ios should work (look below if you want to use expo in your example app).
Steps 13 - 20 are if you want expo in your example app:
13. cd example
14. yarn add [email protected] // NOTE THAT EXPO 53 IS IN BETA, BUT FIXES COMPATIBILITY WITH react-native v0.78+
15. yarn add expo-dev-client
16. npx expo install --check (runs expo-doctor and fixes react and react-native versioning
17. npx expo prebuild --clean
18. Change your index.js file:
import { registerRootComponent } from 'expo'; // need to use expo
import App from './src/App';
registerRootComponent(App);
- Change your
metro.config.jsfile to use expo's:
const { getDefaultConfig } = require("@expo/metro-config");
20: Change your babel.config.js file to use expo's:
const path = require('path');
const { getConfig } = require('react-native-builder-bob/babel-config');
const pkg = require('../package.json');
const root = path.resolve(__dirname, '..');
module.exports = getConfig(
{
presets: ['babel-preset-expo'],
},
{ root, pkg }
);
-
npx expo run:ios --deviceBOOM runs finally (SHEEEEEESHHH at least 4 hours of my life I'll never get back).Anyway, I hope this helps some other poor souls like myself.
TLDR somewhere either in the docs or via automated through the cli, some of these steps need to be automated. Just my 0.02.
There is also a small chance that I'm a moron and just did something completely wrong.
In Gemfile:
cocoapods was resolved to 1.15.2, which depends on
xcodeproj was resolved to 1.25.1, which depends on
CFPropertyList was resolved to 3.0.7, which depends on
nkf
✖ Installing Ruby Gems
error Something when wrong while installing CocoaPods.
I ran into this issue a lot of times. What I do is, manually do
cd example/ios
pod install
Open the example project in Xcode and build from there instead of using react-native and it works fine
@niteshbalusu11 I'm sure this works, but you shouldn't have to do this, you should be able to build with react-native.