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

fix(ios): fix crash when --mode is specified #1958

Merged
merged 1 commit into from
Aug 19, 2023

Conversation

tido64
Copy link
Contributor

@tido64 tido64 commented Jun 8, 2023

Summary:

Assumptions about where the .xcodeproj lives causes checkIfConfigurationExists to crash because undefined was passed as project.

Test Plan:

git clone https://github.com/microsoft/react-native-test-app.git
cd react-native-test-app
npm run set-react-version 0.72
yarn
cd example
pod install --project-directory=ios
yarn ios --mode 'Debug'

The last command should not crash.

Assumptions about where the `.xcodeproj` lives causes
`checkIfConfigurationExists` to crash because `undefined` was passed as
project.
@tido64 tido64 requested review from adamTrz and thymikee as code owners June 8, 2023 12:18
import {IosProjectInfo} from '../types';

export function checkIfConfigurationExists(
project: IosProjectInfo,
mode: string,
) {
if (!project) {
logger.warn(`Unable to check whether "${mode}" exists in your project`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this warning is actually useful. I'd prefer to not have it here, but I'll let you decide.

@adamTrz
Copy link
Collaborator

adamTrz commented Jun 12, 2023

Super strange that example workspace don't have configurations field present when we list them... 🤔

@tido64
Copy link
Contributor Author

tido64 commented Jun 12, 2023

Super strange that example workspace don't have configurations field present when we list them... 🤔

That is because the CLI is trying to look for .xcodeproj where .xcworkspace currently lives. That isn't always the case. Podfile and .xcworkspace are the only two files you can make assumptions about. .xcodeproj can live anywhere. The only way you can find it is by parsing the .xcworkspace, but it may contain several.

@adamTrz
Copy link
Collaborator

adamTrz commented Jun 13, 2023

Super strange that example workspace don't have configurations field present when we list them... 🤔

That is because the CLI is trying to look for .xcodeproj where .xcworkspace currently lives. That isn't always the case. Podfile and .xcworkspace are the only two files you can make assumptions about. .xcodeproj can live anywhere. The only you can find it is by parsing the .xcworkspace, but it may contain several.

Yeah, got it. Still, one would hope that xcodebuild -list would output all configurations but it does not :|

I'll try to look at your PR ASPA, seems like interactive mode is broken as well since it's also calling getProjectInfo function...

@thymikee thymikee merged commit 0296d31 into react-native-community:main Aug 19, 2023
thymikee pushed a commit that referenced this pull request Sep 12, 2023
Assumptions about where the `.xcodeproj` lives causes
`checkIfConfigurationExists` to crash because `undefined` was passed as
project.
@tido64 tido64 deleted the tido/fix-mode-crash branch October 27, 2023 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants