2015-09-27 32 views
1

我已經升級到Xcode 7,並突然出現一個目標未能建立與「宏名稱必須是標識符」消息。這個目標的調試配置可以正常工作,我可以在設備上運行它,但發佈配置不會生成。Xcode 7 - 宏名稱必須是一個標識符

錯誤指向目標的.pch文件,但對於許多其他目標(包括那些正在發佈的目標),相同的.pch文件可以正常生成。

以下是錯誤消息:

 
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. 

這裏是.PCH文件:

 
#import 

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

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

我已經嘗試過的乾淨和Xcode的重新啓動。

我會很感激任何指針,我該如何深入挖掘並找到問題所在。

+0

我有類似的問題,它是用於枚舉。你可以用enums.h的枚舉來更新你的問題嗎? – Miknash

+0

我刪除了「Enums.h」行,仍然存在相同的問題。那應該是別的東西。我會分享「Enums.h」,但它很大。試圖同時在項目的git歷史中找到任何東西... –

回答

1

問題出在編譯命令中的-D=1命令行選項。在構建設置中某處可能存在一個錯誤值,可能是在預處理器宏或其他C標誌中。

+0

這就是它!非常感謝。我不小心重新訪問了Xcode中的預處理器宏,並且對於發佈配置,我只設置了一個空間:TAXI(空間)= 1,它在Xcode,TAXI和= 1中創建了多個宏。因此,-D = 1。謝謝你的鷹銳利的眼睛和智慧! –

0

無論您在.pch文件中顯示的內容看起來不錯,它會爲我正確編譯。然而,編譯器抱怨下面的代碼沒有爲宏指定名稱。 #define必須後跟宏名稱,而在您的聲明中它是缺少的。您能否在您的代碼庫中搜索#define 1聲明並更正它。

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

作爲一個側面說明,請確保你沒有任何預處理器的值設置爲APPAPP設置爲1。要排除,請嘗試使用與APP不同的變量。

相關問題