I want Xcode to compile my Swift source files to bitcode (IR) instead of Mach-O objects. I'm aware that you can invoke the swift compiler with the emit-ir
flag, however adding this to the "Other Swift Flags" does not work for me. The flag is set for the initial call to swiftc
but it's not showing up as an argument in the subsequent calls made to swift
. As a result I get Mach-O 64-bit object
files.
For Objective-C I can simply achieve this by either adding the emit-llvm
flag to clang
or enabling LTO. What should I do for Swift?
I'm running the latest Xcode (7.3) with Swift 2.2.
EDIT: I figured out a workaround where I replace the swift compiler with a script that appends -emit-bc
to the argument list and forwards it to swiftc
. However, adding it to the Swift compiler flags in Xcode doesn't work either.