Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions AppBox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
E1902B5F1E1661BE00C3E0F6 /* UpdateHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpdateHandler.m; sourceTree = "<group>"; };
E1902B621E16633A00C3E0F6 /* KeychainHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeychainHandler.h; sourceTree = "<group>"; };
E1902B631E16633A00C3E0F6 /* KeychainHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeychainHandler.m; sourceTree = "<group>"; };
E191F7C21E1E7B2A00D2A590 /* ALAppStoreUpload.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = ALAppStoreUpload.sh; sourceTree = "<group>"; };
E191F7C31E1E7B3B00D2A590 /* XcodeAppStoreUpload.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = XcodeAppStoreUpload.sh; sourceTree = "<group>"; };
E1C148731E027A6100EE637F /* AFNetworking.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = AFNetworking.framework; sourceTree = "<group>"; };
E1CFC65C1D7E7FEA005872BE /* Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Common.h; sourceTree = "<group>"; };
E1CFC65D1D7E7FEA005872BE /* Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Common.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -341,9 +343,11 @@
isa = PBXGroup;
children = (
E13946141DF2FBAD00B3FAD0 /* ProjectBuildScript.sh */,
E13946151DF2FBAD00B3FAD0 /* WorkspaceBuildScript.sh */,
E172E13B1DEEB3B900405EF2 /* GetSchemeScript.sh */,
E10B82211DF0498600BBE0CD /* TeamIDScript.sh */,
E172E13B1DEEB3B900405EF2 /* GetSchemeScript.sh */,
E13946151DF2FBAD00B3FAD0 /* WorkspaceBuildScript.sh */,
E191F7C21E1E7B2A00D2A590 /* ALAppStoreUpload.sh */,
E191F7C31E1E7B3B00D2A590 /* XcodeAppStoreUpload.sh */,
);
path = Commands;
sourceTree = "<group>";
Expand Down
91 changes: 47 additions & 44 deletions AppBox/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions AppBox/Commands/ALAppStoreUpload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# ALAppStoreUpload.sh
# AppBox
#
# Created by Vineet Choudhary on 05/01/17.
# Copyright © 2017 Developer Insider. All rights reserved.

#{1} - Application Loader Directory
cd "${1}"

# Validate App
#{2} - IPA File Path
#{3} - itunesconnect username
#{4} - itunesconnect password
altool --validate-app -f "${2}" -u "${3}" -p "${4}" --output-format xml


# Upload App
altool --upload-app -f "${2}" -u "${3}" -p "${4}" --output-format xml
7 changes: 7 additions & 0 deletions AppBox/Commands/XcodeAppStoreUpload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# XcodeAppStoreUpload.sh
# AppBox
#
# Created by Vineet Choudhary on 05/01/17.
# Copyright © 2017 Developer Insider. All rights reserved.
1 change: 1 addition & 0 deletions AppBox/Common/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define abBuildLocation @"~/Desktop"

//others
#define abTeamIdLength 10
#define abEmptyString @""


Expand Down
67 changes: 28 additions & 39 deletions AppBox/Common/KeychainHandler/KeychainHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,39 @@
#import "KeychainHandler.h"
static NSString *const CERTIFICATE_KEY = @"CerKey";
static NSString *const CERTIFICATE_KEY_READABLE = @"CerKeyReadable";

@implementation KeychainHandler

#pragma mark - Get Team Id
+ (NSArray *)getAllTeamId{
NSError *error = nil;
NSArray *certficates = [self allKeychainCertificatesWithError:&error];
NSMutableArray *plainCertifcates = [[NSMutableArray alloc] init];
NSMutableArray *tempTeamIds = [[NSMutableArray alloc] init];
////////

[certficates enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableDictionary *certProperties = [self getPlainCertificate:obj];
if([certProperties objectForKey:abTeamId])
[plainCertifcates addObject:certProperties];
}];
NSMutableDictionary *dict = [plainCertifcates mutableCopy];
NSLog(@"Plan certificates %@",dict);
////////////////////
plainCertifcates = [NSMutableArray new];
[certficates enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSMutableDictionary *certProperties = [[NSMutableDictionary alloc] init];
NSString *certLabel = [obj valueForKey:(NSString *)kSecAttrLabel];
NSArray *certComponent = [certLabel componentsSeparatedByString:@": "];
if (certComponent.count == 2 &&
([[[certComponent firstObject] lowercaseString] isEqualToString:abiPhoneDistribution] ||
[[[certComponent firstObject] lowercaseString] isEqualToString:abiPhoneDeveloper])){
NSArray *certDetailsComponent = [[certComponent lastObject] componentsSeparatedByString:@" ("];
if (certDetailsComponent.count == 2){
NSString *teamId = [[certDetailsComponent lastObject] stringByReplacingOccurrencesOfString:@")" withString:abEmptyString];
[certProperties setValue:certLabel forKey:abFullName];
[certProperties setValue:[certComponent lastObject] forKey:abTeamName];
[certProperties setObject:teamId forKey:abTeamId];
if ([teamId containsString:@" "]){

}
if (![tempTeamIds containsObject:teamId] && ![teamId containsString:@" "]){
[tempTeamIds addObject:teamId];
[plainCertifcates addObject:certProperties];
}
}
}

NSString *teamId = [certProperties objectForKey:abTeamId];
NSString *teamName = [certProperties objectForKey:abTeamName];
NSString *fullName = [certProperties objectForKey:abFullName];

NSPredicate *existingTeam = [NSPredicate predicateWithFormat:@"SELF.teamId = %@ AND SELF.teamName = %@ AND SELF.fullName = %@",teamId, teamName, fullName];
NSLog(@"filter - %@",[plainCertifcates filteredArrayUsingPredicate:existingTeam]);
if (![teamId containsString:@" "] && teamId.length == abTeamIdLength //filter team id
&& ([fullName.lowercaseString containsString:abiPhoneDeveloper]
|| [fullName.lowercaseString containsString:abiPhoneDistribution]) //filter certifcates
&& [plainCertifcates filteredArrayUsingPredicate:existingTeam].count == 0 //filter existing team
){
[plainCertifcates addObject:certProperties];
}
}];

[plainCertifcates sortUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return [obj1 valueForKey:abTeamId] > [obj2 valueForKey:abTeamId];
}];
return plainCertifcates;
}
+ (NSArray *)allKeychainCertificatesWithError:(NSError *__autoreleasing *)error
{

+ (NSArray *)allKeychainCertificatesWithError:(NSError *__autoreleasing *)error{
NSDictionary *options = @{(__bridge id)kSecClass: (__bridge id)kSecClassCertificate,
(__bridge id)kSecMatchLimit: (__bridge id)kSecMatchLimitAll};
CFArrayRef certs = NULL;
Expand All @@ -68,41 +52,43 @@ + (NSArray *)allKeychainCertificatesWithError:(NSError *__autoreleasing *)error
}
return certificates;
}

+ (NSMutableDictionary *)getPlainCertificate:(id)certificate{
NSMutableDictionary *plainCertificate = [NSMutableDictionary new];
[plainCertificate addEntriesFromDictionary:[self getSubjectNameDetailsFromCertificate:certificate]];
[plainCertificate addEntriesFromDictionary:[self getIssuerDetailsFromCertificate:certificate]];
return plainCertificate;
}

+(NSMutableDictionary *)getIssuerDetailsFromCertificate:(id)certificate{
NSMutableDictionary *sectionKeys = [NSMutableDictionary new];
[sectionKeys setObject:abExpiryDate forKey:((__bridge id)kSecOIDX509V1ValidityNotAfter)];
// [sectionKeys setObject:abTeamId forKey:((__bridge id)kSecOIDOrganizationalUnitName)];
return [self getCertificateDetails:certificate withSectionIdKey:(__bridge id)kSecOIDX509V1IssuerName withSectionKeys:sectionKeys];
}

+(NSMutableDictionary *)getSubjectNameDetailsFromCertificate:(id)certificate{
NSMutableDictionary *sectionKeys = [NSMutableDictionary new];
[sectionKeys setObject:abTeamName forKey:((__bridge id)kSecOIDOrganizationName)];
[sectionKeys setObject:abTeamId forKey:((__bridge id)kSecOIDOrganizationalUnitName)];
[sectionKeys setObject:abFullName forKeyedSubscript:((__bridge id)kSecOIDCommonName)];
return [self getCertificateDetails:certificate withSectionIdKey:(__bridge id)kSecOIDX509V1SubjectName withSectionKeys:sectionKeys];
}

+(NSMutableDictionary *)getCertificateDetails:(id)certificate withSectionIdKey:(id)section withSectionKeys:(NSDictionary *)sectionKeys{
NSMutableDictionary *plainCertificate = [NSMutableDictionary new];
id sectionValue = [self valueWithCertificate:certificate key:section];
if([sectionValue isKindOfClass:[NSArray class]]){
for (id subjectDetail in sectionValue) {
for (id key in [sectionKeys allKeys]) {
id label = subjectDetail[(__bridge id)kSecPropertyKeyLabel];
NSLog(@"Key %@ Cerificate label %@",key,label);
if([label isEqualToString:key])
{
id value = subjectDetail[(__bridge id)kSecPropertyKeyValue];
id value = subjectDetail[(__bridge id)kSecPropertyKeyValue];
if([label isEqualToString:key]){
[plainCertificate setObject:value forKey:[sectionKeys valueForKey:key]];
}
}
}
}
NSLog(@"Section values %@",sectionValue);
return plainCertificate;
}
+(NSArray *)keysNeedToExtract{
Expand All @@ -112,6 +98,7 @@ +(NSArray *)keysNeedToExtract{
},
];
}

+ (id)valueWithCertificate:(id)certificate key:(id)key{
return [self valuesWithCertificate:certificate keys:@[key] error:nil][key][(__bridge id)kSecPropertyKeyValue];
}
Expand All @@ -122,6 +109,8 @@ + (NSDictionary *)valuesWithCertificate:(id)certificate keys:(NSArray *)keys err
if (error) *error = CFBridgingRelease(e);
return result;
}


#pragma mark - Remove All Cache, Cookies and Credentials
+ (void)removeAllStoredCredentials{
// Delete any cached URLrequests!
Expand Down
17 changes: 16 additions & 1 deletion AppBox/Model/ProjectModel/XCProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

#import <Foundation/Foundation.h>

#define BuildTypeAdHoc @"ad-hoc"
#define BuildTypePackage @"package"
#define BuildTypeAppStore @"app-store"
#define BuildTypeEnterprise @"enterprise"
#define BuildTypeDevelopment @"development"
#define BuildTypeDeveloperId @"developer-id"

#define AppStoreUploadToolAL @"Application Loader"
#define AppStoreUploadToolXcode @"Xcode"

@interface XCProject : NSObject

//Project Basic Properties
Expand All @@ -33,15 +43,20 @@
@property(nonatomic, retain) NSArray *schemes;
@property(nonatomic, retain) NSArray *targets;

//AppStore Details
@property(nonatomic, retain) NSString *itcPasswod;
@property(nonatomic, retain) NSString *itcUserName;
@property(nonatomic, retain) NSString *appStoreUploadTool;

//Info.plist, manifest.plist and buildlist information
@property(nonatomic, retain) NSDictionary *ipaInfoPlist;
@property(nonatomic, retain) NSDictionary *manifestData;
@property(nonatomic, retain) NSDictionary *buildListInfo;
@property(nonatomic, retain) NSDictionary *exportOptionsPlist;

//UniqueLink.json
@property(nonatomic, retain) DBMetadata *uniqueLinkJsonMetaData;
@property(nonatomic, retain) NSURL *uniquelinkShareableURL;
@property(nonatomic, retain) DBMetadata *uniqueLinkJsonMetaData;

//Shareable URL DropBox or Google Shortern
@property(nonatomic, retain) NSURL *dbDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
@interface ProjectAdvancedViewController : NSViewController{
IBOutlet NSPathControl *pathBuild;
IBOutlet NSComboBox *comboAppStoreTool;
IBOutlet NSTextField *textFieldUserName;
IBOutlet NSSecureTextField *textFieldPassword;
}

@property(nonatomic, strong) XCProject *project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ @implementation ProjectAdvancedViewController

- (void)viewDidLoad {
[super viewDidLoad];
if ([self.project.buildType isEqualToString:BuildTypeAppStore]){
[comboAppStoreTool selectItemAtIndex:0];
}else{
[comboAppStoreTool setEnabled:NO];
[textFieldUserName setEnabled:NO];
[textFieldPassword setEnabled:NO];
}
[pathBuild setURL:self.project.buildDirectory];
}

Expand All @@ -25,6 +32,9 @@ - (IBAction)buttonCancelTapped:(NSButton *)sender {

- (IBAction)buttonSaveTapped:(NSButton *)sender {
[UserData setBuildLocation:self.project.buildDirectory];
[self.project setItcPasswod:textFieldPassword.stringValue];
[self.project setItcUserName:textFieldUserName.stringValue];
[self.project setAppStoreUploadTool: comboAppStoreTool.stringValue];
[self dismissController:self];
}

Expand Down