forked from paufau/react-native-multiple-modals-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject-run-ios.js
More file actions
67 lines (59 loc) · 2.19 KB
/
project-run-ios.js
File metadata and controls
67 lines (59 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { execSync } from 'child_process';
import { Logger } from './utils.js';
const logger = new Logger();
const setupPods = ({ project, architecture }) => {
logger.log(`Setting up Pods for iOS project at ${project}...`);
try {
execSync(`cd ${project}/ios && RCT_NEW_ARCH_ENABLED=${architecture === 'new' ? 1 : 0} pod install`, { stdio: 'inherit' });
logger.log('Pods setup completed successfully.');
} catch (error) {
logger.raiseException(`Failed to set up Pods: ${error.message}`);
}
}
const setupProject = ({ project }) => {
logger.log(`Setting up project at ${project}...`);
try {
execSync(`cd ${project} && yarn install`, { stdio: 'inherit' });
logger.log('Project setup completed successfully.');
} catch (error) {
logger.raiseException(`Failed to set up project: ${error.message}`);
}
}
const launchIOSSimulator = ({ device, project }) => {
logger.log(`Launching iOS simulator for device: ${device}`);
try {
execSync(`open -a Simulator`)
// execSync(`cd ${project}/ios && xcrun simctl boot "${device}"`, { stdio: 'inherit' });
logger.log('iOS simulator launched successfully.');
} catch (error) {
logger.raiseException(`Failed to launch iOS simulator: ${error.message}`);
}
}
const installApp = ({ project, device }) => {
logger.log(`Installing app at ${project}...`);
try {
execSync([
`cd ${project} && npx react-native run-ios --extra-params="-allowProvisioningUpdates"`,
device ? `--udid=${device}` : ''
].filter(Boolean).join(' '), { stdio: 'inherit' });
logger.log('App installed successfully.');
} catch (error) {
logger.raiseException(`Failed to install app: ${error.message}`);
}
}
export const runIOS = ({ project, device, architecture, verbose, skipSetup }) => {
logger.isVerbose = verbose;
logger.log(`Running iOS project at ${project} on device ${device} with architecture ${architecture}`);
try {
if (!skipSetup) {
setupProject({ project });
}
setupPods({ project, architecture });
if (device) {
launchIOSSimulator({ project, device });
}
installApp({ project, device });
} catch (error) {
logger.raiseException(`Failed to install iOS app: ${error.message}`);
}
}