tuist / XcodeProj

📝 Read, update and write your Xcode projects

Home Page:https://xcodeproj.tuist.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add/remote framework for target

purkylin opened this issue · comments

func addFramework(name: String, to target: PBXTarget) {
    if let phase = getBuildPhase(for: "Frameworks", in: target) as? PBXFrameworksBuildPhase {
        let element = PBXFileElement(sourceTree: .buildProductsDir, path: "\(name).framework", name: "\(name).framework")
        let file = PBXBuildFile(file: element)
        phase.files?.append(file)
    }
}

Not work, the project filechangs:

"TEMP_DE02C97D-35B4-4B31-8562-343C44F8E473" /* (null) in Frameworks */,

Hey @purkylin. Notice that the file element that you are created must be added to the project. Find the PBXGroup of the directory you'd like to add the file to, and add it as a child.

Let me know if that works :)