Xcode 9.2 App Thinning打包报错:Swift动态库缺少xcent资源
Hey there, let's troubleshoot this frustrating bitcode and app thinning issue you're facing. The error about missing archived-expanded-entitlements.xcent for Swift system libraries (like libswiftQuartzCore.dylib) when exporting an Ad-Hoc build with Bitcode enabled is a common gotcha in mixed Objective-C/Swift projects with mixed third-party integration. Here are targeted steps to fix it:
Step 1: Verify Entitlements Configuration Across All Targets
- Open your project and navigate to your main app target's Build Settings. Search for
Code Signing Entitlementsand double-check that the path points to a valid entitlements file (usuallyYourApp.entitlements) in your project directory. - Don't forget to check Pod-managed targets too! Some pods default to no entitlements configuration, which can cause mismatches during bitcode compilation. For each pod target, set their
Code Signing Entitlementsto match your main app's entitlements file, or ensure they have their own valid entitlements if needed.
Step 2: Do a Full Clean and Rebuild Archive
Cached build artifacts are often the culprit for weird resource missing errors:
- Hold down the Option key and click
Product > Clean Build Folderto wipe all cached files completely. - Rebuild your archive from scratch (
Product > Archive), then try the Ad-Hoc export again.
Step 3: Ensure Consistent Bitcode Settings
Bitcode requires all components (app, pods, frameworks) to have matching settings:
- In your main target's Build Settings, confirm
Enable Bitcodeis set toYes. - Go through every pod target and manually set
Enable BitcodetoYes(some pods might default toNoor$(inherited)which might not propagate correctly). - When exporting your archive, make sure you select the Rebuild from Bitcode option in the app thinning step.
Step 4: Check Bundle Resource Configuration
The archived-expanded-entitlements.xcent file is auto-generated by Xcode—don't mess with it directly, but confirm it's not misconfigured:
- Go to your main target's Build Phases > Copy Bundle Resources. Ensure
archived-expanded-entitlements.xcentis not listed here (adding it manually breaks the auto-generation). - Check Build Settings > Excluded Source File Names to make sure this file isn't being excluded from the build. If it is, remove it from the exclusion list.
Step 5: Reset Signing Configuration
Auto-signing glitches can cause entitlement mismatches:
- Navigate to your main target's General > Signing. Toggle off
Automatically manage signing, then manually select your team and the correct Ad-Hoc provisioning profile. - Toggle
Automatically manage signingback on—this forces Xcode to refresh all signing-related configurations and regenerate entitlement files correctly.
Step 6: Check Manual Third-Party Frameworks
Even though your two private frameworks work, double-check their integration:
- Go to General > Embedded Binaries and select each manually integrated framework. In the right-hand inspector panel, confirm the signing identity matches your app's signing team.
- Ensure these frameworks have Bitcode enabled (you can check by running
otool -l YourFramework.framework/YourFramework | grep bitcodein Terminal—look for abitcodesegment).
Bonus: Update Xcode if Possible
Xcode 9.2 has known bugs related to Swift dynamic libraries and Bitcode packaging. If you can, update to Xcode 9.4.1 (the latest stable release in the Xcode 9 series) as it fixes many of these edge cases.
If you've tried all these steps and still see the error, feel free to share more snippets from your IDEDistribution.log—but these fixes resolve 90% of similar issues in Xcode 9.2.
内容的提问来源于stack exchange,提问作者Ghanashyam Murali

