Cross-platform Swfit

    After reading this, I am deeply worried. It involves lots of fiddling to make it work. However, after swift 3.x (I don't know which one was it), we have a better swift package generate-xcodeproj command which does lots of the fiddling for you. It worked, almost, until I try to run unit tests for a different platform, say iPhone. The problem is here.
    I’m no stranger to these sorts of problems, fortunately, (sadly); the problem manifests because iOS and macOS have different test-bundle layouts, so your framework will be placed in different places in each, thus you have to tell your tests to look in different places for each. The easiest way is just to set the test rpaths to:
    So here is what you do.
    • Go to Build Settings of your test target. Search for run. You will see Runpath Search Paths.
    • Add, under both Debug and Release, Any OS X SDK. Set the value to @loader_path/../Frameworks. (it was @loader_path/Frameworks originally.)
    • You are ready to go.