Xcode 7 - 宏名称必须是标识符 [英] Xcode 7 - macro name must be an identifier

查看:39
本文介绍了Xcode 7 - 宏名称必须是标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已升级到 Xcode 7,突然我的一个目标无法构建,并显示宏名称必须是标识符"消息.此目标的调试配置构建正常,我可以在设备上运行它,但未构建发布配置.

该错误指向目标的 .pch 文件,但相同的 .pch 文件对于许多其他目标(包括那些已发布的目标)都可以正常构建.

错误信息如下:

<前>ProcessPCH/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer.chpchpfix..compilers.llvm.clang.1_0.compilercd/Users/stanislavdvoychenko/Documents/code/speedo导出 LANG=en_US.US-ASCII导出路径="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c-header -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -gmodules -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-missing-braces -Wparentheses-Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants-Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCOCOAPODS=1 -DCOCOAPODS=1 -DTAXI -D=1 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -fstrict-aliasing -Wdeprecated-declarations -miphoneos-version-min=7.0 -g -fvisibility=隐藏 -Wno-sign-conversion -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/taximeter.hmap -I/Users/stanislavdvoychenko/Library/Developer/Xcode/speedovedgagyicfwqpzsudcvwgxjqhwbgpte/Build/Products/Release-iphoneos/include -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/GoogleMapPub我/用户/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources/armv7 -I/Users/stanislaverDeveloper/XcodeLibrdaryDerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources -F/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicqudhpwgs/speedo-gagyicqfwgse/F/用户/stanislavdvoychenko/Documents/code/speedo/Pods/GoogleMaps/Frameworks -F/Users/stanislavdvoychenko/Documents/code/speedo -DNS_BLOCK_ASSERTIONS=1 -isystem/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -isystem/Users/stanislavdvoychenko/Documents/代码/speedo/Pods/Headers/Public/GoogleMaps -MD -MT 依赖项 -MF/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefixdfxcometerdzi.pch.d -c/Users/stanislavdvoychenko/Documents/code/speedo/speedometer/speedometer-Prefix.pch -o/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/builddspeed-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.pch --serialize-diagnostics/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgptates/compile-cropmeters/compileeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.dia在 :334 包含的文件中::4:10: 错误:宏名称必须是标识符#定义1^产生了 1 个错误.

这里是 .pch 文件:

<前>#进口#ifndef __IPHONE_4_0#warning 此项目使用仅在 iOS SDK 4.0 及更高版本中可用的功能."#万一#ifdef __OBJC__#import <UIKit/UIKit.h>#import <Foundation/Foundation.h>#import "Enums.h"#万一#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])

我已经尝试过干净和 Xcode 重启.

我将不胜感激任何关于如何深入挖掘并找到问题所在的指示.

解决方案

问题在于编译命令中的 -D=1 命令行选项.您的构建设置中某处的值不正确,可能在预处理器宏或其他 C 标志中.

I've upgraded to Xcode 7 and out of the sudden one of my targets fails to build with "macro name must be an identifier" message. Debug configuration of this target builds just ok and I can run it on the device, but release configuration doesn't build.

The error points to the target's .pch file, but same .pch file builds just ok for many other targets, including those that are release.

Here is the error message:

ProcessPCH /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.pch speedometer/speedometer-Prefix.pch normal armv7 c com.apple.compilers.llvm.clang.1_0.compiler
    cd /Users/stanislavdvoychenko/Documents/code/speedo
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c-header -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -gmodules -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DCOCOAPODS=1 -DCOCOAPODS=1 -DTAXI -D=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk -fstrict-aliasing -Wdeprecated-declarations -miphoneos-version-min=7.0 -g -fvisibility=hidden -Wno-sign-conversion -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/taximeter.hmap -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Products/Release-iphoneos/include -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -I/Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public/GoogleMaps -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources/armv7 -I/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/speedo.build/Release-iphoneos/taximeter.build/DerivedSources -F/Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Products/Release-iphoneos -F/Users/stanislavdvoychenko/Documents/code/speedo/Pods/GoogleMaps/Frameworks -F/Users/stanislavdvoychenko/Documents/code/speedo -DNS_BLOCK_ASSERTIONS=1 -isystem /Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public -isystem /Users/stanislavdvoychenko/Documents/code/speedo/Pods/Headers/Public/GoogleMaps -MD -MT dependencies -MF /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.d -c /Users/stanislavdvoychenko/Documents/code/speedo/speedometer/speedometer-Prefix.pch -o /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.pch --serialize-diagnostics /Users/stanislavdvoychenko/Library/Developer/Xcode/DerivedData/speedo-gagyicfwqpzsudcvwgxjqhwbgpte/Build/Intermediates/PrecompiledHeaders/speedometer-Prefix-copscroeimdxfkdvcsfifjmzires/speedometer-Prefix.pch.dia

In file included from :334:
:4:10: error: macro name must be an identifier
#define  1
         ^
1 error generated.

And here is the .pch file:

#import 

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import "Enums.h"
#endif
#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])

I've tried already the clean and Xcode restart.

I'll be grateful for any pointers for how can I dig deeper and find where the problem is.

解决方案

The problem is with the -D=1 command-line option in the compile command. You have a bad value somewhere in your build settings, probably in Preprocessor Macros or Other C Flags.

这篇关于Xcode 7 - 宏名称必须是标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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