Skip to content

Commit efd1c37

Browse files
committed
fix: container xcodeproj location resolution
1 parent 8492fde commit efd1c37

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('getInfo', () => {
1616
it('handles non-project / workspace locations in a ', () => {
1717
const name = `YourProjectName`;
1818
(fs.readFileSync as jest.Mock)
19-
.mockReturnValueOnce(`<?xml version="1.0" encoding="UTF-8"?>
19+
.mockReturnValueOnce(`<?xml version="1.0" encoding="UTF-8"?>
2020
<Workspace
2121
version = "1.0">
2222
<FileRef
@@ -32,6 +32,34 @@ describe('getInfo', () => {
3232
(execa.sync as jest.Mock).mockReturnValue({stdout: '{}'});
3333
getInfo({isWorkspace: true, name} as IOSProjectInfo, 'some/path');
3434

35+
const execaSync = execa.sync as jest.Mock;
36+
// Should not call on Pods or the other misc groups
37+
expect(execaSync.mock.calls).toEqual([
38+
[
39+
'xcodebuild',
40+
['-list', '-json', '-project', `some/path/${name}.xcodeproj`],
41+
],
42+
]);
43+
});
44+
it('handles xcodeproj location in container in a ', () => {
45+
const name = `YourProjectName`;
46+
(fs.readFileSync as jest.Mock)
47+
.mockReturnValueOnce(`<?xml version="1.0" encoding="UTF-8"?>
48+
<Workspace
49+
version = "1.0">
50+
<FileRef
51+
location = "container:${name}.xcodeproj">
52+
</FileRef>
53+
<FileRef
54+
location = "group:Pods/Pods.xcodeproj">
55+
</FileRef>
56+
<FileRef
57+
location = "group:container/some_other_file.mm">
58+
</FileRef>
59+
</Workspace>`);
60+
(execa.sync as jest.Mock).mockReturnValue({stdout: '{}'});
61+
getInfo({isWorkspace: true, name} as IOSProjectInfo, 'some/path');
62+
3563
const execaSync = execa.sync as jest.Mock;
3664
// Should not call on Pods or the other misc groups
3765
expect(execaSync.mock.calls).toEqual([

packages/cli-platform-apple/src/tools/getInfo.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import * as fs from 'fs';
55
import * as path from 'path';
66
import type {IosInfo} from '../types';
77

8-
function isErrorLike(err: unknown): err is {message: string} {
8+
function isErrorLike(err: unknown): err is { message: string } {
99
return Boolean(
1010
err &&
11-
typeof err === 'object' &&
12-
'message' in err &&
13-
typeof err.message === 'string',
11+
typeof err === 'object' &&
12+
'message' in err &&
13+
typeof err.message === 'string',
1414
);
1515
}
1616

@@ -72,7 +72,10 @@ export function getInfo(
7272
'-list',
7373
'-json',
7474
'-project',
75-
path.join(sourceDir, location.replace('group:', '')),
75+
path.join(
76+
sourceDir,
77+
location.replace('group:', '').replace('container:', ''),
78+
),
7679
]);
7780
const info = parseTargetList(xcodebuild.stdout);
7881
if (!info) {

0 commit comments

Comments
 (0)