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

构建集成Socket.IO-Client-Swift的静态库报错,求Podfile配置方案

Fixing "SocketIO Not Found" Error When Building a Static Library with Socket.IO-Client-Swift

Got it, let's sort out this "SocketIO not found" issue you're hitting while building your static library. The root problem here is that your original Podfile uses use_frameworks!, which compiles dependencies as dynamic frameworks—and static libraries play nice with statically linked dependencies instead.

Here's the adjusted Podfile configuration that should resolve the error:

# Use modular headers to compile Pods as static libraries (works for most Xcode versions)
use_modular_headers!

# Alternative for Xcode 12+: If you prefer using static frameworks instead, replace the line above with:
# use_frameworks! :linkage => :static

target 'visitor_sdk' do
  pod 'Socket.IO-Client-Swift'
end

Why this works:

  • Your original use_frameworks! forces all Pods to build as dynamic frameworks, which creates linking conflicts when your static library tries to reference them.
  • use_modular_headers! tells CocoaPods to generate modular headers for dependencies and compile them as static libraries, making them compatible with your static library target.
  • The use_frameworks! :linkage => :static variant (for Xcode 12+) achieves the same goal but builds dependencies as static frameworks instead of static libraries—either approach will fix the "not found" error.

Next steps to apply the fix:

  1. Clean up your existing Pods setup to avoid cached issues:
    pod deintegrate
    pod clean
    
  2. Reinstall the Pods with the new configuration:
    pod install
    
  3. Always open your project via the generated .xcworkspace file (never the raw .xcodeproj) and rebuild your visitor_sdk static library target.

Quick extra checks:

  • Make sure your static library target's Build Settings has -ObjC added to Other Linker Flags—Socket.IO-Client-Swift relies on this to properly load category methods.
  • Double-check your target's Build Phases > Link Binary With Libraries to confirm that SocketIO (either as a static library or static framework) is listed.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 04:08:44