-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathpackageIos.ts
More file actions
71 lines (61 loc) · 2.27 KB
/
packageIos.ts
File metadata and controls
71 lines (61 loc) · 2.27 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
68
69
70
71
import path from 'node:path';
import {
getBuildOptions,
type BuildFlags as AppleBuildFlags,
} from '@rock-js/platform-apple-helpers';
import { packageIosAction } from '@rock-js/plugin-brownfield-ios';
import { getReactNativeVersion } from '@rock-js/tools';
import { Command } from 'commander';
import { getProjectInfo } from '../utils/index.js';
import {
actionRunner,
curryOptions,
ExampleUsage,
} from '../../shared/index.js';
export const packageIosCommand = curryOptions(
new Command('package:ios').description('Build iOS XCFramework'),
getBuildOptions({ platformName: 'ios' }).map((option) =>
option.name.startsWith('--build-folder')
? {
...option,
description:
option.description +
" By default, the '<iOS project folder>/build' path will be used.",
}
: option
)
).action(
actionRunner(async (options: AppleBuildFlags) => {
const { projectRoot, platformConfig, userConfig } = getProjectInfo('ios');
if (!userConfig.project.ios) {
throw new Error('iOS project not found.');
}
if (!userConfig.project.ios.xcodeProject) {
throw new Error('iOS Xcode project not found in the configuration.');
}
const brownieCacheDir = path.join(
userConfig.project.ios.sourceDir,
'.brownfield'
);
options.buildFolder ??= path.join(brownieCacheDir, 'build');
await packageIosAction(
options,
{
projectRoot,
reactNativePath: userConfig.reactNativePath,
// below: the userConfig.reactNativeVersion may be a non-semver-format string,
// e.g. '0.82' (note the missing patch component),
// therefore we resolve it manually from RN's package.json using Rock's utils
reactNativeVersion: getReactNativeVersion(projectRoot),
usePrebuiltRNCore: false, // for brownfield, it is required to build RN from source
packageDir: path.join(brownieCacheDir, 'package'), // the output directory for artifacts
skipCache: true, // cache is dependent on existence of Rock config file
},
platformConfig
);
})
);
export const packageIosExample = new ExampleUsage(
'package:ios --scheme BrownfieldLib --configuration Release',
"Build iOS XCFramework for 'BrownfieldLib' scheme in Release configuration"
);