xcworkspace

package
v1.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 16 Imported by: 4

Documentation

Overview

Example
workspace, err := Open("workspace.xcworkspace")
if err != nil {
	panic(err)
}

var fileRefLocations []string
for _, fileRef := range workspace.FileRefs {
	pth, err := fileRef.AbsPath("workspace_dir")
	if err != nil {
		panic(err)
	}

	fileRefLocations = append(fileRefLocations, pth)
}
for _, group := range workspace.Groups {
	groupPth, err := group.AbsPath("workspace_dir")
	if err != nil {
		panic(err)
	}

	for _, fileRef := range group.FileRefs {
		pth, err := fileRef.AbsPath(groupPth)
		if err != nil {
			panic(err)
		}

		fileRefLocations = append(fileRefLocations, pth)
	}
}

var projects []xcodeproj.XcodeProj
for _, fileRefLocation := range fileRefLocations {
	if !xcodeproj.IsXcodeProj(fileRefLocation) {
		continue
	}

	project, err := xcodeproj.Open(fileRefLocation)
	if err != nil {
		panic(err)
	}
	projects = append(projects, project)
}
Output:

Index

Examples

Constants

View Source
const (
	// XCWorkspaceExtension ...
	XCWorkspaceExtension = ".xcworkspace"
)

Variables

This section is empty.

Functions

func IsWorkspace

func IsWorkspace(pth string) bool

IsWorkspace ...

Types

type FileRef

type FileRef struct {
	Location string `xml:"location,attr"`
}

FileRef ...

func (FileRef) AbsPath

func (f FileRef) AbsPath(dir string) (string, error)

AbsPath ...

func (FileRef) TypeAndPath

func (f FileRef) TypeAndPath() (FileRefType, string, error)

TypeAndPath ...

type FileRefType

type FileRefType string

FileRefType ...

const (
	AbsoluteFileRefType  FileRefType = "absolute"
	GroupFileRefType     FileRefType = "group"
	ContainerFileRefType FileRefType = "container"
)

Known FileRefTypes

type Group

type Group struct {
	Location string    `xml:"location,attr"`
	FileRefs []FileRef `xml:"FileRef"`
	Groups   []Group   `xml:"Group"`
}

Group ...

func (Group) AbsPath

func (g Group) AbsPath(dir string) (string, error)

AbsPath ...

func (Group) FileLocations

func (g Group) FileLocations(dir string) ([]string, error)

FileLocations ...

type Workspace

type Workspace struct {
	FileRefs []FileRef `xml:"FileRef"`
	Groups   []Group   `xml:"Group"`

	Name string
	Path string
}

Workspace represents an Xcode workspace

func Open

func Open(pth string) (Workspace, error)

Open ...

func (Workspace) FileLocations

func (w Workspace) FileLocations() ([]string, error)

FileLocations ...

func (Workspace) ProjectFileLocations

func (w Workspace) ProjectFileLocations() ([]string, error)

ProjectFileLocations ...

func (Workspace) Scheme

func (w Workspace) Scheme(name string) (*xcscheme.Scheme, string, error)

Scheme returns the scheme by name, and it's container's absolute path.

func (Workspace) SchemeBuildSettings

func (w Workspace) SchemeBuildSettings(scheme, configuration string, customOptions ...string) (serialized.Object, error)

SchemeBuildSettings ...

func (Workspace) Schemes

func (w Workspace) Schemes() (map[string][]xcscheme.Scheme, error)

Schemes returns the schemes considered by Xcode, when opening the given workspace. The considered schemes are the workspace shared schemes, the workspace user schemes (for the current user) and the embedded project's schemes (XcodeProj.SchemesWithAutocreateEnabled).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL