@Test public void testCopyFilesBuildPhaseIsBeforePostBuildScriptBuildPhase() throws NoSuchBuildTargetException { NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults(); CopyFilePhaseDestinationSpec.Builder specBuilder = CopyFilePhaseDestinationSpec.builder(); specBuilder.setDestination(PBXCopyFilesBuildPhase.Destination.FRAMEWORKS); specBuilder.setPath("script/input.png"); PBXBuildPhase copyFilesPhase = new PBXCopyFilesBuildPhase(specBuilder.build()); mutator.setCopyFilesPhases(ImmutableList.of(copyFilesPhase)); TargetNode<?> postbuildNode = XcodePostbuildScriptBuilder.createBuilder(BuildTargetFactory.newInstance("//foo:script")) .setCmd("echo \"hello world!\"") .build(); mutator.setPostBuildRunScriptPhasesFromTargetNodes( ImmutableList.<TargetNode<?>>of(postbuildNode)); NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject); PBXNativeTarget target = result.target; List<PBXBuildPhase> buildPhases = target.getBuildPhases(); PBXBuildPhase copyBuildPhaseToTest = getSingletonPhaseByType(target, PBXCopyFilesBuildPhase.class); PBXBuildPhase postBuildScriptPhase = getSingletonPhaseByType(target, PBXShellScriptBuildPhase.class); assertThat( buildPhases.indexOf(copyBuildPhaseToTest), lessThan(buildPhases.indexOf(postBuildScriptPhase))); }
@Test public void testCopyFilesBuildPhase() throws NoSuchBuildTargetException { NewNativeTargetProjectMutator mutator = mutatorWithCommonDefaults(); CopyFilePhaseDestinationSpec.Builder specBuilder = CopyFilePhaseDestinationSpec.builder(); specBuilder.setDestination(PBXCopyFilesBuildPhase.Destination.FRAMEWORKS); specBuilder.setPath("foo.png"); PBXBuildPhase copyPhase = new PBXCopyFilesBuildPhase(specBuilder.build()); mutator.setCopyFilesPhases(ImmutableList.of(copyPhase)); NewNativeTargetProjectMutator.Result result = mutator.buildTargetAndAddToProject(generatedProject); PBXBuildPhase buildPhaseToTest = getSingletonPhaseByType(result.target, PBXCopyFilesBuildPhase.class); assertThat(copyPhase, equalTo(buildPhaseToTest)); }