Skip to content
8 changes: 6 additions & 2 deletions .ado/templates/react-native-macos-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ steps:
- task: CmdLine@2
displayName: Init new project
inputs:
script: react-native init testcli
script: npx react-native init testcli
workingDirectory: $(Agent.BuildDirectory)

- task: CmdLine@2
Expand All @@ -96,4 +96,8 @@ steps:
script: npx react-native-macos-init --version latest --overwrite --prerelease
workingDirectory: $(Agent.BuildDirectory)/testcli

# TODO: react-native run-macos and test when implemented
- task: CmdLine@2
displayName: Run macos
inputs:
script: npx react-native run-macos
workingDirectory: $(Agent.BuildDirectory)/testcli
12 changes: 8 additions & 4 deletions local-cli/generator-macos/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ function copyProjectTemplateAndReplace(
{ from: path.join(srcRootPath, 'metro.config.macos.js'), to: 'metro.config.macos.js' },
].forEach((mapping) => copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite));

console.log(chalk.white.bold('To run your app on macOS:'));
console.log(chalk.white(` open ${macOSDir}/${xcodeProjName}`));
console.log(chalk.white(' yarn start:macos'));
console.log(chalk.white.bold(`In Xcode switch to the ${projectNameMacOS} scheme then click Run.`));
console.log(`
${chalk.blue(`Run instructions for ${chalk.bold('macOS')}`)}:
• npx react-native run-macos
${chalk.dim('- or -')}
• Open ${macOSDir}/${xcodeProjName} in Xcode or run "xed -b ${macOSDir}"
• yarn start:macos
• Hit the Run button
`);
}

function installDependencies(options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.HelloWorld.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
VERSIONING_SYSTEM = "apple-generic";
};
Expand All @@ -1317,7 +1317,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.HelloWorld.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
VERSIONING_SYSTEM = "apple-generic";
};
Expand All @@ -1337,7 +1337,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.HelloWorld.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
SDKROOT = macosx;
TARGETED_DEVICE_FAMILY = 1;
Expand All @@ -1358,7 +1358,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.HelloWorld.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = HelloWorld;
SDKROOT = macosx;
TARGETED_DEVICE_FAMILY = 1;
Expand Down
37 changes: 37 additions & 0 deletions local-cli/runMacOS/findXcodeProject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
* @format
* @ts-check
*/
'use strict';

const path = require('path');

/**
* @param {string[]} files
*/
function findXcodeProject(files) {
const sortedFiles = files.sort();
for (let i = sortedFiles.length - 1; i >= 0; i--) {
const fileName = files[i];
const ext = path.extname(fileName);

if (ext === '.xcworkspace') {
return {
name: fileName,
isWorkspace: true,
};
}
if (ext === '.xcodeproj') {
return {
name: fileName,
isWorkspace: false,
};
}
}

return null;
}

module.exports = findXcodeProject;
Loading