Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[apply] Fix iOS name changing #2497

Merged
merged 1 commit into from
Aug 25, 2020
Merged
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
20 changes: 15 additions & 5 deletions packages/expo-cli/src/commands/apply/configureIOSProjectAsync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IOSConfig, WarningAggregator, getConfig } from '@expo/config';
import { getProjectName } from '@expo/config/build/ios/utils/Xcodeproj';
import { IosPlist, UserManager } from '@expo/xdl';
import path from 'path';

Expand Down Expand Up @@ -106,14 +107,23 @@ function sanitizedName(name: string) {
// placeholder for now! Make this more robust when we support applying config
// at any time (currently it's only applied on eject).
function getIOSPaths(projectRoot: string) {
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });
let projectName: string | null = null;

const projectName = exp.name;
if (!projectName) {
throw new Error('Your project needs a name in app.json/app.config.js.');
// Attempt to get the current ios folder name (apply).
try {
projectName = getProjectName(projectRoot);
} catch {
// If no iOS project exists then create a new one (eject).
const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });

projectName = exp.name;
if (!projectName) {
throw new Error('Your project needs a name in app.json/app.config.js.');
}
projectName = sanitizedName(projectName);
}

const iosProjectDirectory = path.join(projectRoot, 'ios', sanitizedName(projectName));
const iosProjectDirectory = path.join(projectRoot, 'ios', projectName);
const iconPath = path.join(iosProjectDirectory, 'Assets.xcassets', 'AppIcon.appiconset');

return {
Expand Down