2323
2424import org .junit .Test ;
2525
26- import com .sap .prd .mobile .ios .mios .xcodeprojreader .Array ;
27- import com .sap .prd .mobile .ios .mios .xcodeprojreader .BuildConfiguration ;
28- import com .sap .prd .mobile .ios .mios .xcodeprojreader .BuildSettings ;
29- import com .sap .prd .mobile .ios .mios .xcodeprojreader .Dict ;
30- import com .sap .prd .mobile .ios .mios .xcodeprojreader .Plist ;
31- import com .sap .prd .mobile .ios .mios .xcodeprojreader .Project ;
32- import com .sap .prd .mobile .ios .mios .xcodeprojreader .ProjectFile ;
33- import com .sap .prd .mobile .ios .mios .xcodeprojreader .ReferenceArray ;
34- import com .sap .prd .mobile .ios .mios .xcodeprojreader .Target ;
3526import com .sap .prd .mobile .ios .mios .xcodeprojreader .buildphases .BuildPhase ;
3627import com .sap .prd .mobile .ios .mios .xcodeprojreader .buildphases .ShellScriptBuildPhase ;
3728import com .sap .prd .mobile .ios .mios .xcodeprojreader .jaxb .JAXBPlistParser ;
@@ -42,54 +33,57 @@ public class UsageExamples
4233 @ Test
4334 public void usage () throws Exception
4435 {
45- JAXBPlistParser parser = new JAXBPlistParser ();
46- Plist plist = parser .load (JAXBPlistParserTest .fileName );
36+ JAXBPlistParser parser = new JAXBPlistParser ();
37+
38+ // optional step, if project file is not already in XML format
39+ // parser.convert(JAXBPlistParserTest.fileName, JAXBPlistParserTest.fileName)
40+ Plist plist = parser .load (JAXBPlistParserTest .fileName );
4741
48- ProjectFile projectFile = new ProjectFile (plist );
49- assertEquals ("46" , projectFile .getObjectVersion ());
42+ ProjectFile projectFile = new ProjectFile (plist );
43+ assertEquals ("46" , projectFile .getObjectVersion ());
5044
51- Project project = projectFile .getProject ();
45+ Project project = projectFile .getProject ();
5246
53- Target target = project .getTargets ().get (0 );
54- assertEquals ("MyTest" , target .getName ());
47+ Target target = project .getTargets ().get (0 );
48+ assertEquals ("MyTest" , target .getName ());
5549
56- target = project .getTargets ().getByName ("MyTest" );
57- assertEquals ("MyTest" , target .getName ());
50+ target = project .getTargets ().getByName ("MyTest" );
51+ assertEquals ("MyTest" , target .getName ());
5852
59- BuildConfiguration config =
60- project .getBuildConfigurationList ().getBuildConfigurations ().get (0 );
61- assertEquals ("Debug" ,
62- config .getName ());
53+ BuildConfiguration config =
54+ project .getBuildConfigurationList ().getBuildConfigurations ().get (0 );
55+ assertEquals ("Debug" ,
56+ config .getName ());
6357
64- config = project .getBuildConfigurationList ().getBuildConfigurations ().getByName ("Release" );
65- assertEquals ("Release" , config .getName ());
58+ config = project .getBuildConfigurationList ().getBuildConfigurations ().getByName ("Release" );
59+ assertEquals ("Release" , config .getName ());
6660
67- BuildSettings buildSettings = config .getBuildSettings ();
68- assertEquals ("5.1" ,
69- buildSettings .getString ("IPHONEOS_DEPLOYMENT_TARGET" ));
70- assertEquals ("YES" ,
71- buildSettings .getString ("VALIDATE_PRODUCT" ));
61+ BuildSettings buildSettings = config .getBuildSettings ();
62+ assertEquals ("5.1" ,
63+ buildSettings .getString ("IPHONEOS_DEPLOYMENT_TARGET" ));
64+ assertEquals ("YES" ,
65+ buildSettings .getString ("VALIDATE_PRODUCT" ));
7266
7367// LOW LEVEL (not recommended)
74- Array buildPhaseRefs = project .getTargets ().get (0 ).getArray ("buildPhases" );
75- String ref = projectFile .generateReference ();
76- buildPhaseRefs .add (ref );
77- Dict phase = projectFile .createDict ();
78- phase .put ("isa" , "PBXShellScriptBuildPhase" );
79- phase .put ("files" , projectFile .createArray ());
80- phase .put ("inputPaths" , projectFile .createArray ());
81- phase .put ("outputPaths" , projectFile .createArray ());
82- phase .put ("runOnlyForDeploymentPostprocessing" , "0" );
83- phase .put ("shellPath" , "/bin/sh" );
84- phase .put ("shellScript" , "env > test.txt" );
85- projectFile .setObjectByReference (ref , phase );
68+ Array buildPhaseRefs = project .getTargets ().get (0 ).getArray ("buildPhases" );
69+ String ref = projectFile .generateReference ();
70+ buildPhaseRefs .add (ref );
71+ Dict phase = projectFile .createDict ();
72+ phase .put ("isa" , "PBXShellScriptBuildPhase" );
73+ phase .put ("files" , projectFile .createArray ());
74+ phase .put ("inputPaths" , projectFile .createArray ());
75+ phase .put ("outputPaths" , projectFile .createArray ());
76+ phase .put ("runOnlyForDeploymentPostprocessing" , "0" );
77+ phase .put ("shellPath" , "/bin/sh" );
78+ phase .put ("shellScript" , "env > test.txt" );
79+ projectFile .setObjectByReference (ref , phase );
8680
8781// HIGH LEVEL
88- ReferenceArray <BuildPhase > buildPhases = project .getTargets ().get (0 ).getBuildPhases ();
89- ShellScriptBuildPhase phase2 = new ShellScriptBuildPhase (projectFile );
90- phase2 .setDefaultValues ();
91- phase2 .setShellScript ("env > test.txt" );
92- buildPhases .add (phase2 );
82+ ReferenceArray <BuildPhase > buildPhases = project .getTargets ().get (0 ).getBuildPhases ();
83+ ShellScriptBuildPhase phase2 = new ShellScriptBuildPhase (projectFile );
84+ phase2 .setDefaultValues ();
85+ phase2 .setShellScript ("env > test.txt" );
86+ buildPhases .add (phase2 );
9387
9488//parser.save(plist, JAXBPlistParserTest.fileName);
9589 }
0 commit comments