开发者

$non_lazy_ptr link error with agvtool version variables?

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 generate开发者_JAVA技巧d 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!


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜