|
2 | 2 |
|
3 | 3 | ##Description |
4 | 4 |
|
5 | | -These classes implement a basic API for the Xcode project file (works also with Xcode 4.3). |
| 5 | +These classes implement a basic API for the Xcode project file (works also with Xcode 4.3.x). |
6 | 6 |
|
7 | 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 | 8 |
|
9 | 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.* |
| 10 | +See [UsageExamples.java](https://github.com/sap-production/XcodeProjectJavaAPI/blob/master/src/test/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/UsageExamples.java). |
89 | 11 |
|
90 | 12 | ##Known limitations |
91 | 13 |
|
92 | | -The following elements are not parsed, yet: |
| 14 | +In order to use this library, you have to convert the Xcode project file to XML (see ```convert``` method in [JAXBPlistParser.java](https://github.com/sap-production/XcodeProjectJavaAPI/blob/master/src/main/java/com/sap/prd/mobile/ios/mios/xcodeprojreader/jaxb/JAXBPlistParser.java). This step can only be done on MAC OS X. The project file cannot be converted back! |
93 | 15 |
|
94 | | -- Date |
95 | | -- Data |
96 | | -- Integer |
97 | | -- Real |
| 16 | +The remainder of the API uses standard Java features. |
0 commit comments