【问题标题】:Debug NSString variables with Apple Script Actions in XCode在 XCode 中使用 Apple 脚本操作调试 NSString 变量
【发布时间】:2025-12-12 04:45:01
【问题描述】:

在调试 iOS 应用时,我尝试使用以下 Apple 脚本通过断点获取屏幕截图:

将屏幕捕获设置为“/usr/sbin/screencapture -l 1586 ~/Downloads/screenshots/photo-@(char*) [myStringVar UTF8String]@.png" -- 做shell脚本截屏

但它失败了,因为 @exp@ 输出引号 (") 来自 myStringVar 并与 set 分配混淆,所以我从 lldb 收到此错误

AppleScript '-viewDidAppear:' 断点操作失败:标识符 不能去追求这个“”。

我怎样才能克服这个问题并确保@exp@ 输出没有引号?替换我的 Apple 脚本中的字符串?

【问题讨论】:

    标签: objective-c xcode debugging applescript lldb


    【解决方案1】:

    您可以尝试让表达式构造整个文件名,例如

    (NSString *)[NSString stringWithFormat: @"~/Downloads/screenshots/photo-%@.png", [self.entryId UTF8String]]
    

    这样您就不会插入任何引号。如果需要,您可能可以通过这种方式完成整个 AppleScript。

    顺便说一句,强制转换是必需的,因为我们没有 NSString stringWithFormat 的调试信息...

    【讨论】: