You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 12项目可构建但无法归档:Realm.framework缺失问题求助

Fixing Realm.framework Missing Error During Xcode 11.2 Archiving for iOS 12 Projects

Hey there, let's work through this frustrating Realm framework issue you're hitting when archiving your iOS 12 app (built with Xcode 11.2 and Swift 5). It's weird that it runs fine on the simulator but breaks during archiving—let's break down actionable fixes:

1. Double-Check Your Realm Integration Method

First, confirm how you added Realm to your project:

  • If using CocoaPods:
    • Make sure you're opening the .xcworkspace file (not .xcodeproj) after running pods.
    • Run these commands in your project directory to refresh the Pods setup:
      pod deintegrate
      pod clean
      pod install
      
    • Verify your Podfile specifies the correct iOS version: platform :ios, '12.0' and uses a Realm version compatible with Xcode 11.2 (Realm Swift 3.20.0 or later should work, but double-check their release notes).
  • If manually integrating:
    • Ensure you've copied Realm.framework to your project's Frameworks folder, and it's included in your target's build phases under Link Binary With Libraries.

2. Tweak Critical Build Settings

Go to your target's Build Settings and adjust these:

  • Framework Search Paths: Use relative paths like $(PROJECT_DIR)/Frameworks instead of absolute paths to avoid machine-specific issues, and confirm it includes the path to Realm.framework.
  • Runpath Search Paths: Add both @executable_path/Frameworks and @loader_path/Frameworks if they're missing—this helps the app find embedded frameworks at runtime and archive time.
  • Always Embed Swift Standard Libraries: Set this to Yes (critical for Swift frameworks like Realm during archiving).
  • Build Active Architecture Only (Release): Set this to No—archiving needs to build for all supported architectures, not just your current device/simulator.

3. Fix Framework Embedding Settings

Head to your target's General tab, under Frameworks, Libraries, and Embedded Content:

  • Find Realm.framework and set its embedding status to Embed & Sign (not Do Not Embed). This ensures the framework gets copied to the archive's build products path correctly.

4. Clear All Cached Data (Beyond Just Derived Data)

You mentioned cleaning Derived Data helps with builds, but let's go further for archiving:

  • Delete old archives: Open Xcode → Preferences → Locations → Archives, then right-click and delete any existing archives for your app.
  • Run a clean via command line to wipe Release configuration caches:
    xcodebuild clean -workspace YOUR_APP.xcworkspace -scheme YOUR_SCHEME_NAME -configuration Release
    
  • Quit Xcode completely, then delete the Derived Data folder again (use the shortcut in Xcode's Locations tab to open it quickly).

5. Validate the Archive Build Path

The error says Realm.framework is missing from the Release-iphoneos folder in your Derived Data. Let's check:

  • Start an archive, and when it fails, navigate to the path in the error message (/Users/ME/Library/Developer/Xcode/DerivedData/.../Release-iphoneos).
  • If Realm.framework isn't there, it means the build phase isn't copying it over. For manual integration, add a new Copy Files build phase, set the destination to Frameworks, and add Realm.framework to it.

Last Resort: Test with a Clean Project

If none of the above works, create a brand new iOS 12 project in Xcode 11.2, add Realm (using your same integration method), and try archiving it. If that works, the issue is likely a corrupted setting in your original project—you can then migrate your code over or compare build settings side-by-side to find the mismatch.


内容的提问来源于stack exchange,提问作者danishhotdog

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:28:58