SourceKitten icon indicating copy to clipboard operation
SourceKitten copied to clipboard

Always link to Foundation

Open jpsim opened this issue 10 years ago • 4 comments

Otherwise, code that compiles and uses Foundation symbols but without import Foundation in the file would generate bad USRs (s:F10RealmSwift12migrateRealmERR vs s:F10RealmSwift12migrateRealmFTSS13encryptionKeyGSqCSo6NSData__GSqCSo7NSError_.

jpsim avatar May 05 '15 23:05 jpsim

Aren't those files just incorrect if they don't import Foundation?

segiddins avatar May 05 '15 23:05 segiddins

They'll still compile. I think Xcode implicitly links to Foundation, even though that's not exposed in the compiler flags when running xcodebuild

jpsim avatar May 05 '15 23:05 jpsim

There’s a build flag for whether Xcode should link Foundation implicitly:

When linking a target using Objective-C code, implicitly link in Foundation (and if deploying back to an older OS) a backwards compatibility library to allow newer language features to run on an OS where the runtime support is not natively available. Most targets that use Objective-C will want to use this, although there are rare cases where a target may wish to opt out of this behavior. [CLANG_LINK_OBJC_RUNTIME, -fobjc-link-runtime]

The setting is on by default.

rastersize avatar Jan 07 '16 22:01 rastersize

Ah, thanks for sharing that @rastersize! Maybe it's as simple as adding -fobjc-link-runtime to compiler arguments.

jpsim avatar Jan 07 '16 22:01 jpsim