如何改变Xcode中MyFramework_vers.c的编译标志? [英] How to change compilation flags for MyFramework_vers.c in Xcode?

查看:453
本文介绍了如何改变Xcode中MyFramework_vers.c的编译标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

启用Apple Generic Versioning后,Xcode会在 DERIVED_SOURCES_DIR 中自动产生一个 MyFramework_vers.c 字符串和数字定义为 const unsigned char [] const double

With Apple Generic Versioning enabled, Xcode autogenerates a MyFramework_vers.c file in the DERIVED_SOURCES_DIR, which contains the version string and number defined as const unsigned char[] and const double.

但是,使用 -Wmissing-variable-declarations (部分 -Weverything 警告


对于非静态变量MyFrameworkVersionString,没有前一个extern声明

没有之前的extern声明,静态变量MyFrameworkVersionNumber

no previous extern declaration for non-static variable 'MyFrameworkVersionString'
no previous extern declaration for non-static variable 'MyFrameworkVersionNumber'

似乎可能的解决方案是:

It seems the possible solutions are:


  • -Wno-missing-variable-declarations 添加到此文件的cflags

  • 添加 extern 在变量定义之上的声明

  • 添加 #import c $ c> extern 来自伞头的声明

  • add -Wno-missing-variable-declarations to the cflags for this file
  • add extern declarations above the variable definitions
  • add a #import that pulls in the extern declarations from the umbrella header

但我不知道如何做任何这些,因为文件存在于DerivedSources中,并且不是编译源阶段的成员。我缺少了什么?

But I can't figure out how to do any of these since the file lives in DerivedSources and isn't a member of the Compile Sources phase. What am I missing?

(我发现了 VERSION_INFO_EXPORT_DECL 设置,允许我标记变量 extern ,但是我得到了extern变量有一个初始化器警告,从 -Wextern-initializer 帮助。)

(I found the VERSION_INFO_EXPORT_DECL setting which would allow me to mark the variables extern, but then I get the "extern variable has an initializer" warning, from -Wextern-initializer, so that doesn't help.)

推荐答案

我不知道如何修改这个文件的编译器参数,滥用 VERSION_INFO_EXPORT_DECL 的警告。将值设置为一个换行符,然后是 #importHeaderWithExternDeclarations.h和另一个换行符。在pbxproj它应该看起来像这样:

I don't know of a way to modify the compiler arguments for this file, but it's possible to address the warning by abusing VERSION_INFO_EXPORT_DECL. Set the value to a literal newline followed by #import "HeaderWithExternDeclarations.h" and another literal newline. In the pbxproj it should look something like this:

VERSION_INFO_EXPORT_DECL = "\n#import \"MyFramework.h\"\n";

如果要导入包含Objective-C的头,还需要更改 VERSION_INFO_FILE 为具有.m扩展名的值,如MyFramework_vers.m,因此生成的文件将被编译为Objective-C源。

If you want to import a header containing Objective-C you'll also need to change VERSION_INFO_FILE to a value with a .m extension such as MyFramework_vers.m so the generated file is compiled as Objective-C source.

或者,您可以使用相同的黑客插入pragma禁用警告:

Alternatively, you can use the same hack to insert a pragma to disable the warning:

VERSION_INFO_EXPORT_DECL = "\n#pragma clang diagnostic ignored \"-Wmissing-variable-declarations\"\n";

这篇关于如何改变Xcode中MyFramework_vers.c的编译标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆