Skip to content
Open
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
45 changes: 41 additions & 4 deletions packages/ios-stickers/src/xcodeSticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@ const isaXCBuildConfiguration = "XCBuildConfiguration";
const pbxTargetDependency = "PBXTargetDependency";
const pbxContainerItemProxy = "PBXContainerItemProxy";

function getMainTargetDevelopmentTeam(
proj: XcodeProject,
): string | undefined {
const configs = proj.pbxXCBuildConfigurationSection();
for (const key in configs) {
const config = configs[key];
if (typeof config === "string") continue;
const bs = config.buildSettings;
if (!bs?.PRODUCT_NAME) continue;
const productName = bs.PRODUCT_NAME.replace(/"/g, "");
if (
productName.includes("Extension") ||
productName.includes("Widget") ||
productName.includes("Sticker")
) {
continue;
}
const team = bs.DEVELOPMENT_TEAM?.replace(/"/g, "");
if (team) {
return team;
}
}
return undefined;
}

export function addStickersTarget(
proj: XcodeProject,
name: string,
Expand Down Expand Up @@ -118,7 +143,9 @@ export function addStickersTarget(
stickerBundleId ?? `"${bundleId}.${bundleName}"`;
const INFOPLIST_FILE = `"${subfolder}/Info.plist"`;

const commonBuildSettings = {
const developmentTeam = getMainTargetDevelopmentTeam(proj);

const commonBuildSettings: Record<string, string> = {
ASSETCATALOG_COMPILER_APPICON_NAME: '"iMessage App Icon"',
CLANG_ANALYZER_NONNULL: "YES",
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
Expand All @@ -138,6 +165,10 @@ export function addStickersTarget(
SKIP_INSTALL: "YES",
TARGETED_DEVICE_FAMILY: `"1,2"`,
};

if (developmentTeam) {
commonBuildSettings.DEVELOPMENT_TEAM = developmentTeam;
}
// Build Configuration: Create
const buildConfigurationsList = [
{
Expand Down Expand Up @@ -264,13 +295,19 @@ export function addStickersTarget(
proj.getFirstProject().uuid
].attributes.TargetAttributes = {};
}
proj.pbxProjectSection()[
proj.getFirstProject().uuid
].attributes.TargetAttributes[target.uuid] = {
const targetAttributes: Record<string, string> = {
CreatedOnToolsVersion: "12.5",
ProvisioningStyle: "Automatic",
};

if (developmentTeam) {
targetAttributes.DevelopmentTeam = developmentTeam;
}

proj.pbxProjectSection()[
proj.getFirstProject().uuid
].attributes.TargetAttributes[target.uuid] = targetAttributes;

return target;
}

Expand Down