Skip to content

Commit d96d011

Browse files
JooHyung Parkclaude
andcommitted
[ai-assisted] fix(mas): add application identifier for TestFlight
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c1aee77 commit d96d011

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

forge.config.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const config: ForgeConfig = {
8585
const identity = process.env.SIGNING_IDENTITY_APPSTORE || 'Apple Distribution';
8686
const childEntitlements = path.resolve('entitlements.child.plist');
8787
const mainEntitlements = path.resolve('entitlements.mas.plist');
88+
const teamId = process.env.APPLE_TEAM_ID || '';
89+
const bundleId = (_config as any).packagerConfig.appBundleId || 'com.grabtaxi.klever';
8890

8991
// Find the .app bundle inside the output directory
9092
const items = fs.readdirSync(outputDir);
@@ -144,10 +146,33 @@ const config: ForgeConfig = {
144146
// Re-sign the main app to update the seal after helper modifications
145147
console.log('[postPackage] Re-signing main app to update seal...');
146148
try {
149+
// Create enhanced entitlements with application identifier for TestFlight
150+
const mainEntitlementsContent = fs.readFileSync(mainEntitlements, 'utf8');
151+
const enhancedEntitlements = mainEntitlementsContent.replace(
152+
'</dict>',
153+
` <!-- Required for TestFlight distribution -->
154+
<key>com.apple.application-identifier</key>
155+
<string>${teamId}.${bundleId}</string>
156+
<key>com.apple.developer.team-identifier</key>
157+
<string>${teamId}</string>
158+
<key>com.apple.security.application-groups</key>
159+
<array>
160+
<string>${teamId}.${bundleId}</string>
161+
</array>
162+
</dict>`
163+
);
164+
165+
const tempEntitlements = path.join(outputDir, 'temp-entitlements.plist');
166+
fs.writeFileSync(tempEntitlements, enhancedEntitlements);
167+
147168
execSync(
148-
`codesign --force --sign "${identity}" --entitlements "${mainEntitlements}" --timestamp=none "${appPath}"`,
169+
`codesign --force --sign "${identity}" --entitlements "${tempEntitlements}" --timestamp=none "${appPath}"`,
149170
{ stdio: 'inherit' }
150171
);
172+
173+
// Clean up temp file
174+
fs.unlinkSync(tempEntitlements);
175+
151176
console.log('[postPackage] ✅ Successfully re-signed main app');
152177
} catch (error) {
153178
console.error('[postPackage] ❌ Failed to re-sign main app:', error);

0 commit comments

Comments
 (0)