Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-native-cli] fixed issue with runIOS not being able to launch tvOS app #17660

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions local-cli/runIOS/__tests__/findMatchingSimulator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,37 @@ describe('findMatchingSimulator', () => {
version: 'iOS 10.0'
});
});

it('should return AppleTV devices if in the list', () => {
expect(findMatchingSimulator({
'devices': {
'tvOS 11.2' : [
{
'state' : 'Booted',
'availability' : '(available)',
'name' : 'Apple TV',
'udid' : '816C30EA-38EA-41AC-BFDA-96FB632D522E'
},
{
'state' : 'Shutdown',
'availability' : '(available)',
'name' : 'Apple TV 4K',
'udid' : 'BCBB7E4B-D872-4D61-BC61-7C9805551075'
},
{
'state' : 'Shutdown',
'availability' : '(available)',
'name' : 'Apple TV 4K (at 1080p)',
'udid' : '1DE12308-1C14-4F0F-991E-A3ADC41BDFFC'
}
]
}
},
'Apple TV'
)).toEqual({
udid: '816C30EA-38EA-41AC-BFDA-96FB632D522E',
name: 'Apple TV',
version: 'tvOS 11.2'
});
});
});
4 changes: 2 additions & 2 deletions local-cli/runIOS/findMatchingSimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function findMatchingSimulator(simulators, simulatorName) {
const devices = simulators.devices;
var match;
for (let version in devices) {
// Making sure the version of the simulator is an iOS (Removes Apple Watch, etc)
if (version.indexOf('iOS') !== 0) {
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
continue;
}
for (let i in devices[version]) {
Expand Down
18 changes: 16 additions & 2 deletions local-cli/runIOS/runIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ const findXcodeProject = require('./findXcodeProject');
const findReactNativeScripts = require('../util/findReactNativeScripts');
const parseIOSDevicesList = require('./parseIOSDevicesList');
const findMatchingSimulator = require('./findMatchingSimulator');
const getBuildPath = function(configuration = 'Debug', appName, isDevice) {
return `build/Build/Products/${configuration}-${isDevice ? 'iphoneos' : 'iphonesimulator'}/${appName}.app`;
const getBuildPath = function (configuration = 'Debug', appName, isDevice) {
let device;

if (isDevice) {
device = 'iphoneos';
} else if (appName.toLowerCase().includes('tvos')) {
device = 'appletvsimulator';
} else {
device = 'iphonesimulator';
}

return `build/Build/Products/${configuration}-${device}/${appName}.app`;
};
const xcprettyAvailable = function() {
try {
Expand Down Expand Up @@ -261,6 +271,10 @@ module.exports = {
desc: "Run on a connected device, e.g. Max's iPhone",
cmd: 'react-native run-ios --device "Max\'s iPhone"',
},
{
desc: 'Run on the AppleTV simulator',
cmd: 'react-native run-ios --simulator "Apple TV" --scheme "helloworld-tvOS"',
}
],
options: [{
command: '--simulator [string]',
Expand Down