V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
emperinter
V2EX  ›  程序员

Mac 软件开发报错 NSTaggedPointerString count [求助]

  •  
  •   emperinter · 287 天前 · 782 次点击
    这是一个创建于 287 天前的主题,其中的信息可能已经有所发展或是发生改变。

    情况

    想着给已有项目配置修复一下国际化问题,刚开始还能运行后续运行报错如下,各种方法都没有找到原因。代码基本没有任何改动,后续发现已上线的测试版本也无法运行。目前定位应该是在入口的@main开始发生问题,也怀疑是 Localizable.strings 的问题,但实际上没有任何修改记录。

    报错如下

    2023-07-16 04:13:48.942021+0800 PDFPhoto Protector[9808:134268] -[NSTaggedPointerString count]: unrecognized selector sent to instance 0xb4fad2e3e13e9cba
    2023-07-16 04:13:48.942928+0800 PDFPhoto Protector[9808:134268] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString count]: unrecognized selector sent to instance 0xb4fad2e3e13e9cba'
    *** First throw call stack:
    (
    	0   CoreFoundation                      0x00000001a319b154 __exceptionPreprocess + 176
    	1   libobjc.A.dylib                     0x00000001a2cba4d4 objc_exception_throw + 60
    	2   CoreFoundation                      0x00000001a3242110 -[NSObject(NSObject) __retain_OA] + 0
    	3   CoreFoundation                      0x00000001a31030a0 ___forwarding___ + 1600
    	4   CoreFoundation                      0x00000001a31029a0 _CF_forwarding_prep_0 + 96
    	5   CoreFoundation                      0x00000001a31df09c _CFLocaleCreateLocaleIdentifierForAvailableLocalizations + 76
    	6   CoreFoundation                      0x00000001a30df058 _CFLocaleCopyCurrentGuts + 816
    	7   CoreFoundation                      0x00000001a30decfc +[NSLocale currentLocale] + 16
    	8   Foundation                          0x00000001a4044dcc -[NSUserDefaults(NSUserDefaults) init] + 1136
    	9   Foundation                          0x00000001a4044910 +[NSUserDefaults(NSUserDefaults) standardUserDefaults] + 64
    	10  AppKit                              0x00000001a630c804 +[NSApplication initialize] + 88
    	11  libobjc.A.dylib                     0x00000001a2caaff0 CALLING_SOME_+initialize_METHOD + 24
    	12  libobjc.A.dylib                     0x00000001a2caac9c initializeNonMetaClass + 904
    	13  libobjc.A.dylib                     0x00000001a2cc50e8 _ZL24initializeAndMaybeRelockP10objc_classP11objc_objectR12locker_mixinIN9lockdebug10lock_mixinI16objc_lock_base_tEEEb + 156
    	14  libobjc.A.dylib                     0x00000001a2caa5c4 lookUpImpOrForward + 884
    	15  libobjc.A.dylib                     0x00000001a2ca9f64 _objc_msgSend_uncached + 68
    	16  AppKit                              0x00000001a630c59c NSApplicationMain + 376
    	17  PDFPhoto Protector                  0x0000000100bd7618 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ + 40
    	18  PDFPhoto Protector                  0x0000000100bd75e0 $s18PDFPhoto_Protector11AppDelegateC5$mainyyFZ + 44
    	19  PDFPhoto Protector                  0x0000000100bd76b0 main + 28
    	20  dyld                                0x00000001a2cebf28 start + 2236
    )
    libc++abi: terminating due to uncaught exception of type NSException
    (lldb) 
    
    • 标红的地方,@main
    import Cocoa
    
    @main
    class AppDelegate: NSObject, NSApplicationDelegate {
    
    3 条回复    2023-07-16 16:27:41 +08:00
    nenseso
        1
    nenseso  
       286 天前
    6 CoreFoundation 0x00000001a30df058 _CFLocaleCopyCurrentGuts + 816
    7 CoreFoundation 0x00000001a30decfc +[NSLocale currentLocale] + 16
    8 Foundation 0x00000001a4044dcc -[NSUserDefaults(NSUserDefaults) init] + 1136
    9 Foundation 0x00000001a4044910 +[NSUserDefaults(NSUserDefaults) standardUserDefaults] + 64
    这里能找到吗?它怎么调到 NSLocale 那里的
    emperinter
        2
    emperinter  
    OP
       286 天前
    @nenseso 找过这个,没在项目中找到任何相关用法,也尝试过程序运行初始阶段设置一段默认配置 NSUserDefaults 也不起作用
    emperinter
        3
    emperinter  
    OP
       286 天前
    目前程序基本定位可能找出来了,确实是 NSUserDefaults 的问题,这个应该是自动生成的,具体原理也不清楚,找过相关文件等等删除后也不起作用,目前通过`defaults delete <bundle_id>`删除默认设置后就能运行了,目前还在寻找具体的解决方案。不过这个删除程序以及缓存等等都删除不了默认设置,也侧面反应了 mac 的程序删除还会有一大堆遗留文件存在,。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   867 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:10 · PVG 05:10 · LAX 14:10 · JFK 17:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.