diff --git a/packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts b/packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts new file mode 100644 index 000000000..8dbde0ff0 --- /dev/null +++ b/packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts @@ -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(` + + + + + + + +`); + (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`], + ], + ]); + }); +}); diff --git a/packages/cli-platform-apple/src/tools/getInfo.ts b/packages/cli-platform-apple/src/tools/getInfo.ts index a4de21ed8..7f45855d7 100644 --- a/packages/cli-platform-apple/src/tools/getInfo.ts +++ b/packages/cli-platform-apple/src/tools/getInfo.ts @@ -59,6 +59,10 @@ export function getInfo( return refs.reduce((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;