Skip to content
Open
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
44 changes: 44 additions & 0 deletions packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type {IOSProjectInfo} from '@react-native-community/cli-types';

import execa from 'execa';
import fs from 'fs';
import {getInfo} from '../getInfo';

jest.mock('execa', () => ({
sync: jest.fn(),
}));

jest.mock('fs', () => ({
readFileSync: jest.fn(),
}));

describe('getInfo', () => {
it('handles non-project / workspace locations in a ', () => {
const name = `YourProjectName`;
(fs.readFileSync as jest.Mock)
.mockReturnValueOnce(`<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:${name}.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
<FileRef
location = "group:container/some_other_file.mm">
</FileRef>
</Workspace>`);
(execa.sync as jest.Mock).mockReturnValue({stdout: '{}'});
getInfo({isWorkspace: true, name} as IOSProjectInfo, 'some/path');

const execaSync = execa.sync as jest.Mock;
// Should not call on Pods or the other misc groups
expect(execaSync.mock.calls).toEqual([
[
'xcodebuild',
['-list', '-json', '-project', `some/path/${name}.xcodeproj`],
],
]);
});
});
4 changes: 4 additions & 0 deletions packages/cli-platform-apple/src/tools/getInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export function getInfo(
return refs.reduce<IosInfo | undefined>((result, ref) => {
const location = ref['@_location'];

if (!location.endsWith('.xcodeproj')) {
return result;
}

// Ignore the project generated by CocoaPods
if (location.endsWith('/Pods.xcodeproj')) {
return result;
Expand Down