2014-10-27 31 views
0

我試圖在swift文件中調用CFSwapInt32HostToBig(< #arg:UInt32#>)方法。我已經將CoreFoundation Framework添加到項目中,並且在我的swift文件的頂部有「import CoreFoundation」。當我開始鍵入方法名稱時,XCode建議該方法向我表明Xcode正在從該框架中識別方法。我在Xcode中沒有任何錯誤,暗示我的所有語法都是正確的,但是當我編譯時,出現以下錯誤。Swift中的Core Foundation Framework錯誤

 
> Ld DerivedData/AudioToy/Build/Products/Debug-iphonesimulator/AudioToy.app/AudioToy normal x86_64 
    cd /Users/michaliberman/Documents/Projects/Swift/AudioToy 
    export IPHONEOS_DEPLOYMENT_TARGET=8.0 
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Products/Debug-iphonesimulator -F/Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Products/Debug-iphonesimulator -filelist /Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Intermediates/AudioToy.build/Debug-iphonesimulator/AudioToy.build/Objects-normal/x86_64/AudioToy.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Intermediates/AudioToy.build/Debug-iphonesimulator/AudioToy.build/Objects-normal/x86_64/AudioToy.swiftmodule -mios-simulator-version-min=8.0 -framework CoreFoundation -framework AVFoundation -framework AudioToolbox -Xlinker -dependency_info -Xlinker /Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Intermediates/AudioToy.build/Debug-iphonesimulator/AudioToy.build/Objects-normal/x86_64/AudioToy_dependency_info.dat -o /Users/michaliberman/Documents/Projects/Swift/AudioToy/DerivedData/AudioToy/Build/Products/Debug-iphonesimulator/AudioToy.app/AudioToy 

Undefined symbols for architecture x86_64: 
    "_CASwapFloat32", referenced from: 
     _CASwapFloat32HostToBig in AudioStudio.o 
    "__OSSwapInt32", referenced from: 
     _CFSwapInt32HostToBig in AudioStudio.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我已經刪除並重新導入框架,但我仍然得到錯誤。當我點擊方法名稱時,它會顯示聲明方法的頭文件,如果點擊該頭文件,我會看到它在框架中。當問題出現在框架內時,我不確定該怎麼做。

回答

0

使用bigEndianlittleEndian方法

let valueLE16 = 16 
let valueBE16 = valueLE16.bigEndian 

println("valueLE16: \(valueLE16)") // valueLE16: 16 
println("valueBE16: \(valueBE16)") // valueBE16: 1152921504606846976 

let valueLE16: Int16 = 16 //UnsafePointer<UInt16>(value.bytes)[0] 
let valueBE16: Int16 = valueLE16.bigEndian 

println("valueLE16: \(valueLE16)") // valueLE16: 16 
println("valueBE16: \(valueBE16)") // valueBE16: 4096