             }
         }
     }
+    var linkWith: [PbxProductReference] = []
+    for lw in _linkWith {
+        if !linkWith.map({$0.guid}).contains(lw.guid) { linkWith.append(lw) }
+    }
+
     let type :PbxProductReference.ReferenceType
     if iosPlatform {
         type = PbxProductReference.ReferenceType.Application

                guard let file = object as? PbxProductReference else { continue }
                precondition(str.hasSuffix(".a")) //not sure what to do in this case
                if file.name + ".a" == str {
                    linkWith.append(file)
                    //because we use dynamic libraries (due to rdar://24221024)
                    //we have to link with all our dependencies' linkWith as well
                    for o in objects {
                        //find the target for the file we're linking
                        guard let target = o as? PbxNativeTarget else { continue }
                        if target.productReference.name != file.name { continue }
                        //append its dependencies
                        linkWith.append(contentsOf: target.linkFiles)
                    }
                    break
                }

        fatalError("Unsupported output type \(task["output-type"])")
    }
    
    var _linkWith : [PbxProductReference] = []
    if let l = task["link-with-product"]?.vector {
        for item in l {
            guard let str = item.string else { fatalError("Not string link target \(item)")}
