Skip to content

Latest commit

 

History

History
183 lines (119 loc) · 5.56 KB

README.md

File metadata and controls

183 lines (119 loc) · 5.56 KB

Description

An API for manipulating Xcode project files.

Usage

Adding Source Files to a Project

XCProject* project = [[XCProject alloc] initWithFilePath:@"MyProject.xcodeproj"];
XCGroup* group = [project groupWithPathFromRoot:@"Main"];
XCClassDefinition* classDefinition = [[XCClassDefinition alloc] initWithName:@"MyNewClass"];
[classDefinition setHeader:@"<some-header-text>"];
[classDefinition setSource:@"<some-impl-text>"];

[group addClass:classDefinition];
[project save];

Specifying Source File Belongs to Target

XCSourceFile* sourceFile = [project fileWithName:@"MyNewClass.m"];
XCTarget* examples = [project targetWithName:@"Examples"];
[examples addMember:sourceFile];
[project save];

Adding a Xib File

This time, we'll use a convenience method on xcode_Group to specify the targets at the same time:

XCXibDefinition* xibDefinition = [[XCXibDefinition alloc] initWithName:@"MyXibFile" content:@"<xibXml>"];
[group addXib:xibDefinition toTargets:[project targets]];
[project save];

Adding a Framework

XCFrameworkDefinition* frameworkDefinition =
    [[XCFrameworkDefinition alloc] initWithFilePath:@"<framework path>" copyToDestination:NO];
[group addFramework:frameworkDefinition toTargets:[project targets]];
[project save];

Setting copyToDestination to YES, will cause the framework to be first copied to the group's directory within the project, and subsequently linked from there.

Adding an Image Resource

XCSourceFileDefinition* sourceFileDefinition = [[XCSourceFileDefinition alloc]
    initWithName:@"MyImageFile.png" data:[NSData dataWithContentsOfFile:<your image file name>]
    type:ImageResourcePNG];

[group addSourceFile:sourceFileDefinition];
[project save];

Adding a Header

XCSourceFileDefinition* header = [[XCSourceFileDefinition alloc]
    initWithName:@"SomeHeader.h" text:<your header text> type:SourceCodeHeader];

[group addSourceFile:header];
[project save];

Adding a sub-project

subProjectDefinition = [XCSubProjectDefinition withName:@"mySubproject" projPath=@"/Path/To/Subproject" type:XcodeProject];
[group addSubProject:subProjectDefinition toTargets:[project targets]];

Removing a sub-project

[group removeSubProject:subProjectDefinition];  //TODO: project should be able to remove itself from parent.

File write behavior

Creates the reference in the project and writes the contents to disk. If a file already exists at the specified location, its contents will be updated.

[definition setFileOperationStyle:FileOperationStyleOverwrite];

Creates the reference in the project. If a file already exists at the specified location, the contents will not be updated.

[definition setFileOperationStyle:FileOperationStyleAcceptExisting];

Creates the reference in the project, but does not write to disk. The filesystem is expected to be updated through some other means.

[definition setFileOperationStyle:FileOperationStyleReferenceOnly];

Docs

You've just read them! The Source/Tests folder contains further usasge examples. A good starting point is to run the test target in Xcode. This will extract a test project to the /tmp directory, where you'll be able to see the outcome for yourself.

Building

Just the Framework

Open the project in XCode and choose Product/Build.

Command-line Build

Includes Unit Tests, Integration Tests, Code Coverge and API reports installed to Xcode.

Requirements (one time only)

In addition to Xcode, requires the Appledoc and lcov packages. A nice way to install these is with MacPorts.

git clone https://github.com/tomaz/appledoc.git
sudo install-appledoc.sh
sudo port install lcov

NB: Xcode 4.3+ requires command-line tools to be installed separately.

Running the build (every other time)

ant 

Feature Requests and Contributions

. . . are very welcome.

If you're using the API shoot me an email and tell me what you're doing with it.

Compatibility

  • Xcode-editor has been tested on Xcode 4+. It should also work on earlier versions of Xcode. The AppCode IDE from JetBrains is not yet supported.
  • Uses ARC and weak references so requires OSX 64 bit, and iOS 5. (Non ARC version coming soon.)

Who's using it?

  • expanz: A RAD framework that enables .NET developers in producing cross-platform and cloud apps.
  • Less Painful: Automated functional testing for mobile applications.
  • Level Helper: A RAD framework for developing 2D games on iOS & Android.

Authors

With contributions from:

Thanks!

LICENSE

Apache License, Version 2.0, January 2004, http://www.apache.org/licenses/

  • © 2011 - 2012 expanz.com