Search in sources :

Example 31 with NSString

use of com.dd.plist.NSString in project robovm by robovm.

the class IOSTarget method customizeInfoPList.

protected void customizeInfoPList(NSDictionary dict) {
    if (isSimulatorArch(arch)) {
        dict.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneSimulator")));
    } else {
        dict.put("CFBundleSupportedPlatforms", new NSArray(new NSString("iPhoneOS")));
        dict.put("DTPlatformVersion", sdk.getPlatformVersion());
        dict.put("DTPlatformBuild", sdk.getPlatformBuild());
        dict.put("DTSDKBuild", sdk.getBuild());
        // them from the installed Xcode.
        try {
            File versionPListFile = new File(new File(ToolchainUtil.findXcodePath()).getParentFile(), "version.plist");
            NSDictionary versionPList = (NSDictionary) PropertyListParser.parse(versionPListFile);
            File xcodeInfoPListFile = new File(new File(ToolchainUtil.findXcodePath()).getParentFile(), "Info.plist");
            NSDictionary xcodeInfoPList = (NSDictionary) PropertyListParser.parse(xcodeInfoPListFile);
            NSString dtXcodeBuild = (NSString) versionPList.objectForKey("ProductBuildVersion");
            if (dtXcodeBuild == null) {
                throw new NoSuchElementException("No ProductBuildVersion in " + versionPListFile.getAbsolutePath());
            }
            NSString dtXcode = (NSString) xcodeInfoPList.objectForKey("DTXcode");
            if (dtXcode == null) {
                throw new NoSuchElementException("No DTXcode in " + xcodeInfoPListFile.getAbsolutePath());
            }
            putIfAbsent(dict, "DTXcode", dtXcode.toString());
            putIfAbsent(dict, "DTXcodeBuild", dtXcodeBuild.toString());
        } catch (Exception e) {
            config.getLogger().warn("Failed to read DTXcodeBuild/DTXcode from current Xcode install. Will use fake values. (%s: %s)", e.getClass().getName(), e.getMessage());
        }
        // Fake Xcode 6.1.1 values if the above fails.
        putIfAbsent(dict, "DTXcode", "0611");
        putIfAbsent(dict, "DTXcodeBuild", "6A2008a");
    }
}
Also used : NSArray(com.dd.plist.NSArray) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) File(java.io.File) NoSuchElementException(java.util.NoSuchElementException) CompilerException(org.robovm.compiler.CompilerException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException)

Aggregations

NSString (com.dd.plist.NSString)31 NSDictionary (com.dd.plist.NSDictionary)22 NSArray (com.dd.plist.NSArray)18 Test (org.junit.Test)10 NSObject (com.dd.plist.NSObject)8 IOException (java.io.IOException)8 File (java.io.File)6 NSNumber (com.dd.plist.NSNumber)5 Path (java.nio.file.Path)5 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)4 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)4 Date (java.util.Date)4 PBXSourcesBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase)3 ExecutionContext (com.facebook.buck.step.ExecutionContext)3 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 NSDate (com.dd.plist.NSDate)2 PBXProject (com.facebook.buck.apple.xcode.xcodeproj.PBXProject)2 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)2