use of com.facebook.buck.apple.xcode.xcodeproj.PBXGroup in project buck by facebook.
the class NewNativeTargetProjectMutatorTest method testPrefixHeaderInSourceGroup.
@Test
public void testPrefixHeaderInSourceGroup() throws NoSuchBuildTargetException {
NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults();
SourcePath prefixHeader = new FakeSourcePath("Group1/prefix.pch");
mutator.setPrefixHeader(Optional.of(prefixHeader));
NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject, true);
// No matter where the prefixHeader file is it should always be directly inside Sources
PBXGroup sourcesGroup = result.targetGroup.get().getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(1));
PBXFileReference fileRef = (PBXFileReference) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("prefix.pch", fileRef.getName());
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXGroup in project buck by facebook.
the class ProjectGeneratorTest method testProjectStructureWithInfoPlist.
@Test
public void testProjectStructureWithInfoPlist() throws IOException {
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
BuildTarget bundleTarget = BuildTarget.builder(rootPath, "//foo", "bundle").build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setExportedHeaders(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))).build();
TargetNode<?, ?> bundleNode = AppleBundleBuilder.createBuilder(bundleTarget).setBinary(libraryTarget).setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK)).setInfoPlist(new FakeSourcePath(("Info.plist"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(libraryNode, bundleNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup bundleGroup = project.getMainGroup().getOrCreateChildGroupByName(bundleTarget.getFullyQualifiedName());
PBXGroup sourcesGroup = bundleGroup.getOrCreateChildGroupByName("Sources");
assertThat(bundleGroup.getChildren(), hasSize(2));
Iterable<String> childNames = Iterables.transform(sourcesGroup.getChildren(), PBXReference::getName);
assertThat(childNames, hasItem("Info.plist"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXGroup in project buck by facebook.
the class ProjectGeneratorTest method resourceDirectoriesDontHaveFolderTypeIfTheyCanHaveAMoreSpecificType.
@Test
public void resourceDirectoriesDontHaveFolderTypeIfTheyCanHaveAMoreSpecificType() throws IOException {
BuildTarget directoryTarget = BuildTarget.builder(rootPath, "//foo", "dir.iconset").build();
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "res").build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> directoryNode = ExportFileBuilder.newExportFileBuilder(directoryTarget).build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setDirs(ImmutableSet.of(new DefaultBuildTargetSourcePath(directoryTarget))).setFiles(ImmutableSet.of()).build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(directoryNode, resourceNode, libraryNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup mainGroup = project.getMainGroup();
PBXGroup resourcesGroup = mainGroup.getOrCreateDescendantGroupByPath(ImmutableList.of("//foo:lib", "Resources"));
PBXFileReference resource = (PBXFileReference) Iterables.get(resourcesGroup.getChildren(), 0);
assertThat(resource.getName(), equalTo("dir.iconset"));
assertThat(resource.getExplicitFileType(), not(equalTo(Optional.of("folder"))));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXGroup in project buck by facebook.
the class ProjectGeneratorTest method testGeneratedProjectStructureAndSettingsWithBridgingHeader.
@Test
public void testGeneratedProjectStructureAndSettingsWithBridgingHeader() throws IOException {
BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of()).setBridgingHeader(Optional.of(new FakeSourcePath("BridgingHeader/header1.h"))).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
projectGenerator.createXcodeProjects();
// check if bridging header file existing in the project structure
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup targetGroup = project.getMainGroup().getOrCreateChildGroupByName(buildTarget.getFullyQualifiedName());
PBXGroup sourcesGroup = targetGroup.getOrCreateChildGroupByName("Sources");
assertThat(sourcesGroup.getChildren(), hasSize(1));
PBXFileReference fileRefBridgingHeader = (PBXFileReference) Iterables.get(sourcesGroup.getChildren(), 0);
assertEquals("header1.h", fileRefBridgingHeader.getName());
// check for bridging header build setting
PBXTarget target = assertTargetExistsAndReturnTarget(project, "//foo:lib");
ImmutableMap<String, String> buildSettings = getBuildSettings(buildTarget, target, "Debug");
assertEquals("$(SRCROOT)/../BridgingHeader/header1.h", buildSettings.get("SWIFT_OBJC_BRIDGING_HEADER"));
}
use of com.facebook.buck.apple.xcode.xcodeproj.PBXGroup in project buck by facebook.
the class ProjectGeneratorTest method testResourcesUnderLibrary.
@Test
public void testResourcesUnderLibrary() throws IOException {
BuildTarget fileTarget = BuildTarget.builder(rootPath, "//foo", "file").build();
BuildTarget resourceTarget = BuildTarget.builder(rootPath, "//foo", "res").build();
BuildTarget libraryTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
TargetNode<?, ?> fileNode = ExportFileBuilder.newExportFileBuilder(fileTarget).build();
TargetNode<?, ?> resourceNode = AppleResourceBuilder.createBuilder(resourceTarget).setDirs(ImmutableSet.of()).setFiles(ImmutableSet.of(new DefaultBuildTargetSourcePath(fileTarget))).build();
TargetNode<?, ?> libraryNode = AppleLibraryBuilder.createBuilder(libraryTarget).setDeps(ImmutableSortedSet.of(resourceTarget)).build();
ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(fileNode, resourceNode, libraryNode));
projectGenerator.createXcodeProjects();
PBXProject project = projectGenerator.getGeneratedProject();
PBXGroup mainGroup = project.getMainGroup();
PBXGroup resourcesGroup = mainGroup.getOrCreateDescendantGroupByPath(ImmutableList.of("//foo:lib", "Resources"));
PBXFileReference resource = (PBXFileReference) Iterables.get(resourcesGroup.getChildren(), 0);
assertThat(resource.getName(), equalTo("file"));
}
Aggregations