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

Xcode报错No such module:导入框架后模拟器正常、归档失败求解决

Hey there, I’ve seen this exact issue pop up a lot when archiving projects with custom frameworks in Xcode 9/Swift 3—let’s walk through the most reliable fixes to get your archive working:

1. Make Sure Your Framework Supports Device Architectures

Simulators use x86_64/i386 architectures, but archiving for Generic iOS Devices targets arm64/armv7 (device-specific architectures). If your framework only includes simulator builds, you’ll hit that "No such module" error during archiving.

  • Right-click your framework in Xcode, select Show in Finder to locate it.
  • Open Terminal, navigate to the framework’s folder, and run:
    lipo -info YourFrameworkName.framework/YourFrameworkName
    
  • If the output doesn’t list arm64 or armv7, you need a universal framework (combines simulator and device builds). You can either request one from the framework provider, or compile it yourself by building for simulator and device separately, then merging the binaries with lipo -create.
2. Tweak Your Target’s Build Settings

Incorrect search paths or build options are often the culprit:

  • Framework Search Paths: Go to your target’s Build Settings → Search Paths → Framework Search Paths. Ensure the path to your framework is correct (use relative paths like $(SRCROOT)/Frameworks instead of absolute paths) and set to recursive so Xcode finds nested frameworks.
  • Always Embed Swift Standard Libraries: If your framework is written in Swift, enable this option under Build Settings → Build Options. Archiving requires these libraries to link properly.
  • Valid Architectures: Double-check Build Settings → Architectures → Valid Architectures includes arm64 and armv7 (Xcode 9 should have these by default, but sometimes they get accidentally removed).
3. Confirm the Framework is Embedded Correctly

Linking a framework isn’t enough—you need to embed it for archiving:

  • Go to your target’s General tab. Look under Embedded Binaries and make sure your framework is listed here. If it’s only in Linked Frameworks and Libraries, add it to Embedded Binaries (this will auto-add it to the linked list too).
  • Check code signing: For third-party frameworks, ensure their signature is compatible with your project’s code signing identity. If you built the framework yourself, make sure your archive uses a valid development or distribution certificate.
4. Clean Up Cached Data (The Classic Troubleshooter)

Xcode’s cached build data can cause weird inconsistencies between simulator and archive builds:

  • Hold the Option key and go to Product → Clean Build Folder (this clears more data than a regular Clean).
  • Close Xcode, then delete your Derived Data folder: Find it via Xcode → Preferences → Locations, click the arrow next to the Derived Data path, and delete the entire folder.
  • Reopen Xcode, build for the simulator first to confirm everything works, then switch to Generic iOS Devices and try archiving again.
5. Check Your Import Statements & Linker Flags
  • Double-check that your import YourFramework statement uses the correct case—Swift is case-sensitive, so a typo here can cause module not found errors during archiving (even if it works in the simulator).
  • If you’re using a static framework, add -ObjC or -all_load to Build Settings → Other Linker Flags to ensure all framework symbols are linked properly during archiving.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:25:11