Skip to content

Commit

Permalink
[eas-json] add experimental.disableIosBundleIdentifierValidation flag (
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozyra95 authored and Jonathan 小林 Hales committed Mar 8, 2021
1 parent 60168c8 commit b3f6b0c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is the log of notable changes to EAS CLI and related packages.
- Log the size of the archived project when uploading. ([#264](https://github.com/expo/eas-cli/pull/264) by [@wkozyra95](https://github.com/wkozyra95))
- Add more build metadata (release channel, build profile name, git commit hash). ([#265](https://github.com/expo/eas-cli/pull/265) by [@dsokal](https://github.com/dsokal))
- Display App Store link after successful submission. ([#144](https://github.com/expo/eas-cli/pull/144) by [@barthap](https://github.com/barthap))
- Add `experimental.disableIosBundleIdentifierValidation` flag to eas.json. ([#263](https://github.com/expo/eas-cli/pull/263) by [@wkozyra95](https://github.com/wkozyra95))

### 🐛 Bug fixes

Expand Down
35 changes: 26 additions & 9 deletions packages/eas-cli/src/build/ios/configure.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { ExpoConfig } from '@expo/config';
import { IOSConfig } from '@expo/config-plugins';
import { Workflow } from '@expo/eas-build-job';
import { VersionAutoIncrement, iOSBuildProfile } from '@expo/eas-json';
import {
EasJsonReader,
VersionAutoIncrement,
iOSBuildProfile,
iOSGenericBuildProfile,
} from '@expo/eas-json';

import Log from '../../log';
import { ConfigureContext } from '../context';
Expand All @@ -17,8 +22,14 @@ export async function configureIosAsync(ctx: ConfigureContext): Promise<void> {
if (!ctx.hasIosNativeProject) {
return;
}
await configureBundleIdentifierAsync(ctx.projectDir, ctx.exp);
await ensureBundleIdentifierIsValidAsync(ctx.projectDir);

const disableIosBundleIdentifierValidation = (
await new EasJsonReader(ctx.projectDir, 'all').readRawAsync()
)?.experimental?.disableIosBundleIdentifierValidation;
if (!disableIosBundleIdentifierValidation) {
await configureBundleIdentifierAsync(ctx.projectDir, ctx.exp);
await ensureBundleIdentifierIsValidAsync(ctx.projectDir);
}

if (isExpoUpdatesInstalled(ctx.projectDir)) {
await configureUpdatesAsync(ctx.projectDir, ctx.exp);
Expand All @@ -39,13 +50,19 @@ export async function validateAndSyncProjectConfigurationAsync({
const versionBumpStrategy = resolveVersionBumpStrategy(autoIncrement);

if (workflow === Workflow.GENERIC) {
const bundleIdentifierFromPbxproj = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(
projectDir
);
if (!bundleIdentifierFromPbxproj || bundleIdentifierFromPbxproj !== exp.ios?.bundleIdentifier) {
throw new Error(
'Bundle identifier is not configured correctly in your Xcode project. Please run "eas build:configure" to configure it.'
const genericBuildProfile = buildProfile as iOSGenericBuildProfile;
if (!genericBuildProfile.disableIosBundleIdentifierValidation) {
const bundleIdentifierFromPbxproj = IOSConfig.BundleIdentifier.getBundleIdentifierFromPbxproj(
projectDir
);
if (
!bundleIdentifierFromPbxproj ||
bundleIdentifierFromPbxproj !== exp.ios?.bundleIdentifier
) {
throw new Error(
'Bundle identifier is not configured correctly in your Xcode project. Please run "eas build:configure" to configure it.'
);
}
}
if (isExpoUpdatesInstalled(projectDir)) {
await syncUpdatesConfigurationAsync(projectDir, exp);
Expand Down
1 change: 1 addition & 0 deletions packages/eas-json/src/Config.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface iOSGenericBuildProfile extends Ios.BuilderEnvironment {
distribution?: iOSDistributionType;
autoIncrement: VersionAutoIncrement;
cache: Cache | null;
disableIosBundleIdentifierValidation?: boolean;
}

export type AndroidBuildProfile = AndroidManagedBuildProfile | AndroidGenericBuildProfile;
Expand Down
11 changes: 10 additions & 1 deletion packages/eas-json/src/EasJsonReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { AndroidBuildProfile, BuildProfile, EasConfig, iOSBuildProfile } from '.
import { EasJsonSchema, schemaBuildProfileMap } from './EasJsonSchema';

interface EasJson {
experimental?: {
disableIosBundleIdentifierValidation?: boolean;
};
builds: {
android?: { [key: string]: BuildProfilePreValidation };
ios?: { [key: string]: BuildProfilePreValidation };
Expand Down Expand Up @@ -39,10 +42,16 @@ export class EasJsonReader {
easJson.builds?.ios || {}
);
}
const iosExperimental = easJson.experimental?.disableIosBundleIdentifierValidation
? {
disableIosBundleIdentifierValidation:
easJson.experimental.disableIosBundleIdentifierValidation,
}
: {};
return {
builds: {
...(androidConfig ? { android: androidConfig } : {}),
...(iosConfig ? { ios: iosConfig } : {}),
...(iosConfig ? { ios: { ...iosConfig, ...iosExperimental } } : {}),
},
};
}
Expand Down
3 changes: 3 additions & 0 deletions packages/eas-json/src/EasJsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ const schemaBuildProfileMap: Record<string, Record<string, Joi.Schema>> = {
};

const EasJsonSchema = Joi.object({
experimental: Joi.object({
disableIosBundleIdentifierValidation: Joi.boolean(),
}),
builds: Joi.object({
android: Joi.object().pattern(
Joi.string(),
Expand Down

0 comments on commit b3f6b0c

Please sign in to comment.