React-Native change default location of iOS and Android folder - android

According to the react-native cli documentation we can specify custom configuration based on each platform for RN cli.
I want to change the default location of each platform folders so I added my custom react-native.config.js to the root of the project which you can find here:
module.exports = {
project: {
ios: {
project: './example/ios/example.xcworkspace',
},
android: {
sourceDir: './example/android/',
},
},
};
If I run react-native config in the root folder, I can see the correct configuration:
{
...
"project": {
"ios": {
"sourceDir": "path-to-project-directory/example/ios",
"folder": "path-to-project-directory",
"pbxprojPath": "path-to-project-directory/example/ios/example.xcworkspace/project.pbxproj",
"podfile": "path-to-project-directory/example/ios/Podfile",
"podspecPath": null,
"projectPath": "path-to-project-directory/example/ios/example.xcworkspace",
"projectName": "example.xcworkspace",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
},
"android": {
"sourceDir": "path-to-project-directory/example/android/",
"isFlat": true,
"folder": "path-to-project-directory",
"stringsPath": "path-to-project-directory/example/android/app/src/main/res/values/strings.xml",
"manifestPath": "path-to-project-directory/example/android/app/src/main/AndroidManifest.xml",
"buildGradlePath": "path-to-project-directory/example/android/build.gradle",
"settingsGradlePath": "path-to-project-directory/example/android/settings.gradle",
"assetsPath": "path-to-project-directory/example/android/app/src/main/assets",
"mainFilePath": "path-to-project-directory/example/android/app/src/main/java/com/example/MainApplication.java",
"packageName": "com.example",
"packageFolder": "com/example",
"appName": "app"
}
}
}
The problem is whenever I run react-native run-ios I get this error:
error iOS project folder not found. Are you sure this is a React Native project?. Run CLI with --verbose flag for more details.
NOTE: I installed all the dependencies properly. Here is the result of the react-native --v command:
react-native-cli: 2.0.1
react-native: 0.62.0

"react-native": "0.63.4"
For iOS you need to specify the --project-path prop in your run script, not in react-native.config.js
Your run script should look like this:
"ios": "react-native run-ios --project-path './<new folder>/ios'"
But after that you need to update paths to ../../node_modules/ located modules in a lot of native files like Podfile, ios/<your project name>.xcodeproj/project.pbxproj
You can check more here

Related

Use Firebase In-App-Messaging in Expo Project

I'm trying to add in a built-in application with react-native-expo a series of tools from firebase.I managed to add the following features Cloud Messaging and Firebase Analitycs.But I have to integrate In-app-messaging and Dynamic links
First time I install all firebase module/dependencies to do this task.
"#react-native-firebase/app": "^12.9.3",
"#react-native-firebase/in-app-messaging": "^12.9.3",
and my file looks like:
.......
import inAppMessaging from '#react-native-firebase/in-app-messaging
.......
useEffect(()=>{
await inAppMessaging().setMessagesDisplaySuppressed(true);
}[])
but I recive a warning:
]Unhandled promise rejection: Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.app().
After that I try to find a solution,I learn that expo allow to create plugins to extend expo functionality
I tty to salve problem fallow expo documentation but I couldn't figure out how to create these plugins.
Next I find a module that can help me with-rn-firebase but is not working and the module is depeciated.
Then I searched the internet until I discovered other people with the same problem this is the link I see in their app.json a basic config of plugin and I try to implement in my project,after I install dependencies that I need i add in my file:
"plugins": [
"#react-native-firebase/app",
"#react-native-firebase/analytics",
"#react-native-firebase/in-app-messaging"
],
But the fallowing error occure:
Package "#react-native-firebase/analytics" does not contain a valid config plugin.
Learn more: https://docs.expo.io/guides/config-plugins/#creating-a-plugin
Cannot use import statement outside a module
What I mean is, if anyone has ever faced this problem, I want in my project to be able to use in-app-messaging and dynamyc-links if someone has tried an implementation with expo and has any idea
Eventually I solved the problem,expo when I use the command expo:build android it only compiles my javascript files,but some of the code was written in java and other optional files in the android / ios folder.So instead of compiling with expo I used eas.
Faloowing command:
Run as administrator cmd and write this line npm install -g eas-cli.
Initialize new module in your expo/react native project with this line eas init.
Build aplication using this line for android: eas build --platform android
*For ios is a bit different you mast edit your file eas.json:
{
"cli": {
"version": ">= 0.43.0"
},
"build": {
"development": {
"distribution": "internal",
"android": {
"gradleCommand": ":app:assembleDebug"
},
"ios": {
"buildConfiguration": "Debug"
}
},
"preview": {
"distribution": "internal"
},
"production": {
"ios": {
"cocoapods": "1.11.2"
}
}
},
"submit": {
"production": {}
}
}
Build aplication using this line for ios: eas build --platform ios
Eas build include in complile all app file .gradle/.js/.java/.xml/.m/.h and this thing offer your posibility to build mobile app in expo with same functionality and complexity like react native cli.
Usefull Link
https://docs.expo.dev/build/setup/
React Native Expo Build Failing due to cocoapods version
I think you need to run locally using expo dev client
https://docs.expo.dev/development/getting-started/
Mostly, the package that is not supported by expo can run natively. But you need successfully built in eas build.

ReactNative: Uncaught TypeError: Cannot read property 'forEach' of undefined, while building KitchenSink demo

I am trying to compile a 'kitchen-sink' demo, for 'react-native':
NativeBase-KitchenSink
, and I have followed the following links already:
Solution to "React native: Android project not found. Maybe run react-native android first?"
Solution to "Expo : Cannot find a module LogReporter"
That is, from the installation of 'npm' till the installation of required tools using 'Yarn'.
And now I am stuck myself:
a. I run the command npm install in the 'root directory' of this project.
b. Then I run expo start, I see that the problems addressed in link 1 and 2 have gone away.
c. Then when the browser is up, I issue expo build:android
The following error shows up:
[11:14:44] Checking if current build exists...
[11:14:48] No currently active or previous builds for this project.
[11:14:50] Publishing to channel 'default'...
[11:14:56] Building iOS bundle
[11:15:09] Building Android bundle
[11:15:20] Analyzing assets
[11:15:27] Uploading assets
[11:15:27] No assets to upload, skipped.
[11:15:27] Processing asset bundle patterns:
[11:15:27] - D:\Projects\ReactNativeProjects\AwesomeProject\**\*
[11:15:27] Cannot read property 'forEach' of undefined
[11:15:27] TypeError: Cannot read property 'forEach' of undefined
at C:\xdl#51.4.0\src\Project.js:903:26
at Generator.next (<anonymous>)
at step (C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:191)
at C:\Users\hp\AppData\Roaming\npm\node_modules\expo-cli\node_modules\xdl\build\Project.js:2033:361
Please help me know where I am wrong? Some posts say the code is correct.
[EDIT]:
I also did a new thing in my 'app.json', just before executing command react-native eject, to create Android and iOS folders:
(Note: It is not mandatory to issue the react-native eject command, as this will cause permanent change according to the documentations)
{
"expo": {
"name": "AwesomeProject",
"description": "A Kitchen Sink project.",
"slug": "AwesomeProject",
"privacy": "public",
"sdkVersion": "30.0.0",
"platforms": [
"ios",
"android"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.abhsax.first"
},
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/logo.png",
"splash": {
"image": "./assets/splashscreen.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
]
},
"changes": "----below are the changes----",
"name": "AwesomeProject",
"displayName": "AwesomeProject"
}
That is, just when I added:
"name": "AwesomeProject",
"displayName": "AwesomeProject"
at the bottom of my 'app.json'
the command react-native eject started working, which was not working earlier, as the output was:
App name must be defined in the app.json config file to define the
project name. It must not contain any spaces or dashes.
Clearly, it is the hybrid of two different versions of the package managers: 'Expo' and 'npm'.
But the 'forEach' error in the concern here, did not go away.
Further efforts done were useless, so I am not putting them here.
I shall keep on trying until I figure it out.
you have to upgrade the expo cli version
do npm install -g expo-cli
and then expo start again
I resolved this by knowing that I was again mixing up with the package managers: 'npm' and 'yarn', and this time you do not need 'expo' for time being or all-together, so modify your 'app.json', removing expo section.
All I had to do was to issue the following commands in order.
Add React Base
yarn add react-base --save
Install Peer Dependencies
The peer dependencies included from any 'npm' packages does not automatically get installed. Your application will not depend on it explicitly.
react-native link
In the case of this demo project, one dependency was missing:
react-native link react-native-vector-icons
Start Yarn
yarn start
Run on android device or simulator.
react-native run-android
[Note:] Java 8 is recommended to be installed instead of higher versions of Java. see: What to install? Java 8 or Java 10
I wish it helps.
Happy coding :-)
Try changing:
"assetBundlePatterns": ["**/*"] to "assetBundlePatterns": ["assets/*"]
in your app.json file.

CRNA build:android issues

I am trying to build an APK file for my CRNA project, using expo. The first issue is, it tries to build iOS every time. Why is it building iOS when I used exp build:android?
Second, iOS only succeeds in building occasionally. It usually hangs at 0%.
The output is below:
> exp build:android
[16:28:36] Making sure project is set up correctly...
-[16:28:38] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
[16:28:38] Your project looks good!
[16:28:38] Checking if current build exists...
[16:28:39] No currently active or previous builds for this project.
[16:28:39] Unable to find an existing exp instance for this directory, starting a new one...
[16:28:40] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
[16:28:42] Starting Metro Bundler on port 19001.
[16:28:42] Metro Bundler ready.
[16:28:43] Tunnel ready.
[16:28:43] Publishing to channel 'default'...
[16:28:44] Warning: Not using the Expo fork of react-native. See https://docs.expo.io/.
[16:28:44] Building iOS bundle
And then it hanngs indefinitely.
Has anyone came across any of these issues and have any advice?
My app.json is below
{
"expo": {
"sdkVersion": "27.0.0",
"icon": "./test-icon.png",
"entryPoint": "./AppEntry.js",
"ignoreNodeModulesValidation": true,
"packagerOpts": {
"config": "rn-cli.config.js",
"projectRoots": ""
},
"android":{
"package": "expo.android.package",
},
"ios":{
"bundleIdentifier": "expo.ios.package",
},
},
"privacy": "unlisted",
"platforms": ["ios", "android"],
"version": "1.0.0",
"orientation": "portrait"
}
expo version: 55.0.4
react-native version: 0.55.4

Setting autoWebview: ' true' at protractor config.js file causing machine logout, ubuntu 16.04

Setting autoWebview: ' true' at protractor config file causing system logout, ubuntu 16.4
This is my config file:
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
specs: ['demo.js'],
capabilities: {
platformName : 'android',
platformVersion : '4.4.2',
deviceName: 'PNV4PN4LUORWSCRO',
directConnect: true,
browserName: "android",
autoWebview: ' true',
app: '/path/abc.apk',
appPackage: 'xyz',
appActivity: '.MainActivity',
newCommandTimeout: 140,
autoWebviewTimeout: 10000,
fulReset: true
},
baseUrl: 'http://10.0.2.2:8000',
allScriptsTimeout: 22000,
onPrepare: function () {
var wd = require('wd'),
protractor = require('protractor'),
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
}
};
If I am not setting autoWebview: ' true', then I am getting below issue:
[21:38:48] I/hosted - Using the selenium server at http://localhost:4723 /wd/hub
[21:38:48] I/launcher - Running 1 instances of WebDriver
[21:39:04] E/runner - Unable to start a WebDriver session.
E/launcher - Error: WebDriverError: Not yet implemented. Please help us: http://appium.io/get-involved.html
at WebDriverError (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/error.js:27:5)
at Object.checkLegacyResponse (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/error.js:580:13)
at /home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:360:15
at Promise.invokeCallback_ (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
at asyncRun (/home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2652:27)
at /home/dilip/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
[15:01:09] E/launcher - Process exited with error code 100
And below is spec.js file content:
describe('Protractor Demo App', function() { var firstNumber =element(by.model('xyz:id/data.email')); var secondNumber = element(by.model('xyz:id/data.password')); it('Open login page', function() { firstNumber.sendKeys("dilip"); secondNumber.sendKeys(7668);
});
Please, somebody help me out.
I had the same problem. As described in appium#6526, there is an issue, if a new version of procps and old version of an appium-chromedriver are used. Unfortunately, if I install appium, then I get old version of appium-chromedriver#2.8.3, because of appium's npm-shrinkwrap.json (which is removed in master).
I'm not npm expert, but solution, which satisfied me is:
Add appium to devDependencies and scripts in package.json
"devDependencies": {
"appium": "^1.5.2",
...
},
"scripts": {
"appium": "appium"
}
This allow you to run app-local version of appium with
npm run appium
instead of global appium installation.
Add npm-shrinkwrap.json (or generate with npm shrinkwrap --dev and edit) file to overwrite dependency:
{
"name": "my app",
"version": "1.0.0",
"dependencies": {
"appium": {
"version": "1.5.2",
"from": "appium#>=1.5.2 <2.0.0",
"resolved": "https://registry.npmjs.org/appium/-/appium-1.5.2.tgz",
"dependencies": {
"appium-android-driver": {
"version": "1.10.7",
"from": "appium-android-driver#1.10.7",
"resolved": "https://registry.npmjs.org/appium-android-driver/-/appium-android-driver-1.10.7.tgz"
}
}
}
}
}
Then install and run appium with
npm install
npm run appium
If I don't missing anything, then it should do the trick. Maybe in next appium release you don't need npm-shrinkwrap.json anymore.
EDIT: Example: ionic-appium-protractor-example
This issue is only seen on Ubuntu 16.04 because i had installed other version of Ubuntu i.e, 14.04 and this issue is not found on that version.

No cordova.local.properties file created by using cmd sencha cordova init com.mycompany.MyApp MyApp

I am executing this cmd
sencha cordova init com.mycompany.MyApp MyApp
cordova folder created but cordova.local.properties not appear
This is my app.json
"builds": {
"web": {"default": true},
"native": {
"packager": "cordova",
"cordova" : {
"config": {
// Uncomment the line below and add the platforms you wish to build for
//“platforms": "ios android wp8 blackberry”,
"id": "com.domain.HELLO123",
"name": "HELLO123"
}
}
}
Please tell me what step i am missing.I want to build remote build

Categories

Resources