Skip to content

Commit 3ac0874

Browse files
author
Alexander Lippling
committed
Added README.md and moved classes to package com.sap.prd.mobile.ios.mios.xcodeprojreader
Change-Id: Ib736d29b3315144094ed9bd6b97281c3615d4bd0
1 parent 69be9a4 commit 3ac0874

44 files changed

Lines changed: 286 additions & 154 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#Read Me
2+
3+
##Description
4+
5+
These classes implement a basic API for the Xcode project file (works also with Xcode 4.3).
6+
7+
Note: *The low level classes in the ```com.sap.prd.mobile.ios.mios.xcodeprojreader.jaxb``` package can be used to load and save arbitrary property lists.*
8+
9+
##Usage
10+
11+
###Create a property list parser
12+
13+
``` java
14+
JAXBPlistParser parser = new JAXBPlistParser();
15+
// Xcode project file has to be converted to XML
16+
parser.convert("path/to/project.pbxproj", "path/to/project.pbxproj/or/other/destination");
17+
Plist plist = parser.load(JAXBPlistParserTest.fileName);
18+
```
19+
20+
###Get/Set values
21+
22+
```java
23+
ProjectFile projectFile = new ProjectFile(plist);
24+
assertEquals("46", projectFile.getObjectVersion());
25+
26+
Project project = projectFile.getProject();
27+
28+
Target target = project.getTargets().get(0);
29+
assertEquals("MyTest", target.getName());
30+
31+
target = project.getTargets().getByName("MyTest");
32+
assertEquals("MyTest", target.getName());
33+
34+
BuildConfiguration config =
35+
project.getBuildConfigurationList().getBuildConfigurations().get(0);
36+
assertEquals("Debug",
37+
config.getName());
38+
39+
config = project.getBuildConfigurationList().getBuildConfigurations().getByName("Release");
40+
assertEquals("Release", config.getName());
41+
42+
BuildSettings buildSettings = config.getBuildSettings();
43+
assertEquals("5.1",
44+
buildSettings.getString("IPHONEOS_DEPLOYMENT_TARGET"));
45+
buildSettings.setString("IPHONEOS_DEPLOYMENT_TARGET", "4.0");
46+
assertEquals("4.0",
47+
buildSettings.getString("IPHONEOS_DEPLOYMENT_TARGET"));
48+
49+
assertEquals("YES",
50+
buildSettings.getString("VALIDATE_PRODUCT"));
51+
```
52+
53+
### Example: Add custom build phase
54+
####Low Level (not recommended)
55+
56+
```java
57+
Array buildPhaseRefs = project.getTargets().get(0).getArray("buildPhases");
58+
String ref = projectFile.generateReference();
59+
Dict phase = projectFile.createDict();
60+
phase.put("isa", "PBXShellScriptBuildPhase");
61+
phase.put("files", projectFile.createArray());
62+
phase.put("inputPaths", projectFile.createArray());
63+
phase.put("outputPaths", projectFile.createArray());
64+
phase.put("runOnlyForDeploymentPostprocessing", "0");
65+
phase.put("shellPath", "/bin/sh");
66+
phase.put("shellScript", "env > test.txt");
67+
projectFile.setObjectByReference(ref, phase);
68+
buildPhaseRefs.add(ref);
69+
parser.save(plist, "path/to/project.pbxproj");
70+
```
71+
72+
####High Level
73+
74+
```java
75+
ReferenceArray<BuildPhase> buildPhases = project.getTargets().get(0).getBuildPhases();
76+
ShellScriptBuildPhase phase2 = new ShellScriptBuildPhase(projectFile);
77+
phase2.setDefaultValues();
78+
phase2.setShellScript("env > test.txt");
79+
buildPhases.add(phase2);
80+
parser.save(plist, "path/to/project.pbxproj");
81+
```
82+
83+
Note: *Collections are created on the fly.*
84+
85+
``` java
86+
project.getTargets().get(0).getBuildPhases().size()
87+
```
88+
*would create a collection of targets and a collection of build phases if they don't exist. This is important to know, if you intend to save the property list later. If you don't want this behavior, you have to use the low level APIs.*
89+
90+
##Known limitations
91+
92+
The following elements are not parsed, yet:
93+
94+
- Date
95+
- Data
96+
- Integer
97+
- Real

src/main/java/com/sap/tip/production/xcode/Array.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/Array.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
import java.util.List;
44

src/main/java/com/sap/tip/production/xcode/BuildConfiguration.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/BuildConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public class BuildConfiguration extends NamedElement
44
{

src/main/java/com/sap/tip/production/xcode/BuildConfigurationList.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/BuildConfigurationList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public class BuildConfigurationList extends Element
44
{

src/main/java/com/sap/tip/production/xcode/BuildFile.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/BuildFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public class BuildFile extends Element
44
{

src/main/java/com/sap/tip/production/xcode/BuildSettings.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/BuildSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public class BuildSettings extends Element
44
{

src/main/java/com/sap/tip/production/xcode/Dict.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/Dict.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
import java.util.Map;
44

src/main/java/com/sap/tip/production/xcode/Element.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/Element.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public abstract class Element implements ValueProvider
44
{

src/main/java/com/sap/tip/production/xcode/ElementFactory.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/ElementFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public interface ElementFactory<T extends Element>
44
{

src/main/java/com/sap/tip/production/xcode/NamedElement.java renamed to src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/NamedElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.sap.tip.production.xcode;
1+
package com.sap.prd.mobile.ios.mios.xcodeprojreader;
22

33
public abstract class NamedElement extends Element
44
{

0 commit comments

Comments
 (0)