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

iOS XCode-Swift构建Profile时class not found,紧急求助(周末将发布App Store)

Troubleshooting "Class Not Found" When Profiling iOS/Swift App (Works in Regular Build)

Hey there, sorry to hear you're hitting this frustrating roadblock right before your App Store release—total bummer. Let's break down why profiling might throw a "class not found" error when a regular build works, and walk through actionable fixes:

  • Check Build Configuration Mismatches
    By default, the Profile action uses the Release configuration (or Debug with optimizations), while your regular Build might be using the unoptimized Debug config. Head to Product > Scheme > Edit Scheme, select the Profile tab, and confirm the Build Configuration matches what you use for your working Build. If they differ:

    • Navigate to your target's Build Settings
    • Search for Compile Sources and Link Binary With Libraries
    • Double-check the missing class is included in the Profile configuration (not just Debug)
  • Disable Aggressive Optimizations/Dead Code Stripping
    Release builds often enable Dead Code Stripping (DEAD_CODE_STRIPPING = YES) and aggressive optimizations that can accidentally remove classes the compiler thinks are unused. Test by temporarily adjusting these for the Profile config:

    • In Build Settings, set Dead Code Stripping to NO
    • Set Optimization Level to None [-O0]
    • Rebuild and try profiling again. If it works, you'll need to mark the class as explicitly used (e.g., add @objc if it's referenced via Objective-C, or use @_optimize(none) for the specific class) to prevent it from being stripped in optimized builds.
  • Wipe Cached Build Artifacts
    Cached derived data or build folder artifacts can cause mismatches between Build and Profile actions. Do a full clean:

    • Press Cmd+Shift+K to clean the build folder
    • Go to Xcode > Settings > Locations, click the arrow next to Derived Data, and delete your project's folder
    • Restart Xcode, then try profiling again
  • Validate Dynamic Framework Setup
    If the missing class lives in a dynamic framework, ensure it's properly embedded and linked for the Profile configuration:

    • Go to your target's General tab, scroll to Frameworks, Libraries, and Embedded Content
    • Confirm the framework is set to Embed & Sign (not Do Not Embed)
    • Check Build Settings to make sure Framework Search Paths includes the framework's location for all configurations
  • Double-Check Scheme Profile Action Settings
    Make sure the Profile action isn't excluding critical targets or files:

    • Open the scheme editor (Product > Scheme > Edit Scheme)
    • Select the Profile tab, then review the Info and Build sections
    • Ensure all necessary targets are checked, and no relevant files are marked as excluded from the build

Hope one of these fixes gets your profiling up and running so you can squash those crashes before your weekend release!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:31:45