Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/blue-dingos-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rnef/platform-apple-helpers': patch
---

fix: always use udid from matched device
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const buildProject = async ({
scheme,
configuration,
args,
deviceName,
}: {
xcodeProject: XcodeProjectInfo;
sourceDir: string;
Expand All @@ -81,6 +82,7 @@ export const buildProject = async ({
scheme: string;
configuration: string;
args: RunFlags | BuildFlags;
deviceName?: string;
}) => {
const simulatorDest = simulatorDestinationMap[platformName];

Expand All @@ -106,17 +108,6 @@ export const buildProject = async ({
}
}

if ('device' in args && args.device) {
// Check if the device argument looks like a UDID (assuming UDIDs are alphanumeric and have specific length)
const isUDID = /^[A-Fa-f0-9-]{25,}$/.test(args.device);
if (isUDID) {
return [`id=${args.device}`];
} else {
// If it's a device name
return [`name=${args.device}`];
}
}

if ('catalyst' in args && args.catalyst) {
return ['platform=macOS,variant=Mac Catalyst'];
}
Expand All @@ -125,6 +116,10 @@ export const buildProject = async ({
return [`id=${udid}`];
}

if (deviceName) {
return [`name=${deviceName}`];
}

return [`generic/platform=${platformName}`];
}

Expand Down
17 changes: 14 additions & 3 deletions packages/platform-apple-helpers/src/lib/commands/run/createRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const createRun = async (
if (!args.binaryPath && args.remoteCache) {
const cachedBuild = await fetchCachedBuild({
configuration: args.configuration ?? 'Debug',
distribution: args.destination ?? (args.device ? 'device' : 'simulator'),
distribution: args.destination ?? 'simulator',
remoteCacheProvider,
root: projectRoot,
fingerprintOptions,
Expand All @@ -54,13 +54,24 @@ export const createRun = async (

validateArgs(args, projectRoot);

// Check if the device argument looks like a UDID
// (assuming UDIDs are alphanumeric and have specific length)
const udid =
args.device && /^[A-Fa-f0-9-]{25,}$/.test(args.device)
? args.device
: undefined;

const deviceName = udid ? undefined : args.device;

if (platformName === 'macos') {
const { appPath } = await buildApp({
args,
projectConfig,
platformName,
platformSDK: getSimulatorPlatformSDK(platformName),
projectRoot,
udid,
deviceName,
});
await runOnMac(appPath);
return;
Expand All @@ -71,6 +82,8 @@ export const createRun = async (
platformName,
platformSDK: getSimulatorPlatformSDK(platformName),
projectRoot,
udid,
deviceName,
});
if (scheme) {
await runOnMacCatalyst(appPath, scheme);
Expand Down Expand Up @@ -172,8 +185,6 @@ async function selectDevice(devices: Device[], args: RunFlags) {
logger.warn(
`No devices or simulators found matching "${args.device}". Falling back to default simulator.`
);
// setting device to undefined to avoid buildProject to use it
args.device = undefined;
}
return device;
}
Expand Down
9 changes: 8 additions & 1 deletion packages/platform-apple-helpers/src/lib/utils/buildApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export async function buildApp({
platformSDK,
udid,
projectRoot,
deviceName,
}: {
args: RunFlags | BuildFlags;
projectConfig: ProjectConfig;
pluginConfig?: IOSProjectConfig;
platformName: ApplePlatform;
platformSDK: PlatformSDK;
udid?: string;
deviceName?: string;
projectRoot: string;
}) {
if ('binaryPath' in args && args.binaryPath) {
Expand All @@ -54,7 +56,11 @@ export async function buildApp({
// because running pods install might have generated .xcworkspace project.
// This should be only case in new project.
if (xcodeProject.isWorkspace === false) {
const newProjectConfig = getValidProjectConfig(platformName, projectRoot, pluginConfig);
const newProjectConfig = getValidProjectConfig(
platformName,
projectRoot,
pluginConfig
);
xcodeProject = newProjectConfig.xcodeProject;
sourceDir = newProjectConfig.sourceDir;
}
Expand All @@ -77,6 +83,7 @@ export async function buildApp({
scheme,
configuration,
args,
deviceName,
});
const buildSettings = await getBuildSettings(
xcodeProject,
Expand Down