Salesforce Asked by user85549 on October 4, 2021
We have an existing React Native application that we would like to integrate with the Mobile SDK.
Is this something that we can do?
Is there a recommend way to do this?
Is there any specific requirements that our existing app needs for this work?
Sorry for the late answer , I believe the below step might help you. you can manually add the Salesforce SDK to your project create a new folder called mobileSDK and add in the iOS [sdk][1] and Android [SDK][2] from salesforce
preferred way is just add a new file for each ios and android
For android create a new file in project root call it "installandroid.js" then paste the below code and save it
#!/usr/bin/env node
var packageJson = require('./package.json')
var execSync = require('child_process').execSync;
var path = require('path');
var fs = require('fs');
console.log('Installing npm dependencies');
execSync('yarn install', {stdio:[0,1,2]});
var rimraf = require('rimraf');
console.log('Installing sdk dependencies');
var sdkDependency = 'SalesforceMobileSDK-Android';
var repoUrlWithBranch = packageJson.sdkDependencies[sdkDependency];
var parts = repoUrlWithBranch.split('#'), repoUrl = parts[0], branch = parts.length > 1 ? parts[1] : 'master';
var targetDir = path.join('mobile_sdk', sdkDependency);
if (fs.existsSync(targetDir)) {
console.log(targetDir + ' already exists - if you want to refresh it, please remove it and re-run install.js');
} else {
execSync('git clone --branch ' + branch + ' --single-branch --depth 1 ' + repoUrl + ' ' + targetDir, {stdio:[0,1,2]});
rimraf.sync(path.join('mobile_sdk', 'SalesforceMobileSDK-Android', 'hybrid'));
rimraf.sync(path.join('mobile_sdk', 'SalesforceMobileSDK-Android', 'libs', 'test'));
rimraf.sync(path.join('mobile_sdk', 'SalesforceMobileSDK-Android', 'libs', 'SalesforceReact', 'package.json')); // confuses metro bundler
}
similarly create a file called "installios.js" in the root of the project and paste the below code and save it
#!/usr/bin/env node
var packageJson = require('./package.json')
var execSync = require('child_process').execSync;
var path = require('path');
var fs = require('fs');
console.log('Installing npm dependencies');
execSync('yarn install', {stdio:[0,1,2]});
console.log('Installing sdk dependencies');
var sdkDependency = 'SalesforceMobileSDK-iOS';
var repoUrlWithBranch = packageJson.sdkDependencies[sdkDependency];
var parts = repoUrlWithBranch.split('#'), repoUrl = parts[0], branch = parts.length > 1 ? parts[1] : 'master';
var targetDir = path.join('mobile_sdk', sdkDependency);
if (fs.existsSync(targetDir)) {
console.log(targetDir + ' already exists - if you want to refresh it, please remove it and re-run install.js');
} else {
execSync('git clone --branch ' + branch + ' --single-branch --depth 1 ' + repoUrl + ' ' + targetDir, {stdio:[0,1,2]});
}
console.log('Installing pod dependencies');
execSync('pod update', {stdio:[0,1,2], cwd:'ios'});
Then go to terminal or command prompt , point to your project root folder then execute the below commands
node ./installios.js
Once its completed then run
node ./installandroid.js
Hope this helps to make the salesforce integrated in your app.
But unfortunately I am unable to help you up with code changes in the code level [1]: https://github.com/forcedotcom/SalesforceMobileSDK-iOS [2]: https://github.com/forcedotcom/SalesforceMobileSDK-Android
Answered by jalilIrfan on October 4, 2021
If you are using CocoaPods this can be easily done for IOS as below.
You will need to install the Cocoapod first
brew install cocoapods
Create a default pod file if you do not have one
pod init
Make sure you have pod file as here
Now run the below command to get all dependencies
pod install
If this fails with errors mentioning xcrun, make sure that in Xcode in Preferences > Locations the Command Line Tools are assigned.
Answered by Mohith Shrivastava on October 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP