Skip to content

Commit

Permalink
✨Add support for EAS build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 14, 2024
1 parent 40fb58f commit e21e892
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
13 changes: 13 additions & 0 deletions plugin/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function safeSet(obj: any, key: string, value: any) {
const segments = key.split('.');
const last = segments.pop();
segments.forEach((segment) => {
if (!obj[segment]) {
obj[segment] = {};
}
obj = obj[segment];
});
obj[last!] = value;

return obj;
}
45 changes: 44 additions & 1 deletion plugin/src/withIosAppcuesRichPush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from 'expo/config-plugins';
import fs from 'fs';

import { safeSet } from './helpers';
import {
APPCUES_NSE_TARGET,
BUNDLE_SHORT_VERSION_TEMPLATE_REGEX,
Expand Down Expand Up @@ -139,20 +140,62 @@ const withAppcuesXcodeProject: ConfigPlugin<ConfigProps> = (config, props) => {
target.uuid
);

const quotedTargetName = `"${APPCUES_NSE_TARGET.NAME}"`;

// Fix "Value for SWIFT_VERSION cannot be empty."
const swiftVersion = xcodeProject.getBuildProperty('SWIFT_VERSION');
xcodeProject.addBuildProperty('SWIFT_VERSION', swiftVersion);
xcodeProject.updateBuildProperty(
'SWIFT_VERSION',
swiftVersion,
null, // want both Debug and Release, so don't specify either
quotedTargetName
);

// Set Automatic code signing.
xcodeProject.updateBuildProperty(
'CODE_SIGN_STYLE',
'Automatic',
null, // want both Debug and Release, so don't specify either
quotedTargetName
);

return config;
});
};

const withEasTargets: ConfigPlugin<ConfigProps> = (config, props) => {
if (!config.ios?.bundleIdentifier) {
throw new Error(`Missing 'ios.bundleIdentifier' in app config.`);
}

safeSet(config, 'extra.eas.build.experimental.ios.appExtensions', []);

const index =
config.extra!.eas.build.experimental.ios.appExtensions.findIndex(
(ext: any) => ext.targetName === APPCUES_NSE_TARGET.NAME
);

const extConfig = {
targetName: APPCUES_NSE_TARGET.NAME,
bundleIdentifier: `${config?.ios?.bundleIdentifier}.${APPCUES_NSE_TARGET.NAME}`,
};

if (index > -1) {
config.extra!.eas.build.experimental.ios.appExtensions[index] = extConfig;
} else {
config.extra!.eas.build.experimental.ios.appExtensions.push(extConfig);
}

return config;
};

export const withIosAppcuesRichPush: ConfigPlugin<ConfigProps> = (
config,
props
) => {
config = withAppcuesXcodeProject(config, props);
config = withAppcuesFiles(config, props);
config = withAppcuesPodfile(config, props);
config = withEasTargets(config, props);
return config;
};

0 comments on commit e21e892

Please sign in to comment.