xcodeproj

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: 21 Imported by: 9

Documentation

Overview

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

for _, target := range project.Proj.Targets {
	fmt.Printf("%s target default configuration: %s\n", target.Name, target.BuildConfigurationList.DefaultConfigurationName)

	buildConfiguration := target.BuildConfigurationList.BuildConfigurations[0]
	bundleID := buildConfiguration.BuildSettings["PRODUCT_BUNDLE_IDENTIFIER"]
	fmt.Printf("%s target bundle id: %s\n", target.Name, bundleID)
}

schemes, err := project.Schemes()
if err != nil {
	panic(err)
}

for _, scheme := range schemes {
	entry := scheme.BuildAction.BuildActionEntries[0]
	targetID := entry.BuildableReference.BlueprintIdentifier

	target, ok := project.Proj.Target(targetID)
	if ok {
		fmt.Printf("%s scheme's main target: %s\n", scheme.Name, target.Name)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// XcodeProjExtension ...
	XcodeProjExtension = ".xcodeproj"
)

Variables

This section is empty.

Functions

func IsXcodeProj

func IsXcodeProj(pth string) bool

IsXcodeProj ...

func ReadPlistFile

func ReadPlistFile(path string) (serialized.Object, int, error)

ReadPlistFile returns a parsed object representing a plist file residing at path and a format identifier specifying the plist file format. Error is returned if: - file at path cannot be read - file is not a valid plist file Format IDs: - XMLFormat = 1 - BinaryFormat = 2 - OpenStepFormat = 3 - GNUStepFormat = 4

func WritePlistFile

func WritePlistFile(path string, entitlements serialized.Object, format int) error

WritePlistFile writes a parsed object representing a plist file according the format identifier specified. Error is returned if: - file at path cannot be written - format id is incorrect Valid format IDs: - XMLFormat = 1 - BinaryFormat = 2 - OpenStepFormat = 3 - GNUStepFormat = 4

Types

type BuildConfiguration

type BuildConfiguration struct {
	ID            string
	Name          string
	BuildSettings serialized.Object
}

BuildConfiguration ..

type ConfigurationList

type ConfigurationList struct {
	ID                       string
	DefaultConfigurationName string
	BuildConfigurations      []BuildConfiguration
}

ConfigurationList ...

type ProductReference

type ProductReference struct {
	Path string
}

ProductReference ...

type Proj

type Proj struct {
	ID                     string
	BuildConfigurationList ConfigurationList
	Targets                []Target
	Attributes             ProjectAtributes
}

Proj ...

func (Proj) Target

func (p Proj) Target(id string) (Target, bool)

Target ...

func (Proj) TargetByName

func (p Proj) TargetByName(name string) (Target, bool)

TargetByName ...

type ProjectAtributes

type ProjectAtributes struct {
	TargetAttributes serialized.Object
}

ProjectAtributes ...

**Deprecated**: use the func (p XcodeProj) Attributes() (serialized.Object, error) method instead

type Target

type Target struct {
	Type                   TargetType
	ID                     string
	Name                   string
	BuildConfigurationList ConfigurationList
	Dependencies           []TargetDependency
	ProductReference       ProductReference
	ProductType            string
	// contains filtered or unexported fields
}

Target ...

func (Target) DependsOn added in v1.0.6

func (t Target) DependsOn(targetID string) bool

DependsOn ...

func (Target) IsAppClipProduct added in v1.0.6

func (t Target) IsAppClipProduct() bool

IsAppClipProduct ...

func (Target) IsAppExtensionProduct

func (t Target) IsAppExtensionProduct() bool

IsAppExtensionProduct ...

func (Target) IsAppProduct

func (t Target) IsAppProduct() bool

IsAppProduct ...

func (Target) IsExecutableProduct

func (t Target) IsExecutableProduct() bool

IsExecutableProduct ...

func (Target) IsTestProduct

func (t Target) IsTestProduct() bool

IsTestProduct ...

func (Target) IsUITestProduct

func (t Target) IsUITestProduct() bool

IsUITestProduct ...

type TargetDependency

type TargetDependency struct {
	TargetID string
	// contains filtered or unexported fields
}

TargetDependency is a reference to another Target that is a dependency of a given Target

type TargetType

type TargetType string

TargetType ...

const (
	NativeTargetType    TargetType = "PBXNativeTarget"
	AggregateTargetType TargetType = "PBXAggregateTarget"
	LegacyTargetType    TargetType = "PBXLegacyTarget"
)

TargetTypes

type TargetsToAppIconSets

type TargetsToAppIconSets map[string][]string

TargetsToAppIconSets maps target names to an array app icon set absolute paths.

func AppIconSetPaths

func AppIconSetPaths(projectPath string) (TargetsToAppIconSets, error)

AppIconSetPaths parses an Xcode project and returns targets mapped to app icon set absolute paths.

type XcodeProj

type XcodeProj struct {
	Proj    Proj
	RawProj serialized.Object
	Format  int

	Name string
	Path string
	// contains filtered or unexported fields
}

XcodeProj ...

func Open

func Open(pth string) (XcodeProj, error)

Open ...

func (XcodeProj) Attributes

func (p XcodeProj) Attributes() (serialized.Object, error)

Attributes ...

func (XcodeProj) BuildConfigurationList

func (p XcodeProj) BuildConfigurationList(targetID string) (serialized.Object, error)

BuildConfigurationList ...

func (XcodeProj) BuildConfigurations

func (p XcodeProj) BuildConfigurations(buildConfigurationList serialized.Object) ([]serialized.Object, error)

BuildConfigurations ...

func (XcodeProj) DependentTargetsOfTarget added in v1.0.6

func (p XcodeProj) DependentTargetsOfTarget(target Target) []Target

DependentTargetsOfTarget returns with all dependencies of a given target, including the transitive dependencies. The returned list contains each target only once, using the target ID for uniqueness.

func (*XcodeProj) ForceCodeSign

func (p *XcodeProj) ForceCodeSign(configuration, targetName, developmentTeam, codesignIdentity, provisioningProfileUUID string) error

ForceCodeSign modifies the project's code signing settings to use manual code signing.

Overrides the target's `ProvisioningStyle`, `DevelopmentTeam` and clears the `DevelopmentTeamName` in the **TargetAttributes**. Overrides the target's `CODE_SIGN_STYLE`, `DEVELOPMENT_TEAM`, `CODE_SIGN_IDENTITY`, `CODE_SIGN_IDENTITY[sdk=iphoneos*]` `PROVISIONING_PROFILE_SPECIFIER`, `PROVISIONING_PROFILE` and `PROVISIONING_PROFILE[sdk=iphoneos*]` in the **BuildSettings**.

func (XcodeProj) ForceTargetBundleID

func (p XcodeProj) ForceTargetBundleID(target, configuration, bundleID string) error

ForceTargetBundleID updates the projects bundle ID for the specified target and configuration. An error is returned if: - the target or configuration is not found - the given target or configuration is not found

func (XcodeProj) ForceTargetCodeSignEntitlement

func (p XcodeProj) ForceTargetCodeSignEntitlement(target, configuration, entitlement string, value interface{}) error

ForceTargetCodeSignEntitlement updates the project descriptor behind p. It searches for the entitlements file for target and configuration and sets the entitlement key to the value provided. Error is returned: - if there's an error during reading or writing the file - if the file does not exist for the given target and configuration

func (XcodeProj) ReCreateSchemes

func (p XcodeProj) ReCreateSchemes() []xcscheme.Scheme

ReCreateSchemes creates new schemes based on the available Targets

func (XcodeProj) ReadTargetInfoplist

func (p XcodeProj) ReadTargetInfoplist(target, configuration string) (serialized.Object, int, error)

ReadTargetInfoplist ...

func (XcodeProj) Save

func (p XcodeProj) Save() error

Save the XcodeProj

Overrides the project.pbxproj file of the XcodeProj with the contents of `rawProj`

func (XcodeProj) SaveSharedScheme

func (p XcodeProj) SaveSharedScheme(scheme xcscheme.Scheme) error

SaveSharedScheme saves or overwrites a shared Scheme in the Project The file name will be determined using the Name field of the Scheme

func (XcodeProj) Scheme

func (p XcodeProj) Scheme(name string) (*xcscheme.Scheme, string, error)

Scheme returns the project's scheme by name and the project's absolute path.

func (XcodeProj) Schemes

func (p XcodeProj) Schemes() ([]xcscheme.Scheme, error)

Schemes returns the schemes considered by Xcode, when opening the given project. The considered schemes are the project shared schemes and the project user schemes (for the current user). The default (shared scheme) is present in the user's xcschememanagement.plist, any schemes related change trigger generating all the schemes as xcscheme files. If no schemes are found, Xcode recreates the default schemes unless 'Autocreate schemes' option is disabled (in this case actions are disabled in Xcode, and 'No schemes' message appears).

func (XcodeProj) SchemesWithAutocreateEnabled added in v1.0.15

func (p XcodeProj) SchemesWithAutocreateEnabled(isAutocreateSchemesEnabled bool) ([]xcscheme.Scheme, error)

SchemesWithAutocreateEnabled returns the schemes considered by Xcode, when opening the given project as part of a workspace. THIS SHOULD BE CALLED ONLY BY A WORKSPACE. If you want to get the schemes directly, please call XcodeProj.Schemes.

SchemesWithAutocreateEnabled behaves similarly to XcodeProj.Schemes, the only difference is that the 'Autocreate schemes' option is coming from the workspace settings.

func (XcodeProj) TargetAttributes

func (p XcodeProj) TargetAttributes() (serialized.Object, error)

TargetAttributes ...

func (XcodeProj) TargetBuildSettings

func (p XcodeProj) TargetBuildSettings(target, configuration string, customOptions ...string) (serialized.Object, error)

TargetBuildSettings ...

func (XcodeProj) TargetBundleID

func (p XcodeProj) TargetBundleID(target, configuration string) (string, error)

TargetBundleID ...

func (XcodeProj) TargetCodeSignEntitlements

func (p XcodeProj) TargetCodeSignEntitlements(target, configuration string) (serialized.Object, error)

TargetCodeSignEntitlements ...

func (XcodeProj) TargetCodeSignEntitlementsPath

func (p XcodeProj) TargetCodeSignEntitlementsPath(target, configuration string) (string, error)

TargetCodeSignEntitlementsPath ...

func (XcodeProj) TargetInfoplistPath

func (p XcodeProj) TargetInfoplistPath(target, configuration string) (string, error)

TargetInfoplistPath ...

func (XcodeProj) WriteTargetInfoplist

func (p XcodeProj) WriteTargetInfoplist(infoplist serialized.Object, format int, target, configuration string) error

WriteTargetInfoplist ...

Jump to

Keyboard shortcuts

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