Use PBXBuildFile.create and PBXFileReference.create to inject new files into an existing XcodeProject instance. The objects are automatically injected into the project's objects dictionary.
import { PBXBuildFile, PBXFileReference } from "@bacons/xcode";
import path from "path";
// Assuming `project` is an instance of XcodeProject
const file = PBXBuildFile.create(project, {
fileRef: PBXFileReference.create(project, {
path: "MyFile.swift",
sourceTree: "<group>",
}),
});
import { PBXBuildFile, PBXFileReference } from "@bacons/xcode";
import path from "path";
// Get `project` from XcodeProject.
const file = PBXBuildFile.create(project, {
fileRef: PBXFileReference.create(project, {
path: "MyFile.swift",
sourceTree: "<group>",
}),
});