use of org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer in project gradle by gradle.
the class GenerateXcodeProjectFileTask method configure.
@Override
protected void configure(XcodeProjectFile projectFile) {
PBXProject project = new PBXProject(getProject().getPath());
project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_DEBUG);
project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(BUILD_RELEASE);
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getSources(), "Sources");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getHeaders(), "Headers");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getTests(), "Tests");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getRoot());
for (XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
project.getTargets().add(toGradlePbxTarget(xcodeTarget));
project.getTargets().add(toIndexPbxTarget(xcodeTarget));
if (xcodeTarget.isUnitTest()) {
// Creates XCTest configuration only if XCTest are present.
project.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(TEST_DEBUG);
} else {
File debugOutputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
PBXFileReference fileReference = new PBXFileReference(debugOutputFile.getName(), debugOutputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE);
fileReference.setExplicitFileType(Optional.of(xcodeTarget.getOutputFileType()));
project.getMainGroup().getOrCreateChildGroupByName(PRODUCTS_GROUP_NAME).getChildren().add(fileReference);
}
}
XcodeprojSerializer serializer = new XcodeprojSerializer(gidGenerator, project);
final NSDictionary rootObject = serializer.toPlist();
projectFile.transformAction(new Action<NSDictionary>() {
@Override
public void execute(NSDictionary dict) {
dict.clear();
dict.putAll(rootObject);
}
});
}
Aggregations