Search in sources :

Example 21 with SourceTreePath

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

the class NewNativeTargetProjectMutator method addFrameworksBuildPhase.

private void addFrameworksBuildPhase(PBXProject project, PBXNativeTarget target) {
    if (frameworks.isEmpty() && archives.isEmpty()) {
        return;
    }
    PBXGroup sharedFrameworksGroup = project.getMainGroup().getOrCreateChildGroupByName("Frameworks");
    PBXFrameworksBuildPhase frameworksBuildPhase = new PBXFrameworksBuildPhase();
    target.getBuildPhases().add(frameworksBuildPhase);
    for (FrameworkPath framework : frameworks) {
        SourceTreePath sourceTreePath;
        if (framework.getSourceTreePath().isPresent()) {
            sourceTreePath = framework.getSourceTreePath().get();
        } else if (framework.getSourcePath().isPresent()) {
            sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputPathToSourcePath(framework.getSourcePath().get()), Optional.empty());
        } else {
            throw new RuntimeException();
        }
        PBXFileReference fileReference = sharedFrameworksGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
        frameworksBuildPhase.getFiles().add(new PBXBuildFile(fileReference));
    }
    for (PBXFileReference archive : archives) {
        frameworksBuildPhase.getFiles().add(new PBXBuildFile(archive));
    }
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) PBXGroup(com.facebook.buck.apple.xcode.xcodeproj.PBXGroup) PBXFrameworksBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXFrameworksBuildPhase) FrameworkPath(com.facebook.buck.rules.coercer.FrameworkPath) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)

Aggregations

SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)21 NSString (com.dd.plist.NSString)10 Test (org.junit.Test)10 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)8 BuildTarget (com.facebook.buck.model.BuildTarget)8 PBXGroup (com.facebook.buck.apple.xcode.xcodeproj.PBXGroup)7 PBXTarget (com.facebook.buck.apple.xcode.xcodeproj.PBXTarget)7 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)7 ImmutableMap (com.google.common.collect.ImmutableMap)5 SourcePath (com.facebook.buck.rules.SourcePath)4 FrameworkPath (com.facebook.buck.rules.coercer.FrameworkPath)4 HumanReadableException (com.facebook.buck.util.HumanReadableException)4 Path (java.nio.file.Path)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 NSDictionary (com.dd.plist.NSDictionary)3 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)3 PathSourcePath (com.facebook.buck.rules.PathSourcePath)3 NSObject (com.dd.plist.NSObject)2 AppleBundleDescription (com.facebook.buck.apple.AppleBundleDescription)2 AppleLibraryDescription (com.facebook.buck.apple.AppleLibraryDescription)2