Xcode控制台“po“错误:表达式解析失败

iOS开发中,使用Xcode开发时,有时候原本运行好好的项目,突然调试时,发现po命令无法正常显示变量的值,无论是清空编译目录,还是重装Xcode,都无法解决问题。当使用po命令时,显示如下:

通过百般折腾与搜索,终于在github上找到了解决该问题的方案:https://github.com/florentmorin/Xcode13LLDBBug

因为我的项目是通过Pod集成依赖的,所以按照解决方案中针对pod的解决方式就行。有几个点需要说明下,就在解决方案的描述上进行说明:

复制代码
post_integrate do |installer|
	// 注意在项目里面找到对应文件的正确路径,如果这个文件路径有问题,pod install会报错
    xcconfig_path = installer.sandbox.target_support_files_root.to_s + '/Pods-App/Pods-App.debug.xcconfig'

    xcconfig_content = File.read xcconfig_path
    xcconfig_original_ld_flags = xcconfig_content.match(/OTHER_LDFLAGS = ([^\n]+)\n/)[1]

    xcconfig_new_ld_flags = <<~CONTENT

    // Xcode 13.3+
    //	InternalPod换成你需要debug的代码所在的库的名字,如果有多个库debug出问题,就按照这个格式,把多个库加上去。
    OTHER_LDFLAGS = #{xcconfig_original_ld_flags} -Wl,-add_ast_path,$(TARGET_BUILD_DIR)/InternalPod/InternalPod.framework/Modules/InternalPod.swiftmodule/$(NATIVE_ARCH_ACTUAL)-apple-$(SHALLOW_BUNDLE_TRIPLE).swiftmodule

	 //现在的xcode版本基本都是Xcode 15及以上了,所以下面这几行不需要了。
    // Xcode 13.2
    OTHER_LDFLAGS[sdk=iphoneos15.2] = #{xcconfig_original_ld_flags} -Wl,-add_ast_path,$(TARGET_BUILD_DIR)/InternalPod/InternalPod.framework/Modules/InternalPod.swiftmodule/$(NATIVE_ARCH_ACTUAL)-apple-ios.swiftmodule
    OTHER_LDFLAGS[sdk=iphonesimulator15.2] = #{xcconfig_original_ld_flags} -Wl,-add_ast_path,$(TARGET_BUILD_DIR)/InternalPod/InternalPod.framework/Modules/InternalPod.swiftmodule/$(NATIVE_ARCH_ACTUAL)-apple-simulator.swiftmodule

    CONTENT

    xcconfig_content.gsub! /OTHER_LDFLAGS = ([^\n]+)\n/, xcconfig_new_ld_flags

    File.open(xcconfig_path, 'w') do |f|
      f.puts xcconfig_content
    end

end
相关推荐
pumpkin845145 小时前
Mac Studio M4 Max 纯本地化部署 Qwen 3.6 并桥接 Claude Code 实践指南
macos
hurrycry_小亦7 小时前
苹果WWDC 2026前瞻:Ferret-Pro端侧大模型即将亮相|小亦之闻|AI 编程三日速递!(5月26日~5月28日)
macos·ios·wwdc
搬砖的小码农_Sky10 小时前
macOS Sequoia OpenClaw + Ollama 本地离线部署(免API、Apple Silicon金属加速)
人工智能·macos·ai·人机交互
稚枭天卓14 小时前
mac 安装 redis
redis·macos
AugustRed14 小时前
MacOS 运维常用命令大全(超全速查表)
运维·macos
稚枭天卓18 小时前
mac 安装mysql
mysql·macos
是烨笙啊19 小时前
AI编程:项目管理
ide·人工智能·ai编程
czy87874751 天前
vscode编译make命令要修改stm32cubemx生成的STM32F103XX_FLASH.ld文件
ide·vscode·stm32
feifeigo1231 天前
基于隐马尔可夫模型(HMM)的孤立词语音识别系统
人工智能·语音识别·xcode
m0_535817552 天前
macOS上Claude Code安装配置保姆级教程:国内直连API,从0到1跑通(附避坑指南)
gpt·macos·ai·node.js·claude·claudecode·88api