簡體   English   中英

ARC和非ARC文件的組合不起作用

[英]Combining ARC and non-ARC files not working

一旦我將-fno-objc-arc標志添加到Build Phases中的一個或多個單獨文件,我的MyProject-Prefix.pch文件就會被拋入非ARC模式,導致150個警告,如“警告:沒有'賦值','保留',或'copy'屬性被指定 - 'assign'被假定為“被拋出。

這是編譯MyProject-Prefix.pch的clang日志輸出。 如您所見,-fobjc-arc標志出現,但稍后會添加-no-fobjc-arc,我假設它會覆蓋ARC。 只有當我將-fno-objc-arc添加到Build Phases中的單個.m源文件時(每個人都可以混合ARC和非ARC文件的標准建議),才會發生這種情況。

有任何想法嗎?

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c-header -arch i386 -fmessage-length=0 -std=gnu99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -DDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -fexceptions -fasm-blocks -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.6 -g -Wno-conversion -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -iquote /Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/MyProject-generated-files.hmap -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/MyProject-own-target-headers.hmap -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/MyProject-all-target-headers.hmap -iquote /Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/MyProject-project-headers.hmap -iquoteOAuth2Client -iquoteOAuth2Client/Sources -iquoteOAuth2Client/Sources/OAuth2Client -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Products/Debug-iphonesimulator/include -I../../Source/facebook-ios-sdk/src -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Products/Debug-iphonesimulator/../three20 -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Products/Debug-iphonesimulator/../../three20 -I../../Source/three20/Build/Products/three20 -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/DerivedSources/i386 -I/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/MyProject.build/Debug-iphonesimulator/MyProject.build/DerivedSources -F/Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Products/Debug-iphonesimulator -F/Users/steve/Desktop/MyProject/YelpAPI/Frameworks -fno-objc-arc --serialize-diagnostics /Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-eouuweehlrhtjxdsrgwseamnhnna/MyProject-Prefix.pch.dia -c /Users/steve/Desktop/MyProject/MyProject/MyProject-Prefix.pch -o /Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-eouuweehlrhtjxdsrgwseamnhnna/MyProject-Prefix.pch.pth -MMD -MT dependencies -MF /Users/steve/Library/Developer/Xcode/DerivedData/MyProject-ajtusdfivjqtabgvzfuzqifdjuis/Build/Intermediates/PrecompiledHeaders/MyProject-Prefix-eouuweehlrhtjxdsrgwseamnhnna/MyProject-Prefix.pch.d

這只是預料之中的。 您的.pch文件包含一些定義會導致在非ARC模式下編譯時出現警告的.pch很高。 很可能非弧編譯文件也會使用預編譯的頭文件,所以.pch文件中的頭文件應該在ARC和非ARC模式下都可編譯(畢竟,PCH機制在語義上等同於放入#imports.pch文件放入每個.m文件中)。

我會說這是XCode的一個錯誤,如果它仍然在所有非ARC編譯文件明確免除PCH編譯模型時發出這些警告。 顯然你無法關閉XCode下單個文件的預編譯頭文件的使用(就像你使用MS的VisualC ++一樣),所以我能給你的唯一建議就是讓你的.pch文件中的類兼容ARC和非ARC編譯。

我在嘗試使用標記我的兩個.m文件時遇到了同樣的錯誤

-fno-objc-arc

,並找不到解決方案,所以我只是將“Objective-C自動引用計數”變量設置為“否”並添加了

-fobjc-arc 

編譯器標志到使用ARC的所有.m文件。 這對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM