diff --git a/packages/ios-stickers/src/xcodeSticker.ts b/packages/ios-stickers/src/xcodeSticker.ts index 74bc7b2e..f30eb55a 100644 --- a/packages/ios-stickers/src/xcodeSticker.ts +++ b/packages/ios-stickers/src/xcodeSticker.ts @@ -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, @@ -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 = { ASSETCATALOG_COMPILER_APPICON_NAME: '"iMessage App Icon"', CLANG_ANALYZER_NONNULL: "YES", CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE", @@ -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 = [ { @@ -264,13 +295,19 @@ export function addStickersTarget( proj.getFirstProject().uuid ].attributes.TargetAttributes = {}; } - proj.pbxProjectSection()[ - proj.getFirstProject().uuid - ].attributes.TargetAttributes[target.uuid] = { + const targetAttributes: Record = { CreatedOnToolsVersion: "12.5", ProvisioningStyle: "Automatic", }; + if (developmentTeam) { + targetAttributes.DevelopmentTeam = developmentTeam; + } + + proj.pbxProjectSection()[ + proj.getFirstProject().uuid + ].attributes.TargetAttributes[target.uuid] = targetAttributes; + return target; }