@@ -12,8 +12,8 @@ struct ProvisioningProfile {
1212
1313 var filename : String ,
1414 name : String ,
15- created : NSDate ,
16- expires : NSDate ,
15+ created : Date ,
16+ expires : Date ,
1717 appID : String ,
1818 teamID : String ,
1919 rawXML : String ,
@@ -22,14 +22,14 @@ struct ProvisioningProfile {
2222 static func getProfiles( ) -> [ ProvisioningProfile ] {
2323 var output : [ ProvisioningProfile ] = [ ]
2424
25- let fileManager = NSFileManager ( )
26- if let libraryDirectory = fileManager. URLsForDirectory ( . LibraryDirectory , inDomains: . UserDomainMask ) . first, libraryPath = libraryDirectory. path {
25+ let fileManager = FileManager ( )
26+ if let libraryDirectory = fileManager. urlsForDirectory ( . libraryDirectory , inDomains: . userDomainMask ) . first, libraryPath = libraryDirectory. path {
2727 let provisioningProfilesPath = libraryPath. stringByAppendingPathComponent ( " MobileDevice/Provisioning Profiles " ) as NSString
2828
29- if let provisioningProfiles = try ? fileManager. contentsOfDirectoryAtPath ( provisioningProfilesPath as String ) {
29+ if let provisioningProfiles = try ? fileManager. contentsOfDirectory ( atPath : provisioningProfilesPath as String ) {
3030 for provFile in provisioningProfiles {
3131 if provFile. pathExtension == " mobileprovision " {
32- let profileFilename = provisioningProfilesPath. stringByAppendingPathComponent ( provFile)
32+ let profileFilename = provisioningProfilesPath. appendingPathComponent ( provFile)
3333 if let profile = ProvisioningProfile ( filename: profileFilename) {
3434 output. append ( profile)
3535 }
@@ -44,24 +44,24 @@ struct ProvisioningProfile {
4444 init? ( filename: String) {
4545 let securityArgs = [ " cms " , " -D " , " -i " , filename]
4646
47- let taskOutput = NSTask ( ) . execute ( " /usr/bin/security " , workingDirectory: nil , arguments: securityArgs)
47+ let taskOutput = Task ( ) . execute ( " /usr/bin/security " , workingDirectory: nil , arguments: securityArgs)
4848 if taskOutput. status == 0 {
4949 self . rawXML = taskOutput. output
5050
51- if let results = try ? NSPropertyListSerialization . propertyListWithData ( taskOutput. output. dataUsingEncoding ( NSUTF8StringEncoding ) !, options: . Immutable , format: nil ) {
51+ if let results = try ? PropertyListSerialization . propertyList ( from : taskOutput. output. data ( using : String . Encoding . utf8 ) !, options: PropertyListSerialization . MutabilityOptions ( ) , format: nil ) {
5252
53- if let expirationDate = results. valueForKey ( " ExpirationDate " ) as? NSDate ,
54- creationDate = results. valueForKey ( " CreationDate " ) as? NSDate ,
55- name = results. valueForKey ( " Name " ) as? String ,
56- entitlements = results. valueForKey ( " Entitlements " ) ,
57- applicationIdentifier = entitlements. valueForKey ( " application-identifier " ) as? String ,
58- periodIndex = applicationIdentifier. characters. indexOf ( " . " ) {
53+ if let expirationDate = results. value ( forKey : " ExpirationDate " ) as? Date ,
54+ creationDate = results. value ( forKey : " CreationDate " ) as? Date ,
55+ name = results. value ( forKey : " Name " ) as? String ,
56+ entitlements = results. value ( forKey : " Entitlements " ) ,
57+ applicationIdentifier = entitlements. value ( forKey : " application-identifier " ) as? String ,
58+ periodIndex = applicationIdentifier. characters. index ( of : " . " ) {
5959
6060 self . filename = filename
6161 self . expires = expirationDate
6262 self . created = creationDate
63- self . appID = applicationIdentifier. substringFromIndex ( periodIndex . advancedBy ( 1 ) )
64- self . teamID = applicationIdentifier. substringToIndex ( periodIndex)
63+ self . appID = applicationIdentifier. substring ( from : applicationIdentifier . index ( periodIndex , offsetBy : 1 ) )
64+ self . teamID = applicationIdentifier. substring ( to : periodIndex)
6565 self . name = name
6666 self . entitlements = entitlements
6767
@@ -81,11 +81,11 @@ struct ProvisioningProfile {
8181 }
8282 }
8383
84- func getEntitlementsPlist( tempFolder: String) - > NSString? {
84+ func getEntitlementsPlist( _ tempFolder: String) - > NSString? {
8585 let mobileProvisionPlist = tempFolder. stringByAppendingPathComponent ( " mobileprovision.plist " )
8686 do {
87- try self . rawXML. writeToFile ( mobileProvisionPlist, atomically: false , encoding: NSUTF8StringEncoding )
88- let plistBuddy = NSTask ( ) . execute ( " /usr/libexec/PlistBuddy " , workingDirectory: nil , arguments: [ " -c " , " Print :Entitlements " , mobileProvisionPlist, " -x " ] )
87+ try self . rawXML. write ( toFile : mobileProvisionPlist, atomically: false , encoding: String . Encoding . utf8 )
88+ let plistBuddy = Task ( ) . execute ( " /usr/libexec/PlistBuddy " , workingDirectory: nil , arguments: [ " -c " , " Print :Entitlements " , mobileProvisionPlist, " -x " ] )
8989 if plistBuddy. status == 0 {
9090 return plistBuddy. output
9191 } else {
@@ -99,4 +99,4 @@ struct ProvisioningProfile {
9999 return nil
100100 }
101101 }
102- }
102+ }
0 commit comments