[generator-macos] Use CocoaPods to build iOS and macOS targets (#298)

* [generator-macos] Import upstream v0.62 template and add macOS target

* [generator-macos] Make targets build using CP

* [generator-macos] Give macOS app localhost access

* [generator-macos] Update pbxproj after pod install

* [generator-macos] Remove last refs to Flipper

* [generator-macos] Revert some unneeded changes

* [CI] Run pod install before run-macos

* [CLI] No longer use legacy build system

* [CLI] Don't try to parse build output
This commit is contained in:
Eloy Durán 2020-04-15 00:24:47 +02:00 коммит произвёл GitHub
Родитель 2cd3cdb164
Коммит 4bbea7cde2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
22 изменённых файлов: 504 добавлений и 1250 удалений

Просмотреть файл

@ -96,6 +96,12 @@ steps:
script: npx react-native-macos-init --version latest --overwrite --prerelease
workingDirectory: $(Agent.BuildDirectory)/testcli
- task: CmdLine@2
displayName: Install pods
inputs:
script: pod install
workingDirectory: $(Agent.BuildDirectory)/testcli/macos
- task: CmdLine@2
displayName: Run macos
inputs:

Просмотреть файл

@ -37,8 +37,10 @@
#endif // TODO(macOS ISS#2323203)
#import "RCTShadowView+Internal.h"
#import "RCTShadowView.h"
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
#import "RCTSurfaceRootShadowView.h"
#import "RCTSurfaceRootView.h"
#endif // TODO(macOS ISS#2323203)
#import "RCTUIManagerObserverCoordinator.h"
#import "RCTUIManagerUtils.h"
#import "RCTUtils.h"

Просмотреть файл

@ -39,11 +39,11 @@ Pod::Spec.new do |s|
# TODO(macOS GH#214)
"**/MacOS/*"
s.osx.exclude_files = "Modules/RCTRedBoxExtraDataViewController.{h,m}",
"Modules/RCTStatusBarManager.*",
"UIUtils/*",
"Profiler/{RCTFPSGraph,RCTPerfMonitor}.*",
"Profiler/RCTProfileTrampoline-{arm,arm64,i386}.S",
"Base/{RCTPlatform,RCTKeyCommands}.*",
"Base/RCTKeyCommands.*",
"Base/RCTPlatform.m",
"Base/Surface/SurfaceHostingView/*",
"Base/Surface/RCTSurface{,Delegate,Root*}.*",
"Base/RCTTV*.*",

Просмотреть файл

@ -1,3 +1,5 @@
// @ts-check
const fs = require('fs');
const chalk = require('chalk');
const path = require('path');
@ -5,12 +7,29 @@ const copyAndReplace = require('@react-native-community/cli/build/tools/copyAndR
const walk = require('@react-native-community/cli/build/tools/walk').default;
const prompt = require('@react-native-community/cli/build/tools/generator/promptSync').default();
/**
* @param {string} destPath
*/
function createDir(destPath) {
if (!fs.existsSync(destPath)) {
fs.mkdirSync(destPath);
fs.mkdirSync(destPath, { recursive: true });
}
}
/**
* @todo Move this upstream to @react-native-community/cli
*
* @param {string} templatePath
* @param {Record<string, string>} replacements
*/
function replaceInPath(templatePath, replacements) {
let result = templatePath;
Object.keys(replacements).forEach(key => {
result = result.replace(key, replacements[key]);
});
return result;
}
function copyAndReplaceWithChangedCallback(srcPath, destRoot, relativeDestPath, replacements, alwaysOverwrite) {
if (!replacements) {
replacements = {};
@ -35,15 +54,23 @@ function copyAndReplaceWithChangedCallback(srcPath, destRoot, relativeDestPath,
);
}
/**
* @param {string} srcPath
* @param {string} destPath
* @param {string} relativeDestDir
* @param {Record<string, string>} replacements
* @param {boolean} alwaysOverwrite
*/
function copyAndReplaceAll(srcPath, destPath, relativeDestDir, replacements, alwaysOverwrite) {
walk(srcPath).forEach(absoluteSrcFilePath => {
const filename = path.relative(srcPath, absoluteSrcFilePath);
const relativeDestPath = path.join(relativeDestDir, filename);
const relativeDestPath = path.join(relativeDestDir, replaceInPath(filename, replacements));
copyAndReplaceWithChangedCallback(absoluteSrcFilePath, destPath, relativeDestPath, replacements, alwaysOverwrite);
});
}
function alwaysOverwriteContentChangedCallback( absoluteSrcFilePath,
function alwaysOverwriteContentChangedCallback(
absoluteSrcFilePath,
relativeDestPath,
contentChanged
) {

Просмотреть файл

@ -1,4 +1,7 @@
// @ts-check
'use strict';
const chalk = require('chalk');
const path = require('path');
const childProcess = require('child_process');
@ -10,7 +13,14 @@ const {
} = require('../generator-common');
const macOSDir = 'macos';
const oldProjectName = 'HelloWorld';
/**
* @param {string} srcRootPath
* @param {string} destPath
* @param {string} newProjectName
* @param {{ overwrite?: boolean }} options
*/
function copyProjectTemplateAndReplace(
srcRootPath,
destPath,
@ -29,29 +39,23 @@ function copyProjectTemplateAndReplace(
throw new Error('Need a project name');
}
const projectNameMacOS = newProjectName + '-macOS';
const projectNameIOS = newProjectName;
const xcodeProjName = newProjectName + '.xcodeproj';
const schemeNameMacOS = newProjectName + '-macOS.xcscheme';
const schemeNameIOS = newProjectName + '.xcscheme';
createDir(path.join(destPath, macOSDir));
createDir(path.join(destPath, macOSDir, projectNameIOS));
createDir(path.join(destPath, macOSDir, projectNameMacOS));
createDir(path.join(destPath, macOSDir, xcodeProjName));
createDir(path.join(destPath, macOSDir, xcodeProjName, 'xcshareddata'));
createDir(path.join(destPath, macOSDir, xcodeProjName, 'xcshareddata/xcschemes'));
createDir(path.join(destPath, srcDirPath(newProjectName, 'iOS')));
createDir(path.join(destPath, srcDirPath(newProjectName, 'macOS')));
createDir(path.join(destPath, xcodeprojPath(newProjectName)));
createDir(path.join(destPath, schemesPath(newProjectName)));
const templateVars = {
'HelloWorld': newProjectName,
[oldProjectName]: newProjectName,
};
[
{ from: path.join(srcRootPath, 'macos/HelloWorld'), to: path.join(macOSDir, projectNameIOS) },
{ from: path.join(srcRootPath, 'macos/HelloWorld-macOS'), to: path.join(macOSDir, projectNameMacOS) },
{ from: path.join(srcRootPath, 'macos/HelloWorld.xcodeproj'), to: path.join(macOSDir, xcodeProjName) },
{ from: path.join(srcRootPath, 'macos/xcschemes/HelloWorld-macOS.xcscheme'), to: path.join(macOSDir, xcodeProjName, 'xcshareddata/xcschemes', schemeNameMacOS) },
{ from: path.join(srcRootPath, 'macos/xcschemes/HelloWorld.xcscheme'), to: path.join(macOSDir, xcodeProjName, 'xcshareddata/xcschemes', schemeNameIOS) },
{ from: path.join(srcRootPath, macOSDir, 'Podfile'), to: path.join(macOSDir, 'Podfile') },
{ from: path.join(srcRootPath, srcDirPath(oldProjectName, 'iOS')), to: srcDirPath(newProjectName, 'iOS') },
{ from: path.join(srcRootPath, srcDirPath(oldProjectName, 'macOS')), to: srcDirPath(newProjectName, 'macOS') },
{ from: path.join(srcRootPath, pbxprojPath(oldProjectName)), to: pbxprojPath(newProjectName) },
{ from: path.join(srcRootPath, schemePath(oldProjectName, 'iOS')), to: schemePath(newProjectName, 'iOS') },
{ from: path.join(srcRootPath, schemePath(oldProjectName, 'macOS')), to: schemePath(newProjectName, 'macOS') },
].forEach((mapping) => copyAndReplaceAll(mapping.from, destPath, mapping.to, templateVars, options.overwrite));
[
@ -61,14 +65,70 @@ function copyProjectTemplateAndReplace(
console.log(`
${chalk.blue(`Run instructions for ${chalk.bold('macOS')}`)}:
cd macos && pod install && cd ..
npx react-native run-macos
${chalk.dim('- or -')}
Open ${macOSDir}/${xcodeProjName} in Xcode or run "xed -b ${macOSDir}"
Open ${xcworkspacePath(newProjectName)} in Xcode or run "xed -b ${macOSDir}"
yarn start:macos
Hit the Run button
`);
}
/**
* @param {string} basename
* @param {"iOS" | "macOS"} platform
*/
function projectName(basename, platform) {
return basename + '-' + platform;
}
/**
* @param {string} basename
* @param {"iOS" | "macOS"} platform
*/
function srcDirPath(basename, platform) {
return path.join(macOSDir, projectName(basename, platform));
}
/**
* @param {string} basename
*/
function xcodeprojPath(basename) {
return path.join(macOSDir, basename + '.xcodeproj');
}
/**
* @param {string} basename
*/
function xcworkspacePath(basename) {
return path.join(macOSDir, basename + '.xcworkspace');
}
/**
* @param {string} basename
*/
function pbxprojPath(basename) {
return path.join(xcodeprojPath(basename), 'project.pbxproj');
}
/**
* @param {string} basename
*/
function schemesPath(basename) {
return path.join(xcodeprojPath(basename), 'xcshareddata', 'xcschemes');
}
/**
* @param {string} basename
* @param {"iOS" | "macOS"} platform
*/
function schemePath(basename, platform) {
return path.join(schemesPath(basename), projectName(basename, platform) + '.xcscheme');
}
/**
* @param {{ verbose?: boolean }=} options
*/
function installDependencies(options) {
const cwd = process.cwd();
@ -80,6 +140,8 @@ function installDependencies(options) {
// Install dependencies using correct package manager
const isYarn = fs.existsSync(path.join(cwd, 'yarn.lock'));
/** @type {{ stdio?: 'inherit' }} */
const execOptions = options && options.verbose ? { stdio: 'inherit' } : {};
childProcess.execSync(isYarn ? 'yarn' : 'npm i', execOptions);
}

Просмотреть файл

@ -1,15 +1,5 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
@ -39,11 +29,6 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {

Просмотреть файл

@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>HelloWorld</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>

Просмотреть файл

@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

Просмотреть файл

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
</dependencies>
<scenes>
<!--Application-->
@ -526,19 +524,22 @@
<menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title=" Default" id="YGs-j5-SAR">
<menuItem id="YGs-j5-SAR">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionNatural:" target="Ady-hI-5gd" id="qtV-5e-UBP"/>
</connections>
</menuItem>
<menuItem title=" Left to Right" id="Lbh-J2-qVU">
<menuItem id="Lbh-J2-qVU">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="S0X-9S-QSf"/>
</connections>
</menuItem>
<menuItem title=" Right to Left" id="jFq-tB-4Kx">
<menuItem id="jFq-tB-4Kx">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="5fk-qB-AqJ"/>
@ -548,19 +549,22 @@
<menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title=" Default" id="Nop-cj-93Q">
<menuItem id="Nop-cj-93Q">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionNatural:" target="Ady-hI-5gd" id="lPI-Se-ZHp"/>
</connections>
</menuItem>
<menuItem title=" Left to Right" id="BgM-ve-c93">
<menuItem id="BgM-ve-c93">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionLeftToRight:" target="Ady-hI-5gd" id="caW-Bv-w94"/>
</connections>
</menuItem>
<menuItem title=" Right to Left" id="RB4-Sm-HuC">
<menuItem id="RB4-Sm-HuC">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionRightToLeft:" target="Ady-hI-5gd" id="EXD-6r-ZUu"/>
@ -669,7 +673,7 @@
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider=""/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
@ -679,10 +683,10 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="HelloWorld" allowsToolTipsWhenApplicationIsInactive="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="HelloWorld" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="720"/>
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
@ -694,20 +698,20 @@
</windowController>
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="467"/>
<point key="canvasLocation" x="75" y="250"/>
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" sceneMemberID="viewController">
<view key="view" wantsLayer="YES" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="720"/>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="640" y="467"/>
<point key="canvasLocation" x="75" y="655"/>
</scene>
</scenes>
</document>

Просмотреть файл

@ -2,9 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

Просмотреть файл

@ -15,7 +15,7 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
@ -23,21 +23,25 @@
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
</dict>
</plist>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,25 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1120"
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
BuildableName = "libReact.a"
BlueprintName = "React"
ReferencedContainer = "container:../node_modules/react-native-macos/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
@ -30,7 +16,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld"
BlueprintName = "HelloWorld-iOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>
</BuildActionEntry>
@ -60,7 +46,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld"
BlueprintName = "HelloWorld-iOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
@ -77,7 +63,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld"
BlueprintName = "HelloWorld-iOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>

Просмотреть файл

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1120"
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "NO"
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
@ -14,22 +14,8 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6B857DA21EC51FC600A9D063"
BuildableName = "libReact.a"
BlueprintName = "React-macOS"
ReferencedContainer = "container:../node_modules/react-native-macos/React/React.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38C1415723BBE33000902604"
BuildableName = "HelloWorld-macOS.app"
BlueprintIdentifier = "514201482437B4B30078DB4F"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld-macOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>
@ -58,8 +44,8 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38C1415723BBE33000902604"
BuildableName = "HelloWorld-macOS.app"
BlueprintIdentifier = "514201482437B4B30078DB4F"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld-macOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>
@ -75,8 +61,8 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "38C1415723BBE33000902604"
BuildableName = "HelloWorld-macOS.app"
BlueprintIdentifier = "514201482437B4B30078DB4F"
BuildableName = "HelloWorld.app"
BlueprintName = "HelloWorld-macOS"
ReferencedContainer = "container:HelloWorld.xcodeproj">
</BuildableReference>

Просмотреть файл

@ -0,0 +1,40 @@
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
abstract_target 'Shared' do
# use_native_modules!
pod 'React', :path => "../node_modules/react-native-macos/"
pod 'React-Core', :path => "../node_modules/react-native-macos/React"
pod 'React-fishhook', :path => "../node_modules/react-native-macos/Libraries/fishhook"
pod 'React-RCTActionSheet', :path => "../node_modules/react-native-macos/Libraries/ActionSheetIOS"
pod 'React-RCTAnimation', :path => "../node_modules/react-native-macos/Libraries/NativeAnimation"
pod 'React-RCTBlob', :path => "../node_modules/react-native-macos/Libraries/Blob"
pod 'React-RCTImage', :path => "../node_modules/react-native-macos/Libraries/Image"
pod 'React-RCTLinking', :path => "../node_modules/react-native-macos/Libraries/LinkingIOS"
pod 'React-RCTNetwork', :path => "../node_modules/react-native-macos/Libraries/Network"
pod 'React-RCTSettings', :path => "../node_modules/react-native-macos/Libraries/Settings"
pod 'React-RCTText', :path => "../node_modules/react-native-macos/Libraries/Text"
pod 'React-RCTVibration', :path => "../node_modules/react-native-macos/Libraries/Vibration"
pod 'React-RCTWebSocket', :path => "../node_modules/react-native-macos/Libraries/WebSocket"
pod 'React-cxxreact', :path => "../node_modules/react-native-macos/ReactCommon/cxxreact"
pod 'React-jscallinvoker', :path => "../node_modules/react-native-macos/ReactCommon/jscallinvoker"
pod 'React-jsi', :path => "../node_modules/react-native-macos/ReactCommon/jsi"
pod 'React-jsiexecutor', :path => "../node_modules/react-native-macos/ReactCommon/jsiexecutor"
pod 'React-jsinspector', :path => "../node_modules/react-native-macos/ReactCommon/jsinspector"
pod 'yoga', :path => "../node_modules/react-native-macos/ReactCommon/yoga"
pod 'DoubleConversion', :podspec => "../node_modules/react-native-macos/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "../node_modules/react-native-macos/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "../node_modules/react-native-macos/third-party-podspecs/Folly.podspec"
pod 'boost-for-react-native', :podspec => "../node_modules/react-native-macos/third-party-podspecs/boost-for-react-native.podspec"
pod 'React-DevSupport', :path => "../node_modules/react-native-macos/React"
target 'HelloWorld-macOS' do
platform :macos, '10.14'
# Pods specifically for macOS target
end
target 'HelloWorld-iOS' do
platform :ios, '9'
# Pods specifically for iOS target
end
end

Просмотреть файл

@ -58,23 +58,26 @@ function runMacOS(_, ctx, args) {
* @param {{configuration: string, scheme?: string, projectPath: string, packager: boolean, verbose: boolean, port: number, terminal: string | undefined}} args
*/
async function run(xcodeProject, scheme, args) {
const appName = await buildProject(xcodeProject, scheme, args);
await buildProject(xcodeProject, scheme, args);
const appPath = getBuildPath(
const buildSettings = getBuildSettings(
xcodeProject,
args.configuration,
appName,
scheme,
);
const appPath = path.join(
buildSettings.TARGET_BUILD_DIR,
buildSettings.FULL_PRODUCT_NAME,
);
const infoPlistPath = path.join(
buildSettings.TARGET_BUILD_DIR,
buildSettings.INFOPLIST_PATH,
);
const bundleID = child_process
.execFileSync(
'/usr/libexec/PlistBuddy',
[
'-c',
'Print:CFBundleIdentifier',
path.join(appPath, 'Contents/Info.plist'),
],
['-c', 'Print:CFBundleIdentifier', infoPlistPath],
{encoding: 'utf8'},
)
.trim();
@ -109,7 +112,6 @@ function buildProject(xcodeProject, scheme, args) {
args.configuration,
'-scheme',
scheme,
'-UseModernBuildSystem=NO',
];
logger.info(
`Building ${chalk.dim(
@ -168,67 +170,46 @@ function buildProject(xcodeProject, scheme, args) {
);
return;
}
resolve(getProductName(buildOutput) || scheme);
resolve();
});
});
}
/**
* @param {string} buildSettings
* @param {{name: string, isWorkspace: boolean}} xcodeProject
* @param {string} configuration
* @param {string} scheme
* @returns {{ FULL_PRODUCT_NAME: string, INFOPLIST_PATH: string, TARGET_BUILD_DIR: string }}
*/
function getTargetBuildDir(buildSettings) {
const settings = JSON.parse(buildSettings);
function getBuildSettings(xcodeProject, configuration, scheme) {
const settings = JSON.parse(
child_process.execFileSync(
'xcodebuild',
[
xcodeProject.isWorkspace ? '-workspace' : '-project',
xcodeProject.name,
'-scheme',
scheme,
'-sdk',
'macosx',
'-configuration',
configuration,
'-showBuildSettings',
'-json',
],
{encoding: 'utf8'},
),
);
// Find app in all building settings - look for WRAPPER_EXTENSION: 'app',
for (const i in settings) {
const wrapperExtension = settings[i].buildSettings.WRAPPER_EXTENSION;
if (wrapperExtension === 'app') {
return settings[i].buildSettings.TARGET_BUILD_DIR;
const appSettings = settings[i].buildSettings;
if (appSettings.WRAPPER_EXTENSION === 'app') {
return appSettings;
}
}
return null;
}
/**
* @param {{name: string, isWorkspace: boolean}} xcodeProject
* @param {string} configuration
* @param {string} appName
* @param {string} scheme
*/
function getBuildPath(xcodeProject, configuration, appName, scheme) {
const buildSettings = child_process.execFileSync(
'xcodebuild',
[
xcodeProject.isWorkspace ? '-workspace' : '-project',
xcodeProject.name,
'-scheme',
scheme,
'-sdk',
'macosx',
'-configuration',
configuration,
'-showBuildSettings',
'-json',
],
{encoding: 'utf8'},
);
const targetBuildDir = getTargetBuildDir(buildSettings);
if (!targetBuildDir) {
throw new CLIError('Failed to get the target build directory.');
}
return `${targetBuildDir}/${appName}.app`;
}
/**
* @param {string} buildOutput
*/
function getProductName(buildOutput) {
const productNameMatch = /export FULL_PRODUCT_NAME="?(.+).app"?$/m.exec(
buildOutput,
);
return productNameMatch ? productNameMatch[1] : null;
throw new CLIError('Failed to get the target build settings.');
}
function xcprettyAvailable() {