react-native-macos 0.75.1 → 0.75.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/Libraries/Core/ReactNativeVersion.js +1 -1
  2. package/React/Base/RCTVersion.m +1 -1
  3. package/ReactAndroid/gradle.properties +1 -1
  4. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  5. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  6. package/local-cli/cli.js +18 -0
  7. package/local-cli/generate-macos.js +38 -0
  8. package/local-cli/generator-common/index.js +384 -0
  9. package/local-cli/generator-macos/index.js +153 -0
  10. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/AppDelegate.h +6 -0
  11. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/AppDelegate.mm +40 -0
  12. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  13. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/Assets.xcassets/Contents.json +6 -0
  14. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/Base.lproj/Main.storyboard +684 -0
  15. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/HelloWorld.entitlements +12 -0
  16. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/Info.plist +47 -0
  17. package/local-cli/generator-macos/templates/macos/HelloWorld-macOS/main.m +5 -0
  18. package/local-cli/generator-macos/templates/macos/HelloWorld.xcodeproj/project.pbxproj +536 -0
  19. package/local-cli/generator-macos/templates/macos/HelloWorld.xcodeproj/xcshareddata/xcschemes/HelloWorld-iOS.xcscheme +78 -0
  20. package/local-cli/generator-macos/templates/macos/HelloWorld.xcodeproj/xcshareddata/xcschemes/HelloWorld-macOS.xcscheme +78 -0
  21. package/local-cli/generator-macos/templates/macos/Podfile +26 -0
  22. package/local-cli/generator-macos/templates/macos/_gitignore +2 -0
  23. package/local-cli/runMacOS/findXcodeProject.js +37 -0
  24. package/local-cli/runMacOS/runMacOS.js +329 -0
  25. package/package.json +2 -1
@@ -0,0 +1,78 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Scheme
3
+ LastUpgradeVersion = "1140"
4
+ version = "1.3">
5
+ <BuildAction
6
+ parallelizeBuildables = "YES"
7
+ buildImplicitDependencies = "YES">
8
+ <BuildActionEntries>
9
+ <BuildActionEntry
10
+ buildForTesting = "YES"
11
+ buildForRunning = "YES"
12
+ buildForProfiling = "YES"
13
+ buildForArchiving = "YES"
14
+ buildForAnalyzing = "YES">
15
+ <BuildableReference
16
+ BuildableIdentifier = "primary"
17
+ BlueprintIdentifier = "514201482437B4B30078DB4F"
18
+ BuildableName = "HelloWorld.app"
19
+ BlueprintName = "HelloWorld-macOS"
20
+ ReferencedContainer = "container:HelloWorld.xcodeproj">
21
+ </BuildableReference>
22
+ </BuildActionEntry>
23
+ </BuildActionEntries>
24
+ </BuildAction>
25
+ <TestAction
26
+ buildConfiguration = "Debug"
27
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
+ shouldUseLaunchSchemeArgsEnv = "YES">
30
+ <Testables>
31
+ </Testables>
32
+ </TestAction>
33
+ <LaunchAction
34
+ buildConfiguration = "Debug"
35
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37
+ launchStyle = "0"
38
+ useCustomWorkingDirectory = "NO"
39
+ ignoresPersistentStateOnLaunch = "NO"
40
+ debugDocumentVersioning = "YES"
41
+ debugServiceExtension = "internal"
42
+ allowLocationSimulation = "YES">
43
+ <BuildableProductRunnable
44
+ runnableDebuggingMode = "0">
45
+ <BuildableReference
46
+ BuildableIdentifier = "primary"
47
+ BlueprintIdentifier = "514201482437B4B30078DB4F"
48
+ BuildableName = "HelloWorld.app"
49
+ BlueprintName = "HelloWorld-macOS"
50
+ ReferencedContainer = "container:HelloWorld.xcodeproj">
51
+ </BuildableReference>
52
+ </BuildableProductRunnable>
53
+ </LaunchAction>
54
+ <ProfileAction
55
+ buildConfiguration = "Release"
56
+ shouldUseLaunchSchemeArgsEnv = "YES"
57
+ savedToolIdentifier = ""
58
+ useCustomWorkingDirectory = "NO"
59
+ debugDocumentVersioning = "YES">
60
+ <BuildableProductRunnable
61
+ runnableDebuggingMode = "0">
62
+ <BuildableReference
63
+ BuildableIdentifier = "primary"
64
+ BlueprintIdentifier = "514201482437B4B30078DB4F"
65
+ BuildableName = "HelloWorld.app"
66
+ BlueprintName = "HelloWorld-macOS"
67
+ ReferencedContainer = "container:HelloWorld.xcodeproj">
68
+ </BuildableReference>
69
+ </BuildableProductRunnable>
70
+ </ProfileAction>
71
+ <AnalyzeAction
72
+ buildConfiguration = "Debug">
73
+ </AnalyzeAction>
74
+ <ArchiveAction
75
+ buildConfiguration = "Release"
76
+ revealArchiveInOrganizer = "YES">
77
+ </ArchiveAction>
78
+ </Scheme>
@@ -0,0 +1,26 @@
1
+ require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
2
+ require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3
+
4
+ prepare_react_native_project!
5
+
6
+ target 'HelloWorld-macOS' do
7
+ platform :macos, '11.0'
8
+ use_native_modules!
9
+
10
+ # Flags change depending on the env values.
11
+ flags = get_default_flags()
12
+
13
+ use_react_native!(
14
+ :path => '../node_modules/react-native-macos',
15
+ :hermes_enabled => false,
16
+ :fabric_enabled => ENV['RCT_NEW_ARCH_ENABLED'] == '1',
17
+ # Flipper is not compatible w/ macOS
18
+ :flipper_configuration => FlipperConfiguration.disabled,
19
+ # An absolute path to your application root.
20
+ :app_path => "#{Pod::Config.instance.installation_root}/.."
21
+ )
22
+
23
+ post_install do |installer|
24
+ react_native_post_install(installer)
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ # CocoaPods
2
+ Pods/
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ * @ts-check
6
+ */
7
+ 'use strict';
8
+
9
+ const path = require('path');
10
+
11
+ /**
12
+ * @param {string[]} files
13
+ */
14
+ function findXcodeProject(files) {
15
+ const sortedFiles = files.sort();
16
+ for (let i = sortedFiles.length - 1; i >= 0; i--) {
17
+ const fileName = files[i];
18
+ const ext = path.extname(fileName);
19
+
20
+ if (ext === '.xcworkspace') {
21
+ return {
22
+ name: fileName,
23
+ isWorkspace: true,
24
+ };
25
+ }
26
+ if (ext === '.xcodeproj') {
27
+ return {
28
+ name: fileName,
29
+ isWorkspace: false,
30
+ };
31
+ }
32
+ }
33
+
34
+ return null;
35
+ }
36
+
37
+ module.exports = findXcodeProject;
@@ -0,0 +1,329 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ * @ts-check
6
+ */
7
+ 'use strict';
8
+
9
+ /**
10
+ * @typedef {{
11
+ * configuration: string;
12
+ * mode: string;
13
+ * packager: boolean;
14
+ * port: number;
15
+ * projectPath: string;
16
+ * scheme?: string;
17
+ * terminal: string | undefined;
18
+ * verbose: boolean;
19
+ * }} Options
20
+ *
21
+ * @typedef {{
22
+ * name: string;
23
+ * isWorkspace: boolean;
24
+ * }} XcodeProject
25
+ */
26
+
27
+ const findXcodeProject = require('./findXcodeProject');
28
+ const chalk = require('chalk');
29
+ const child_process = require('child_process');
30
+ const fs = require('fs');
31
+ const path = require('path');
32
+ const {logger, CLIError, getDefaultUserTerminal} = (() => {
33
+ const cli = require.resolve('@react-native-community/cli/package.json');
34
+ const options = {paths: [path.dirname(cli)]};
35
+ const tools = require.resolve('@react-native-community/cli-tools', options);
36
+ return require(tools);
37
+ })();
38
+
39
+ /**
40
+ * @param {string[]} _
41
+ * @param {Record<string, unknown>} _ctx
42
+ * @param {Options} args
43
+ */
44
+ function runMacOS(_, _ctx, args) {
45
+ if (!fs.existsSync(args.projectPath)) {
46
+ throw new CLIError(
47
+ 'macOS project folder not found. Are you sure this is a React Native project?',
48
+ );
49
+ }
50
+
51
+ if (args.configuration) {
52
+ logger.warn(
53
+ 'Argument --configuration has been deprecated and will be removed in a future release, please use --mode instead.',
54
+ );
55
+
56
+ if (!args.mode) {
57
+ args.mode = args.configuration;
58
+ }
59
+ }
60
+
61
+ process.chdir(args.projectPath);
62
+
63
+ const xcodeProject = findXcodeProject(fs.readdirSync('.'));
64
+ if (!xcodeProject) {
65
+ throw new CLIError(
66
+ `Could not find Xcode project files in "${args.projectPath}" folder`,
67
+ );
68
+ }
69
+
70
+ const inferredSchemeName =
71
+ path.basename(xcodeProject.name, path.extname(xcodeProject.name)) +
72
+ '-macOS';
73
+ const scheme = args.scheme || inferredSchemeName;
74
+
75
+ logger.info(
76
+ `Found Xcode ${
77
+ xcodeProject.isWorkspace ? 'workspace' : 'project'
78
+ } "${chalk.bold(xcodeProject.name)}"`,
79
+ );
80
+
81
+ return run(xcodeProject, scheme, args);
82
+ }
83
+
84
+ /**
85
+ * @param {XcodeProject} xcodeProject
86
+ * @param {string} scheme
87
+ * @param {Options} args
88
+ */
89
+ async function run(xcodeProject, scheme, args) {
90
+ await buildProject(xcodeProject, scheme, args);
91
+
92
+ const buildSettings = getBuildSettings(xcodeProject, args.mode, scheme);
93
+ const appPath = path.join(
94
+ buildSettings.TARGET_BUILD_DIR,
95
+ buildSettings.FULL_PRODUCT_NAME,
96
+ );
97
+ const infoPlistPath = path.join(
98
+ buildSettings.TARGET_BUILD_DIR,
99
+ buildSettings.INFOPLIST_PATH,
100
+ );
101
+
102
+ const bundleID = child_process
103
+ .execFileSync(
104
+ '/usr/libexec/PlistBuddy',
105
+ ['-c', 'Print:CFBundleIdentifier', infoPlistPath],
106
+ {encoding: 'utf8'},
107
+ )
108
+ .trim();
109
+
110
+ logger.info(
111
+ `Launching app "${chalk.bold(bundleID)}" from "${chalk.bold(appPath)}"`,
112
+ );
113
+
114
+ child_process.exec(
115
+ 'open -b ' + bundleID + ' -a ' + '"' + appPath + '"',
116
+ (error, stdout, stderr) => {
117
+ if (error) {
118
+ logger.error('Failed to launch the app', stderr);
119
+ } else {
120
+ logger.success('Successfully launched the app');
121
+ }
122
+ },
123
+ );
124
+ }
125
+
126
+ /**
127
+ * @param {XcodeProject} xcodeProject
128
+ * @param {string} scheme
129
+ * @param {Options} args
130
+ */
131
+ function buildProject(xcodeProject, scheme, args) {
132
+ return new Promise((resolve, reject) => {
133
+ const xcodebuildArgs = [
134
+ xcodeProject.isWorkspace ? '-workspace' : '-project',
135
+ xcodeProject.name,
136
+ '-configuration',
137
+ args.mode,
138
+ '-scheme',
139
+ scheme,
140
+ ];
141
+ logger.info(
142
+ `Building ${chalk.dim(
143
+ `(using "xcodebuild ${xcodebuildArgs.join(' ')}")`,
144
+ )}`,
145
+ );
146
+ let xcpretty;
147
+ if (!args.verbose) {
148
+ xcpretty =
149
+ xcprettyAvailable() &&
150
+ child_process.spawn('xcpretty', [], {
151
+ stdio: ['pipe', process.stdout, process.stderr],
152
+ });
153
+ }
154
+ const buildProcess = child_process.spawn(
155
+ 'xcodebuild',
156
+ xcodebuildArgs,
157
+ getProcessOptions(args),
158
+ );
159
+ let buildOutput = '';
160
+ let errorOutput = '';
161
+ buildProcess.stdout.on('data', data => {
162
+ const stringData = data.toString();
163
+ buildOutput += stringData;
164
+ if (xcpretty) {
165
+ xcpretty.stdin.write(data);
166
+ } else {
167
+ if (logger.isVerbose()) {
168
+ logger.debug(stringData);
169
+ } else {
170
+ process.stdout.write('.');
171
+ }
172
+ }
173
+ });
174
+ buildProcess.stderr.on('data', data => {
175
+ errorOutput += data;
176
+ });
177
+ buildProcess.on('close', code => {
178
+ if (xcpretty) {
179
+ xcpretty.stdin.end();
180
+ } else {
181
+ process.stdout.write('\n');
182
+ }
183
+ if (code !== 0) {
184
+ reject(
185
+ new CLIError(
186
+ `
187
+ Failed to build macOS project.
188
+
189
+ We ran "xcodebuild" command but it exited with error code ${code}. To debug build
190
+ logs further, consider building your app with Xcode.app, by opening
191
+ ${xcodeProject.name}.
192
+ `,
193
+ buildOutput + '\n' + errorOutput,
194
+ ),
195
+ );
196
+ return;
197
+ }
198
+ resolve();
199
+ });
200
+ });
201
+ }
202
+
203
+ /**
204
+ * @param {XcodeProject} xcodeProject
205
+ * @param {string} configuration
206
+ * @param {string} scheme
207
+ * @returns {{ FULL_PRODUCT_NAME: string, INFOPLIST_PATH: string, TARGET_BUILD_DIR: string }}
208
+ */
209
+ function getBuildSettings(xcodeProject, configuration, scheme) {
210
+ const settings = JSON.parse(
211
+ child_process.execFileSync(
212
+ 'xcodebuild',
213
+ [
214
+ xcodeProject.isWorkspace ? '-workspace' : '-project',
215
+ xcodeProject.name,
216
+ '-scheme',
217
+ scheme,
218
+ '-sdk',
219
+ 'macosx',
220
+ '-configuration',
221
+ configuration,
222
+ '-showBuildSettings',
223
+ '-json',
224
+ ],
225
+ {encoding: 'utf8'},
226
+ ),
227
+ );
228
+
229
+ // Find app in all building settings - look for WRAPPER_EXTENSION: 'app',
230
+ for (const i in settings) {
231
+ const appSettings = settings[i].buildSettings;
232
+ if (appSettings.WRAPPER_EXTENSION === 'app') {
233
+ return appSettings;
234
+ }
235
+ }
236
+
237
+ throw new CLIError('Failed to get the target build settings.');
238
+ }
239
+
240
+ function xcprettyAvailable() {
241
+ try {
242
+ child_process.execSync('xcpretty --version', {
243
+ stdio: [0, 'pipe', 'ignore'],
244
+ });
245
+ } catch (error) {
246
+ return false;
247
+ }
248
+ return true;
249
+ }
250
+
251
+ /**
252
+ * @param {Options} args
253
+ * @returns {import('child_process').ProcessEnvOptions}
254
+ */
255
+ function getProcessOptions({packager, terminal, port}) {
256
+ if (packager) {
257
+ return {
258
+ env: {
259
+ ...process.env,
260
+ RCT_TERMINAL: terminal,
261
+ RCT_METRO_PORT: port.toString(),
262
+ },
263
+ };
264
+ }
265
+
266
+ return {
267
+ env: {
268
+ ...process.env,
269
+ RCT_TERMINAL: terminal,
270
+ RCT_NO_LAUNCH_PACKAGER: 'true',
271
+ },
272
+ };
273
+ }
274
+
275
+ module.exports = {
276
+ name: 'run-macos',
277
+ description: 'builds your app and starts it',
278
+ func: runMacOS,
279
+ examples: [
280
+ {
281
+ desc: 'Run the macOS app',
282
+ cmd: 'react-native run-macos',
283
+ },
284
+ ],
285
+ options: [
286
+ {
287
+ name: '--configuration [string]',
288
+ description:
289
+ '[Deprecated] Explicitly set the scheme configuration to use',
290
+ default: 'Debug',
291
+ },
292
+ {
293
+ name: '--mode [string]',
294
+ description:
295
+ 'Explicitly set the scheme configuration to use, corresponds to `--configuration` in `xcodebuild` command, e.g. Debug, Release.',
296
+ },
297
+ {
298
+ name: '--scheme [string]',
299
+ description:
300
+ 'Explicitly set Xcode scheme to use, corresponds to `--scheme` in `xcodebuild` command.',
301
+ },
302
+ {
303
+ name: '--project-path [string]',
304
+ description:
305
+ 'Path relative to project root where the Xcode project ' +
306
+ '(.xcodeproj) lives.',
307
+ default: 'macos',
308
+ },
309
+ {
310
+ name: '--no-packager',
311
+ description: 'Do not launch packager while building',
312
+ },
313
+ {
314
+ name: '--verbose',
315
+ description: 'Do not use xcpretty even if installed',
316
+ },
317
+ {
318
+ name: '--port [number]',
319
+ default: process.env.RCT_METRO_PORT || 8081,
320
+ parse: val => Number(val),
321
+ },
322
+ {
323
+ name: '--terminal [string]',
324
+ description:
325
+ 'Launches the Metro Bundler in a new window using the specified terminal path.',
326
+ default: getDefaultUserTerminal,
327
+ },
328
+ ],
329
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.75.1",
3
+ "version": "0.75.2",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "jest",
45
45
  "Libraries",
46
46
  "LICENSE",
47
+ "local-cli",
47
48
  "React-Core.podspec",
48
49
  "react-native.config.js",
49
50
  "React.podspec",