I'm building a new project using Xcode and I get an error
react-native init test
{
"name": "test1",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.9"
},
"devDependencies": {
"#babel/core": "7.4.5",
"#babel/runtime": "7.4.5",
"babel-jest": "24.8.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
I got this error
'glog/logging.h' file not found
Try this:
rm -rf ./node_modules && yarn && react-native run-ios
cd node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh should do the trick.
You just have to execute the script manually. Might need to sudo.
Related
The default files generated from npx react-native init {file_name} resulted in a 558.7MB app. This app is running on a physical device. Its also using typescript, but I don't think that should have that much of an effect. I have created react native apps in the past before but they were never this big, has something changed? Is this size normal now?
package.json
{
"name": "-------",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"react": "18.1.0",
"react-native": "0.70.6"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"#tsconfig/react-native": "^2.0.2",
"#types/jest": "^26.0.23",
"#types/react": "^18.0.21",
"#types/react-native": "^0.70.6",
"#types/react-test-renderer": "^18.0.0",
"#typescript-eslint/eslint-plugin": "^5.37.0",
"#typescript-eslint/parser": "^5.37.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "0.72.3",
"react-test-renderer": "18.1.0",
"typescript": "^4.8.3"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
All,
I am trying to include babel-plugin-proposal-class-properties in my code bundle, but I get the following error;
2020-01-07 08:19:31.593 [error][tid:NSOperationQueue 0x2817acc40 (QOS: UNSPECIFIED)][RCTCxxBridge.mm:414] Failed to load bundle(http://169.254.99.36:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(index.js: Cannot find module 'babel-plugin-plugin-proposal-class-properties' from '/Users/bburch/Projects/systems/SystemsDockConfig'
- Did you mean "#babel/plugin-proposal-class-properties"? (null))
My .babelrc looks like;
{ "presets": [
"#babel/env",
"#babel/react", ], "plugins": ["proposal-class-properties",] }
I also have tried this syntax;
{
"presets": [
"#babel/preset-env",
"#babel/preset-react"
],
"plugins": ["#babel/plugin-proposal-class-properties"]
}
In either case, somehow the "plugin" part of the package name is being doubled and of course the module is not found when that happens.
My package.json;
{
"name": "SystemsDockConfig",
"version": "0.0.2",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#babel/plugin-proposal-class-properties": "^7.7.4",
"#babel/plugin-syntax-object-rest-spread": "^7.7.4",
"#babel/preset-env": "^7.7.7",
"buffer": "^5.0.7",
"eslint": "^6.8.0",
"eventemitter3": "^4.0.0",
"native-base": "^2.13.8",
"react": "16.8.3",
"react-native": "0.59.10",
"react-native-ble-plx": "1.1.0",
"react-native-camera": "^1.0.0",
"react-native-router-flux": "^4.0.6",
"react-native-version-number": "^0.3.1",
"react-native-wheel-datepicker": "^2.1.8"
},
"devDependencies": {
"#babel/core": "^7.6.4",
"#babel/runtime": "^7.6.3",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
I suggest you change your .babelrc to babel.config.json and use{
make sure you install
npm i --save-dev #babel/plugin-proposal-class-properties
this should work
bable.config.json
{
"presets": ["#babel/preset-env", "#babel/preset-react"],
"plugins": [
"#babel/plugin-proposal-class-properties"
]
}
I keep getting this error:
error in ./node_modules/keytar/build/Release/keytar.node
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
# ./node_modules/keytar/lib/keytar.js 1:13-52
# ./src/background.js
# multi ./src/background.js
I have background.js set as the main electron file in package.json because I'm using vue/vuetify with it which uses a main.js file as well.
{
"name": "project",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js", // <------------------ see right here
"dependencies": {
"axios": "^0.19.0",
"core-js": "^3.4.3",
"jwt-decode": "^2.2.0",
"keytar": "^5.0.0",
"request": "^2.88.0",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuetify": "^2.1.0",
"vuex": "^3.1.2"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^4.1.0",
"#vue/cli-plugin-eslint": "^4.1.0",
"#vue/cli-service": "^4.1.0",
"babel-eslint": "^10.0.3",
"electron": "^7.1.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"node-loader": "^0.6.0",
"sass": "^1.19.0",
"sass-loader": "^8.0.0",
"vue-cli-plugin-electron-builder": "^1.4.3",
"vue-cli-plugin-vuetify": "^2.0.2",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.3.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}
Searching, it seems this happens when keytar is used in a renderer process. But background.js isn't a renderer process. Or am I missing something? I am completely new to electron.
I needed to mark keytar as external (as mentioned at https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html#native-modules)
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
// List native deps here if they don't work
externals: ['keytar']
}
}
}
Once I did that it worked properly.
Run appropriate loader (source).
yarn add node-loader -D
// vue.config.js
configureWebpack: {
devtool: 'source-map',
module: {
rules: [
{ test: /\.node$/, loader: 'node-loader' }
]
}
}
I am trying to get the current locale from ios devices.
I followed this guide when I created my project and I'm using expo.
I tried the following code
if (Platform.OS === "android") {
langRegionLocale = NativeModules.I18nManager.localeIdentifier || "";
} else if (Platform.OS === "ios") {
langRegionLocale = NativeModules.SettingsManager.settings.AppleLocale || "";
}
and it worked for android, but when tested on an iPhone, it did not work and said SettingsManager was undefined when i logged it.
How can I get the current locale for ios without ejecting or using AlexanderZaytsev/react-native-i18n?
If possible I would like to use something that is built in.
Below is my package.json
{
"name": "demoapp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.5.0",
"jest-expo": "^21.0.2",
"react-test-renderer": "16.0.0-alpha.12"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"expo": "^21.0.0",
"react": "16.0.0-alpha.12",
"react-native": "^0.48.4",
"react-navigation": "^1.0.0-beta.13",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
}
}
Expo Util API has a method for getting device locale.
Expo.Util.getCurrentLocaleAsync()
Returns the current device
locale as a string.
I just created a new project on react-native version 0.37 on iOS.
I've setting up this part of info.plist
server is running :
But this loads loop on this url:
url: /index.ios.bundle?platform=ios&dev=true&minify=false
And I finally get this error :
my package.json
{
"name": "Mich",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.3.2",
"react-native": "0.37.0"
},
"jest": {
"preset": "jest-react-native"
},
"devDependencies": {
"babel-jest": "17.0.2",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.3",
"jest-react-native": "17.0.3",
"react-test-renderer": "15.3.2",
"whatwg-fetch": "2.0.1"
}
}
I have never had this error before by starting a new project. Someone can explain me what is wrong?
I've found a solution, i press CMD+R and during server is loading, i press CMD + D and i press on Debug JS remotly.