$non_lazy_ptr 与 agvtool 版本变量的链接错误?

发布于 2024-09-12 14:18:10 字数 889 浏览 5 评论 0原文

我一直在为我的 iPhone 应用程序之一使用 agvtool 一般原则,并且最近找到了一个我希望能够检查版本变量的原因(以便我可以重新复制帮助内容进入文档目录(如果已过期)。 MyApp_vers.c 中定义的变量 MyAppVersionNumber 是在构建过程中自动生成的。它在 .o 文件中生成,并显示在链接应用程序本身的(以前的版本?)中。到目前为止似乎一切顺利。

所以现在我在 .m 文件中声明了一个 extern double MyAppVersionNumber ,我需要在其中使用它(稍后尝试使用它,只是在 NSLog 语句开始),我尝试为 iPhone 模拟器构建,并收到链接错误:

  "_MyAppVersionNumber", referenced from:
      _MyAppVersionNumber$non_lazy_ptr in HelpViewController.o
     (maybe you meant: _MyAppVersionNumber$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

那么,我需要做些什么不同的事情才能使其链接?

我在谷歌上搜索了 $non_lazy_ptr 和 agvtool,但什么也没得到,而只是 $non_lazy_ptr,它提供了一些东西,但主要应用于库,这不是,真的(是吗?)。到目前为止,在我的挖掘中,我还没有打开一个关于 agvtool 的页面,它实际上详细讨论了如何使用变量——我读过的那些只是随意地说声明一个 extern 变量,我已经这样做了。

任何人熟悉这一点,和/或能够提供任何帮助?

谢谢!

I've been using agvtool for one of my iPhone apps on general principle, and have recently found a reason why I want to be able to check the version variable (so that I can re-copy help content into the Documents directory, if it's out of date). The variable, MyAppVersionNumber, defined in MyApp_vers.c, is auto-generated during the build. It gets generated in a .o file, and shows up in (the previous version?) of the linked app itself. So far so good, it would seem.

So now I've declared an extern double MyAppVersionNumber in the .m file where I need to use this (and later try to use it, just in an NSLog statement to get started), and I try to build for the iPhone simulator, and get a link error:

  "_MyAppVersionNumber", referenced from:
      _MyAppVersionNumber$non_lazy_ptr in HelpViewController.o
     (maybe you meant: _MyAppVersionNumber$non_lazy_ptr)
ld: symbol(s) not found
collect2: ld returned 1 exit status

So, what do I need to do differently, to get this to link?

I googled for $non_lazy_ptr and agvtool, and got nothing at all, and for just $non_lazy_ptr, which gave some things, but mostly applying to libraries, which this isn't, really (is it?). And in my diggings so far, I've yet to turn up a page about agvtool that actually talks in any detail about using the variables -- the ones I've read just casually say to declare an extern variable, which I've done.

Anyone familiar with this, and/or otherwise able to provide any help?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯角 2024-09-19 14:18:10

由于 agvtool 更新了 plist 的 CFBundleVersion 值,我建议在运行时使用以下命令访问版本号:

NSDictionary *mainDictionary = [[NSBundle mainBundle] infoDictionary];
double myVersionNumber = [(NSString *)[infoDictionary objectForKey:@"CFBundleVersion"] doubleValue];

Since agvtool updates your plist's CFBundleVersion value, I suggest accessing the version number at run-time with:

NSDictionary *mainDictionary = [[NSBundle mainBundle] infoDictionary];
double myVersionNumber = [(NSString *)[infoDictionary objectForKey:@"CFBundleVersion"] doubleValue];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文