[swift-dev] Disable objc interop

Scott Knight knightsc at gmail.com
Wed Feb 10 14:07:47 CST 2016


I've been trying to look if there's a way with swift build or swiftc itself
to disable objective-c interoperability. I've gotten as far as inspecting
the IR output with the disable-obc-interop flag with this command

swiftc -emit-ir -Xfrontend -disable-llvm-optzns -Xfrontend
-disable-objc-interop -O Sources/main.swift

But I haven't been able to figure out if there's a way to do this with
swift build. No matter what I do when I inspect the compiled binary

otool -L .build/debug/Test
.build/debug/Hello:
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version
228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
1226.10.1)
@rpath/libswiftCore.dylib (compatibility version 0.0.0, current version
0.0.0)

libobjc is always linked in. I ran the emit-ir command above both with and
without disable-obc-interop and could see in the emitted IR that this line
was removed when using the disable-obc-interop flag

!7 = !{!"-lobjc"}

Is there something I'm missing or is this just not supported currently? I
don't have a practical use case currently for this but was just curious to
better understand the swift runtime and internals.

Thanks,
Scott Knight
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160210/189b5a3e/attachment.html>


More information about the swift-dev mailing list