Search in sources :

Example 6 with PBXCopyFilesBuildPhase

use of com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase in project buck by facebook.

the class ProjectGeneratorTest method testAppleWatchTarget.

@Test
public void testAppleWatchTarget() throws IOException {
    BuildTarget watchAppBinaryTarget = BuildTarget.builder(rootPath, "//foo", "WatchAppBinary").build();
    TargetNode<?, ?> watchAppBinaryNode = AppleBinaryBuilder.createBuilder(watchAppBinaryTarget).build();
    BuildTarget watchAppTarget = BuildTarget.builder(rootPath, "//foo", "WatchApp").addFlavors(DEFAULT_FLAVOR).build();
    TargetNode<?, ?> watchAppNode = AppleBundleBuilder.createBuilder(watchAppTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setXcodeProductType(Optional.of("com.apple.product-type.application.watchapp2")).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(watchAppBinaryTarget).build();
    BuildTarget hostAppBinaryTarget = BuildTarget.builder(rootPath, "//foo", "HostAppBinary").build();
    TargetNode<?, ?> hostAppBinaryNode = AppleBinaryBuilder.createBuilder(hostAppBinaryTarget).build();
    BuildTarget hostAppTarget = BuildTarget.builder(rootPath, "//foo", "HostApp").build();
    TargetNode<?, ?> hostAppNode = AppleBundleBuilder.createBuilder(hostAppTarget).setExtension(Either.ofLeft(AppleBundleExtension.APP)).setInfoPlist(new FakeSourcePath("Info.plist")).setBinary(hostAppBinaryTarget).setDeps(ImmutableSortedSet.of(watchAppTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(watchAppNode, watchAppBinaryNode, hostAppNode, hostAppBinaryNode));
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:HostApp");
    assertEquals(target.getProductType(), ProductType.APPLICATION);
    ProjectGeneratorTestUtils.assertHasSingletonCopyFilesPhaseWithFileEntries(target, ImmutableList.of("$BUILT_PRODUCTS_DIR/WatchApp.app"));
    PBXCopyFilesBuildPhase copyBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXCopyFilesBuildPhase.class);
    assertEquals(copyBuildPhase.getDstSubfolderSpec(), CopyFilePhaseDestinationSpec.builder().setDestination(PBXCopyFilesBuildPhase.Destination.PRODUCTS).setPath("$(CONTENTS_FOLDER_PATH)/Watch").build());
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) Test(org.junit.Test)

Example 7 with PBXCopyFilesBuildPhase

use of com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase in project buck by facebook.

the class ProjectGenerator method getSingleCopyFilesBuildPhase.

private PBXCopyFilesBuildPhase getSingleCopyFilesBuildPhase(CopyFilePhaseDestinationSpec destinationSpec, Iterable<TargetNode<?, ?>> targetNodes) {
    PBXCopyFilesBuildPhase copyFilesBuildPhase = new PBXCopyFilesBuildPhase(destinationSpec);
    HashSet<UnflavoredBuildTarget> frameworkTargets = new HashSet<UnflavoredBuildTarget>();
    for (TargetNode<?, ?> targetNode : targetNodes) {
        PBXFileReference fileReference = getLibraryFileReference(targetNode);
        PBXBuildFile buildFile = new PBXBuildFile(fileReference);
        if (fileReference.getExplicitFileType().equals(Optional.of("wrapper.framework"))) {
            UnflavoredBuildTarget buildTarget = targetNode.getBuildTarget().getUnflavoredBuildTarget();
            if (frameworkTargets.contains(buildTarget)) {
                continue;
            }
            frameworkTargets.add(buildTarget);
            NSDictionary settings = new NSDictionary();
            settings.put("ATTRIBUTES", new String[] { "CodeSignOnCopy", "RemoveHeadersOnCopy" });
            buildFile.setSettings(Optional.of(settings));
        }
        copyFilesBuildPhase.getFiles().add(buildFile);
    }
    return copyFilesBuildPhase;
}
Also used : NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) PBXCopyFilesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference) HashSet(java.util.HashSet)

Aggregations

PBXCopyFilesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXCopyFilesBuildPhase)7 Test (org.junit.Test)6 PBXBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildPhase)5 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)4 BuildTarget (com.facebook.buck.model.BuildTarget)4 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)4 CopyFilePhaseDestinationSpec (com.facebook.buck.apple.xcode.xcodeproj.CopyFilePhaseDestinationSpec)3 NSDictionary (com.dd.plist.NSDictionary)2 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)2 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)2 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)2 PathSourcePath (com.facebook.buck.rules.PathSourcePath)2 SourcePath (com.facebook.buck.rules.SourcePath)2 TargetGraph (com.facebook.buck.rules.TargetGraph)2 TargetNode (com.facebook.buck.rules.TargetNode)2 NSString (com.dd.plist.NSString)1 AppleAssetCatalogBuilder (com.facebook.buck.apple.AppleAssetCatalogBuilder)1 AppleBinaryBuilder (com.facebook.buck.apple.AppleBinaryBuilder)1 AppleBundleBuilder (com.facebook.buck.apple.AppleBundleBuilder)1 AppleBundleExtension (com.facebook.buck.apple.AppleBundleExtension)1