Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Jakub Bednář via swift-users
C++ puts function pointers (or indexes into virtual function table) into the build binary so it looses track of what exactly it was build against. If in runtime you give it an object that has functions with different signature (types/number of parameters) or different semantics (it does

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Jonathan Prescott via swift-users
In most systems, including macOS, everyone uses the same linker, no matter what language. swiftc, at the object code level, supports the same ABI as clang(C/C++/Obj-C/Objc-C++), and in fact, uses a lot of the compiler infrastructure as clang, including pieces of clang. Your example is the

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
The way I look at it is that Swift wants all symbols resolved when linking. C++ is probably very lenient toward full resolution, and as long as you know that a certain unresolved reference is not used, you can safely ignore the warning. Or maybe the C++ compiler is just very clever and can

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Jonathan Prescott via swift-users
I think the process is the same as C/C++/Obj-C/Obj-C++, except it’s labelled differently for Swift. In Xcode, users set “C Pre-processor Macro Definitions” with things like USE_LOGGING. In Swift, since it doesn’t use the C pre-processor, Xcode has a separate build setting called “Active

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Jakub Bednář via swift-users
Hi Rien, looks like a good way around my problem. Still I wonder why this does not work in Swift as it does work in Objective-C or even in strongly typed checked C++. Maybe it is some kind of Swift’s security measure to avoid hard-to-debug bugs in C++ caused by virtual table inconsistencies.

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
Well, that was a bit short… When you want to use logging, define the ACC “USE_LOGGING” in the build settings. When you don’t want to use logging, don’t define the ACC. PS: You can get my logging framework from github: https://github.com/Balancingrock/SwifterLog Regards, Rien Site:

Re: [swift-users] How to optionally link swift framework into another framework

2017-03-06 Thread Rien via swift-users
You need conditional compilation. Called “Active Compilation Conditions” in the build settings. For example define a ACC of “USE_LOGGING” Then in your code: #if USE_LOGGING import Logging #else struct Logging { func debug(message: string) {} } #endif Regards, Rien Site: