Linking an OS X CLI target with Swift using -ObjC fails

Originator:neocool2
Number:rdar://25289652 Date Originated:22-Mar-2016 01:46 PM
Status:Open Resolved:
Product:Developer Tools Product Version:7.3
Classification:Serious Bug Reproducible:Always
 
Summary:

The given project demonstrates an issue regarding Xcode 7.3 and linking an OS X CLI target using Swift.

If -ObjC is passed as a linker flag, linking will fail with errors like:

duplicate symbol _OBJC_CLASS_$__SwiftNativeNSError in:
    /Applications/Xcode-7.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx/libswiftRuntime.a(ErrorObject.mm.o)
    /Applications/Xcode-7.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift_static/macosx/libswiftCore.a(ErrorObject.mm.o)

Linking works fine if -ObjC is not being passed.

Steps to Reproduce:

1. Create a new project with an OS X CLI target, written in Swift
2. Add -ObjC to other linker flags

Expected Results:

The project compiles and links fine.

Actual Results:

Linking fails with duplicated symbol errors, see above.

Regression:

This has worked fine in previous versions of Xcode.

Notes:

An example project can be found here: https://github.com/neonichu/xcode-7.3-linker-issue

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!