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

Xcode 9.3中Swift项目集成libxml报错:无法构建Objective-C模块‘libxml’

Fix "Could not build Objective-C module 'libxml'" After Xcode 9.3 Upgrade

Hey there, I’ve run into this exact issue before after upgrading to Xcode 9.3—here’s how to fix it properly:

The Root Cause

Xcode 9.3 updated the iOS SDK to include an official module map for libxml2, which conflicts with the custom module.modulemap you created earlier. This clash is why you’re seeing the "Could not build Objective-C module 'libxml'" error and issues with the _xmlEnumeration struct definition.

Step-by-Step Fix

  1. Delete your custom module.modulemap file
    Get rid of the file you created with this content:

    module libxml [system] {
        header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/libxml2/libxml/tree.h"
        export *
    }
    

    It’s no longer needed and is causing the conflict.

  2. Update your project’s Header Search Paths
    Go to your project’s Build Settings, search for Header Search Paths, and add this path:

    $(SDKROOT)/usr/include/libxml2
    

    Make sure the path is set to Recursive (check the box next to it) to ensure all nested headers are found correctly.

  3. Import the official module in your Swift code
    Replace your old import libxml with:

    import libxml2
    

    This uses the official SDK module that Xcode 9.3 now provides natively, which includes all necessary headers and avoids symbol conflicts.

That’s it—your project should build without those errors now. The official module handles all the header references properly, so you don’t need to manage a custom module map anymore.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 09:11:05