title: Swift package dependency with unsafe build flags: target integrity error
body: <h3>TL;DR</h3>
  <p>I am getting the following error for a local Swift package dependency when attempting to use it within an iOS project in Xcode:</p>
  <p><code>The package product 'DlibWrapper' cannot be used as a dependency of this target because it uses unsafe build flags.</code></p>
  <p>(I am using unsafe flags to specify static library location)</p>
  <p>I also tried to import the package as a remote branch-based dependency but it fails anyway.</p>
  <p>According to <a href="https://forums.swift.org/t/se-0238-package-manager-target-specific-build-settings/18341/10" rel="noreferrer">this post</a> on Swift forums the issue was addressed a while ago and a corresponding <a href="https://github.com/apple/swift-package-manager/pull/2254" rel="noreferrer">pull request</a> was already merged.</p>
  <p>The problem appears both with Swift 5.2.4 (Xcode 11.6) and 5.3 (Xcode 12 beta 3).</p>
  <p>Any clues what could be the issue?</p>
  <hr />
  <h3>Details</h3>
  <p>I am trying to build a Swift package that wraps <a href="http://dlib.net/" rel="noreferrer">dlib</a> library and use it within an iOS app. Because of the platform I can't use the <code>.systemLibrary</code> target to link the <code>dlib</code>. So I precompiled it in a static lib and packaged together with the wrapper code like so:</p>
  <pre class="lang-none prettyprint-override"><code>DlibWrapper/
    Libraries/
      dlib/
        include/
            ...
        lib/
          arm64/
            libdlib.a
  
    Sources/
      CWrapper/
        include/
          module.modulemap
          cwrapper.h
        cwrapper.cpp
  
      SwiftWrapper/
        SwiftWrapper.swift
  
    Package.swift
  </code></pre>
  <p>Simplified contents of the <code>DlibWrapper/Package.swift</code>:</p>
  <pre class="lang-swift prettyprint-override"><code>// swift-tools-version:5.3
  
  import PackageDescription
  
  let package = Package(
      name: &quot;DlibWrapper&quot;,
      platforms: [
          .iOS(.v13)
      ],
      products: [
          .library(
              name: &quot;DlibWrapper&quot;,
              targets: [&quot;CWrapper&quot;, &quot;SwiftWrapper&quot;])
      ],
      dependencies: [],
      targets: [
          .target(
              name: &quot;SwiftWrapper&quot;,
              dependencies: [&quot;CWrapper&quot;]
          ),
          .target(
              name: &quot;CWrapper&quot;,
  
              cxxSettings: [.headerSearchPath(&quot;../../Libraries/dlib/include&quot;)],
  
              linkerSettings: [
                  .linkedLibrary(&quot;dlib&quot;),
                  .linkedFramework(&quot;Accelerate&quot;, .when(platforms: [.iOS])),
  
                  // The error is caused by this line
                  .unsafeFlags([&quot;-LLibraries/dlib/lib/arm64&quot;], .when(platforms: [.iOS])),
              ]
          ),
      ],
      cxxLanguageStandard: .cxx1z
  )
  </code></pre>
  <p>I tried to use the <code>link</code> property inside the <code>module.modulemap</code> but compiler seems to ignore it. Also, giving an absolute path to the library in <code>.linkedLibrary()</code> in target manifest doesn't help, the linker complains it can't find the library.</p>
  <p>Any ideas for workarounds? (As a last resort I would probably package everything in a framework)</p>
  <p>Would appreciate any help.</p>
  <p>Thanks</p>