[swift-dev] Using Objective C class in Swift (open source, Linux)

Труб Илья itrub at yandex.ru
Mon Feb 1 09:09:42 CST 2016


I'd like to note some interesting issue. If I try to input 

swiftc -c s.swift -Xcc -I<paths to my headers, including path to Foundation/NSObject.h> -import-objc-header C.h

then I get a lot of compile errors on ALL ObjectiveC code lines in NSObject.h, so, it seems that compiler does not recognize Objective C syntax at all.
But, if I (in another example) use -import-objc-header <pure C header file>
that all is OK: .swift source file with function invocations from pure C .h-file compiled successfully, .o-file is created. What is explanation of such phenomena and how it could be overcomed?




More information about the swift-dev mailing list