Skip to content
Open
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
44 changes: 35 additions & 9 deletions Mobile Apps Icon Generator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
28CE9DEA266488E300A3F7B1 /* macOS_Contents.json in Resources */ = {isa = PBXBuildFile; fileRef = 28CE9DE9266488E300A3F7B1 /* macOS_Contents.json */; };
A6321E691B09994E003247B1 /* LTUtilites.m in Sources */ = {isa = PBXBuildFile; fileRef = A6321E681B09994E003247B1 /* LTUtilites.m */; };
A6321E6F1B09C1CD003247B1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6321E6E1B09C1CD003247B1 /* CoreGraphics.framework */; };
A6321E711B09C1F5003247B1 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6321E701B09C1F5003247B1 /* Quartz.framework */; };
Expand Down Expand Up @@ -35,6 +36,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
28CE9DE9266488E300A3F7B1 /* macOS_Contents.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = macOS_Contents.json; sourceTree = "<group>"; };
A6321E671B09994E003247B1 /* LTUtilites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LTUtilites.h; sourceTree = "<group>"; };
A6321E681B09994E003247B1 /* LTUtilites.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LTUtilites.m; sourceTree = "<group>"; };
A6321E6A1B099961003247B1 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -86,6 +88,7 @@
A65A3FB21B09F5A10062D80C /* Assets */ = {
isa = PBXGroup;
children = (
28CE9DE9266488E300A3F7B1 /* macOS_Contents.json */,
A68D6AD21BC50CEB000E35E0 /* AndroidIconSize.plist */,
A65A3FB31B09F5A10062D80C /* Contents.json */,
A65A3FB51B09F6DD0062D80C /* IconSize.plist */,
Expand Down Expand Up @@ -214,12 +217,12 @@
A65AFA261B05F07E008EDF83 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = "© IML";
TargetAttributes = {
A65AFA2D1B05F07E008EDF83 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = LH225FX8ZS;
DevelopmentTeam = 2Z39MNNT8W;
};
A65AFA431B05F07E008EDF83 = {
CreatedOnToolsVersion = 6.3.1;
Expand All @@ -229,7 +232,7 @@
};
buildConfigurationList = A65AFA291B05F07E008EDF83 /* Build configuration list for PBXProject "Mobile Apps Icon Generator" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand All @@ -254,6 +257,7 @@
A65AFA571B05FC3A008EDF83 /* droppanel.png in Resources */,
A65AFA3C1B05F07E008EDF83 /* Images.xcassets in Resources */,
A68D6AD31BC50CEB000E35E0 /* AndroidIconSize.plist in Resources */,
28CE9DEA266488E300A3F7B1 /* macOS_Contents.json in Resources */,
A65A3FB61B09F6DD0062D80C /* IconSize.plist in Resources */,
A65AFA3F1B05F07E008EDF83 /* Main.storyboard in Resources */,
A65A3FB41B09F5A10062D80C /* Contents.json in Resources */,
Expand Down Expand Up @@ -316,18 +320,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -362,18 +376,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -400,13 +424,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_IDENTITY = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = LH225FX8ZS;
DEVELOPMENT_TEAM = 2Z39MNNT8W;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "iOS Apps Icon Generator/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = com.imodlife.apps.icongenerator;
PRODUCT_BUNDLE_IDENTIFIER = com.paopaosa.icongenerator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -415,13 +440,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_IDENTITY = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = LH225FX8ZS;
DEVELOPMENT_TEAM = 2Z39MNNT8W;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "iOS Apps Icon Generator/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = com.imodlife.apps.icongenerator;
PRODUCT_BUNDLE_IDENTIFIER = com.paopaosa.icongenerator;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
68 changes: 68 additions & 0 deletions iOS Apps Icon Generator/Assets/macOS_Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x",
"filename" : "icon_16@1x.png"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x",
"filename" : "icon_16@2x.png"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x",
"filename" : "icon_32@1x.png"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x",
"filename" : "icon_32@2x.png"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x",
"filename" : "icon_128@1x.png"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x",
"filename" : "icon_128@2x.png"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x",
"filename" : "icon_256@1x.png"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x",
"filename" : "icon_256@2x.png"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x",
"filename" : "icon_512@1x.png"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x",
"filename" : "icon_512@2x.png"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
3 changes: 3 additions & 0 deletions iOS Apps Icon Generator/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

NSString *outputPathAndroid;

NSString *outputPathMacOS;

NSDictionary *iconNamedSizes;
}

@property (weak) IBOutlet NSTextField *lbOutputPath;

@property (weak) IBOutlet IMLImageView_DragDrop *ivIcon;

@property (weak) IBOutlet NSButton *isMacOS;
@property (weak) IBOutlet NSButton *isIOS;
@property (weak) IBOutlet NSButton *isAndroid;

Expand Down
51 changes: 50 additions & 1 deletion iOS Apps Icon Generator/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@implementation ViewController
@synthesize ivIcon, lbOutputPath, lbMessage;
@synthesize isIOS, isAndroid;
@synthesize isIOS, isAndroid, isMacOS;

- (void)viewDidLoad {
[super viewDidLoad];
Expand All @@ -34,6 +34,8 @@ - (void)dropComplete:(NSString *)filePath {

outputPath = [[[[filePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"iml_generated_output/ios"] stringByAppendingString:@".xcassets"] stringByAppendingPathComponent:@"AppIcon.appiconset"];

outputPathMacOS = [[[[filePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"iml_generated_output/macOS"] stringByAppendingString:@".xcassets"] stringByAppendingPathComponent:@"AppIcon.appiconset"];

lbOutputPath.stringValue = [filePath stringByDeletingLastPathComponent];
}

Expand All @@ -49,6 +51,26 @@ - (IBAction)btnGenerateClicked:(id)sender {
NSError *error;
NSFileManager *fm = [NSFileManager defaultManager];

// macOS work
if (isMacOS.state == NSOnState) {
// delete old one
[fm removeItemAtPath:outputPathMacOS error:&error];

// create new result dir for iOS
if([fm createDirectoryAtPath:outputPathMacOS withIntermediateDirectories:YES attributes:nil error:&error]){
// make macOS json file
[self makeContentJsonForMacOS:fm withIconSizeFile:@"macOSIconSize.plist" outputPath:outputPathMacOS];


//NSRunAlertPanel(@"Success", @"Your Icon set was generated at: %@", nil, nil, nil, outputPath);
[self showMessage:@"Success" forError:false];
} else {
//NSLog(@"Convert error: %@", error.description);
//NSRunAlertPanel(@"Error", @"%@", nil, nil, nil, @"Convert failed, please try again.");
[self showMessage:@"Failed" forError:true];
}
}

// iOS work
if (isIOS.state == NSOnState) {
// delete old one
Expand Down Expand Up @@ -126,4 +148,31 @@ - (void)showMessage:(NSString *)msg forError:(Boolean)isError {
lbMessage.hidden = false;
}

- (void)makeContentJsonForMacOS:(NSFileManager *)fm withIconSizeFile:(NSString *)plistFileName outputPath:(NSString *)outPath {
NSError *error = nil;
NSString *originJsonPath = [[NSBundle mainBundle] pathForResource:@"macOS_Contents" ofType:@"json"];
[fm copyItemAtPath:originJsonPath toPath:[outPath stringByAppendingPathComponent:@"Contents.json"] error:&error];
NSData *originData = [NSData dataWithContentsOfFile:originJsonPath];
id jsonObject = [NSJSONSerialization JSONObjectWithData:originData options:NSJSONReadingAllowFragments error:&error];
if ([jsonObject isKindOfClass:[NSDictionary class]] == NO) return;
NSDictionary *dict = (NSDictionary *)jsonObject;
// rewrite for reading from macOS_Contents.json
iconNamedSizes = [dict objectForKey:@"images"];
NSString *sizeA,*sizeB,*scale;
NSString *sizeStr = nil;
NSArray *sizeArray = nil;
NSString *named;
for (NSDictionary *item in iconNamedSizes) {
sizeStr = [item objectForKey:@"size"];
sizeArray = [sizeStr componentsSeparatedByString:@"x"];
sizeA = sizeArray.firstObject;
sizeB = sizeArray.lastObject;
named = [item objectForKey:@"filename"];
scale = [[item objectForKey:@"scale"] stringByReplacingOccurrencesOfString:@"x" withString:@""];
double sizeWidth = sizeA.doubleValue * scale.doubleValue;
double sizeHeight = sizeB.doubleValue * scale.doubleValue;
[LTUtilites writeImage:[LTUtilites resizeImageWithPath:inputPath toSize:CGSizeMake(sizeWidth,sizeHeight)] toPath:[outPath stringByAppendingPathComponent:named]];
}
}

@end
Loading