Mojave + Xcode 10 build fails on glog config.h, gflags/gflags.h - react-native

I'm testing React Native 0.56.0-rc.2 on Mac OS Mojave and Xcode 10.
Running:
react-native init TestProject --version="0.56.0-rc.2"
cd TestProject
npm run start
react-native run-ios
Which generated some long errors.
Entering Xcode gave me a failure on missing config.h for glog, which I found could be built manually:
cd ./node_modules/react-native/third-party/glog-0.3.4
./configure && make && make install
Which passed that stage, but got me on yet another issue
(...)/node_modules/react-native/third-party/glog-0.3.4/src/glog/logging.h:85:10:
'gflags/gflags.h' file not found
I can't find anything related to RN and this on Google or Stack Overflow, only references to other packages and instructions to install those on a Debian-based system.
Is this a known issue?

Running this from the project directory fixed it for me:
cd ./node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh
This manually triggers the config script

A simple and quick resolution.
In Xcode, go to File->Project/Workspace settings.
Change the build system to Legacy Build system.
This is the resolution from Wesley's link. Saw something the other day about posting the direct answer and trying to avoid linking because links / websites can change. I was going to leave this as a comment, but don't have enough rep.

Update
It is a known issue, tracked here:
https://github.com/facebook/react-native/issues/19774

I resolved it by running following steps
In the root of the project, run npm install or yarn - install packages
cd node_modules/react-native - go to node modules directory
scripts/ios-install-third-party.sh - install # node_modules/react-native/third-party
cd third-party - go to newly created third party directory
cd glog-0.3.x - ls -la to find your directory version number or just use tab to auto-complete)
./configure - run setup
cd ../../../../ - change back to your project directory
react-native run-ios or react-native run-android - deploy

If any of these solution does not work, please check your project path. Project path and/or directory names should not contain any
space in its name or you can create project on Desktop or in Documents
directory.
Because of invalid name in project path, React Native project unable to link / add glob header files inside project / workspace.

Related

Expo CLI installed through yarn, but not working

So I tried installing expo CLI for my react native project. I tried installing it with npm as shown on the official expo.io website, but it didn't work out. So as per the answers from this stack overflow post. It installed with the command yarn global add expo-cli and I got to see this following output.
success Installed "expo-cli#4.0.13" with binaries:
- expo
- expo-cli
but to verify whether the installation was successful, I ran the command expo whoami and got the following error.
Command 'expo' not found, did you mean:
command 'exo' from snap exoscale-cli (v1.22.0)
command 'expr' from deb coreutils (8.30-3ubuntu2)
command 'expn' from deb sendmail-base (8.15.2-18)
See 'snap info <snapname>' for additional versions.
I'm on Ubuntu 20.04 LTS. I really don't know what's going on here and how can I get to run expo CLI successfully, a little help for your newbie fellow developer here.
Check if expo-cli is properly installed or not using the following code:
yarn global list
Check if expo-cli is added to your path or not using the following code. (Generally, it should be added automatically )
echo $PATH
This will show a list of folders. Look into these folder and try to find expo-cli. If that is not present there then export the path of expo-cli in your .bashrc ( or other dotfile ) using the following
export PATH=$PATH:~/PATH/TO/YOUR/EXPOCLI
Change the "PATH/TO/YOUR/EXPOCLI" to the path of your expo-cli.
If you're running Windows, follow these steps:
Follow this guide to access the PATH environment variable https://www.maketecheasier.com/what-is-the-windows-path/
Add an entry to the Path environment variable that looks like this: C:\Users\<YourUserNameHere>\AppData\Local\Yarn\bin

react-native-camera: sdk manager plateforms-tools 28.0.1 can't be installed

I'm trying to install react-native-camera. I'm on Ubuntu 18, Webstorm for IDE. Targeting Android.
For the Android SDK, I don't have a full Android Studio install. I've instead install only android-sdk and I'm using the sdkmanager. That works fine with my stub app, it compile and runs on Android with
react-native run-android
I've installed react-native-camera as a module with npm as per the indications:
npm install react-native-camera --save
react-native link react-native-camera
So far so good. It links. If I try to launch the app however (even before trying to actually use the camera), I get some warnings:
> Configure project :react-native-camera
Checking the license for package Android SDK Platform-Tools in /usr/lib/android-sdk/licenses
License for package Android SDK Platform-Tools accepted.
Preparing "Install Android SDK Platform-Tools (revision: 28.0.1)".
Warning: Failed to read or create install properties file.
WARNING: platform-tools package is not installed, and automatic installation failed.
So I've tried to install the platforms tools using the sdk manager & instructions provided here:
sdkmanager "platform-tools" "platforms;android-28"
Which yields:
Warning: Failed to read or create install properties file.
So I am guessing it really has to do with the sdkmanager...
Do I absolutely need 28.0.1 for react-native-camera? If so, how can I get around this issue with the SDK manager? I've tried various similar syntax for the install of the platform and it didn't work. I checked with sdkmanager --list that it's the proper name (seems to be). And if I go under android-sdk/platforms-tools all I see there is the adb file (or perhaps the install is supposed to just update that file?)
Silly me.
I needed to run the SDK manager as sudo. To do that:
sudo bash sdkmanager [installations args as per post above].
I will leave the post - I lost a ridiculous amount of time for that, hopefully it can help others....
And yes - if the platform-tools install has worked then under /platform-tools you should see a bunch of files, not just the adb one.

Nativescript vue, how to get the .apk file?

By following nativescript docs, installed all dependencies and tns doctor dont find any error.
and followed a tutorial and ran the following commands,
npm install -g #vue/cli #vue/cli-init
vue init nativescript-vue/vue-cli-template hello-vue
cd hello-vue
npm install
All sets fine and then i did my coding for an simple app then i ran below command:
npm run watch:android
This deploy the app in my connected android phone.
so my question is how can i get the apk file, so that i can send to another person?
Note: sidekick even not opening my folder. and when running tns build android shows No project found at or above 'C:\wamp64\www\newapp' and neither was a --path specified.
For building the apk for android, use the following command:
tns build android --release --key-store-path <path-to-your-keystore> --key-store-password <your-key-store-password> --key-store-alias <your-alias-name> --key-store-alias-password <your-alias-password>
Lots more info here : https://docs.nativescript.org/tooling/publishing/publishing-android-apps
If you want to get the debug apk using tns debug android --bundle, it will be located here :
<your project folder>/platforms/android/app/build/outputs/apk/debug/app-debug.apk
If you are having trouble running tns, install nativescript globally using:
npm i -g nativescript
And follow the simple prompts.
I'm not sure if this is what you're looking for (it sounds like you want a debug.apk instead of an output.apk), but you might want to look at the documentation for publishing an Android app.

Setup a cloned react-native project created via react-native init command

I have created a react-native project XYZApp using react-native init which is pushed in GitHub repo.
Now when I am cloning the project on a different system. following is the directory structure
app/XYZApp
Following is the set of commands and steps I am using.
cd app
brew install node
brew install watchman
#
npm install -g react-native-cli
#
install android studio and required SDKs
#
install X-Code
#
react-native init MyApp
prompt: Directory MyApp already exists. Continue?: (no)
I am typing - yes
npm install [all dependencies]
react-native link
Through all the above steps, some new default files are getting created which runs a default app, with some minor changes in those files I am able to run the app. But I know this is not the correct way of doing this.
I tried several other methods also,
like npm start
I checked several links but could not find the correct method for the setup after cloning.
Most of them are mentioned for create-react-native-app method.
It will be great if someone can help me regarding this.
after cloning
Don't do this
react-native init MyApp
prompt: Directory MyApp already exists. Continue?: (no)
I am typing - yes
npm install [all dependencies]
react-native link
just go to cloned app directory XYZApp and do
npm install
and all set to run the app using
react-native run-android
Update 2019 React Native 0.60.0+:
First you need to install all the node modules by running
npm install
If you're using libraries with native dependencies like react-native-gesture-handler these libraries need to be linked correctly. To do so run
react-native link
For setting up the iOS project correctly you need to install the CocoaPods dependencies:
cd ios && pod install

Failed to run react-native link on my project

When I run react-native link on my RN project, I got below error:
$ react-native link
rnpm-install ERR! ERRPACKAGEJSON No package found. Are you sure it's a React Native project?
Cannot read property '_text' of undefined
I have searched that some people say run react-native upgrade will resolve this issue. I have tried but no lock. My react version is shown as below:
$ react-native --version
react-native-cli: 2.0.1
react-native: 0.39.2
How can I solve this issue?
Follow below steps in order -
npm cache clean or yarn cache clean
rm -rf node_modules
yarn install or npm install
react-native upgrade ( You can choose no in all steps)
react-native link
If you get permission related error use sudo with all commands.
A little late but this may help someone else. My problem was large commented out copies of <manifest> ... </manifest> in android/app/src/main/AndroidManifest.xml. Once I removed commented out copies, link worked as expected.
It seems xmldoc had touble parsing the manifest even though the AndroidManifest.xml was valid XML. Calling react-native link uses ../node_modules/react-native/local-cli/core/android/index.js. To debug such issues in future I would start with putting debugging statements in ../node_modules/react-native/local-cli/core/android/index.js and narrow down to the root cause of the issue. Similar logic should work for ios.
For me cleaning the gradle did the trick.
1- Go to the root directory of the project.
2- Run cd android
3- Run gradlew clean
4- Run cd..
and then run the link commands
i had this problem. i fixed it with following way:
1- edit "/android/app/src/debug/AndroidManifest.xml"
2- add package="com.YOUR PACKAGE NAME" inline manifest tag. like:
<manifest package="com.YOUR PACKAGE NAME"
note: replace "YOUR PACKAGE NAME" with your package. you can find it in "/android/app/src/main/AndroidManifest.xml"
3- cd android
4- ./gradlew clean
5- cd ../
6- react-native link
try to go android -> src -> main -> AndroidManifest.xml and delete all comments here. After that rerun react-native link, and all is working for me. Good luck!