Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build error caused by ZipKit, outdated XIB files, and removed 'system' function #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
271 changes: 36 additions & 235 deletions ArtworkDetailViewController.xib
Original file line number Diff line number Diff line change
@@ -1,236 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1024</int>
<string key="IBDocument.SystemVersion">9L30</string>
<string key="IBDocument.InterfaceBuilderVersion">680</string>
<string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="841351856">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
</object>
<object class="IBProxyObject" id="606714003">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
</object>
<object class="IBUIView" id="200840190">
<nil key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIImageView" id="907963752">
<reference key="NSNextResponder" ref="200840190"/>
<int key="NSvFlags">301</int>
<string key="NSFrame">{{20, 20}, {200, 230}}</string>
<reference key="NSSuperview" ref="200840190"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace" id="958714743">
<int key="NSID">2</int>
</object>
</object>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<int key="IBUIContentMode">4</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
</object>
</object>
<string key="NSFrame">{{40, -84}, {320, 460}}</string>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC43NQA</bytes>
<reference key="NSCustomColorSpace" ref="958714743"/>
</object>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
</object>
<object class="IBUIBarButtonItem" id="715729246">
<string key="IBUITitle">Save</string>
<int key="IBUIStyle">1</int>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">saveButton</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="715729246"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">save</string>
<reference key="source" ref="715729246"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">7</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="200840190"/>
</object>
<int key="connectionID">9</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">imageView</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="907963752"/>
</object>
<int key="connectionID">10</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="766608075">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="841351856"/>
<reference key="parent" ref="766608075"/>
<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="606714003"/>
<reference key="parent" ref="766608075"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="715729246"/>
<reference key="parent" ref="766608075"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="200840190"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="907963752"/>
</object>
<reference key="parent" ref="766608075"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="907963752"/>
<reference key="parent" ref="200840190"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
<string>3.IBEditorWindowLastContentRect</string>
<string>3.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>8.IBEditorWindowLastContentRect</string>
<string>8.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>ArtworkDetailViewController</string>
<string>UIResponder</string>
<string>{{0, 274}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>{{0, 285}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">10</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">ArtworkDetailViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">save</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>imageView</string>
<string>saveButton</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIImageView</string>
<string>UIBarButtonItem</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/ArtworkDetailViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">ArtworkDetailViewController</string>
<string key="superclassName">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">iOS Artwork Extractor.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">3.1</string>
</data>
</archive>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<dependencies>
<deployment version="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ArtworkDetailViewController">
<connections>
<outlet property="imageView" destination="3" id="10"/>
<outlet property="saveButton" destination="4" id="5"/>
<outlet property="view" destination="8" id="9"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="8">
<rect key="frame" x="0.0" y="0.0" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView opaque="NO" clearsContextBeforeDrawing="NO" userInteractionEnabled="NO" contentMode="center" id="3">
<rect key="frame" x="20" y="20" width="200" height="230"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</imageView>
</subviews>
<color key="backgroundColor" red="0.75" green="0.75" blue="0.75" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
<barButtonItem title="Save" id="4">
<connections>
<action selector="save" destination="-1" id="7"/>
</connections>
</barButtonItem>
</objects>
</document>
20 changes: 13 additions & 7 deletions Classes/ArtworkViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "IPAArchive.h"

#import "FindSymbol.h"
#import "RunCMD.h"
#import <mach-o/dyld.h>
#import <objc/runtime.h>

Expand Down Expand Up @@ -415,17 +416,20 @@ - (void) loadImages

for (NSString *imageName in [[self.artwork allKeys] sortedArrayUsingSelector:@selector(localizedCompare:)])
[self addImage:[self.artwork objectForKey:imageName] filePath:imageName];


NSRegularExpression *scaleModifierRegex = [NSRegularExpression regularExpressionWithPattern:@"@[23]x" options:NSRegularExpressionCaseInsensitive error:nil];

if ([self isArtwork])
{
for (NSString *relativePath in [[NSFileManager defaultManager] enumeratorAtPath:systemRoot()])
{
BOOL scale1 = [UIScreen mainScreen].scale == 1 && [[relativePath lowercaseString] rangeOfString:@"@2x"].location == NSNotFound;
BOOL scale1 = [UIScreen mainScreen].scale == 1 && [scaleModifierRegex rangeOfFirstMatchInString:relativePath options:0 range:NSMakeRange(0, [relativePath length])].location == NSNotFound;
BOOL scale2 = [UIScreen mainScreen].scale == 2 && [[relativePath lowercaseString] rangeOfString:@"@2x"].location != NSNotFound;
BOOL scale3 = [UIScreen mainScreen].scale == 3 && [[relativePath lowercaseString] rangeOfString:@"@3x"].location != NSNotFound;
NSString *filePath = [systemRoot() stringByAppendingPathComponent:relativePath];
NSBundle *bundle = [NSBundle bundleWithPath:[filePath stringByDeletingLastPathComponent]];
NSString *archiveName = [[relativePath lastPathComponent] stringByDeletingPathExtension];
if ([relativePath hasSuffix:@"png"] && (scale1 || scale2))
if ([relativePath hasSuffix:@"png"] && (scale1 || scale2 || scale3))
{
NSString *filePath = [systemRoot() stringByAppendingPathComponent:relativePath];
[self addImage:imageWithContentsOfFile(filePath) filePath:filePath];
Expand Down Expand Up @@ -461,8 +465,9 @@ - (void) loadImages
UIImage *image = [assetManager imageNamed:renditionName];
NSString *pseudoBundlePath = [[relativePath stringByDeletingLastPathComponent] stringByAppendingFormat:@" %@", archiveName];
NSString *filePath = [[pseudoBundlePath stringByAppendingPathComponent:renditionName] stringByAppendingPathExtension:@"png"];
if ([image scale] == [[UIScreen mainScreen] scale])
if (image.scale == [UIScreen mainScreen].scale) {
[self addImage:image filePath:filePath];
}
}
}
}
Expand All @@ -472,9 +477,10 @@ - (void) loadImages
for (NSString *imageName in self.archive.imageNames)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
BOOL scale1 = [UIScreen mainScreen].scale == 1 && [[imageName lowercaseString] rangeOfString:@"@2x"].location == NSNotFound;
BOOL scale1 = [UIScreen mainScreen].scale == 1 && [scaleModifierRegex rangeOfFirstMatchInString:imageName options:0 range:NSMakeRange(0, [imageName length])].location == NSNotFound;
BOOL scale2 = [UIScreen mainScreen].scale == 2 && [[imageName lowercaseString] rangeOfString:@"@2x"].location != NSNotFound;
if ([imageName hasSuffix:@"png"] && (scale1 || scale2))
BOOL scale3 = [UIScreen mainScreen].scale == 3 && [[imageName lowercaseString] rangeOfString:@"@3x"].location != NSNotFound;
if ([imageName hasSuffix:@"png"] && (scale1 || scale2 || scale3))
{
[self addImage:[self.archive imageNamed:imageName] filePath:imageName];
}
Expand Down Expand Up @@ -582,7 +588,7 @@ - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butt

AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
NSString *openCommand = [NSString stringWithFormat:@"/usr/bin/open \"%@\"", [appDelegate saveDirectory:nil]];
system([openCommand fileSystemRepresentation]);
run_cmd([openCommand fileSystemRepresentation]);
}

// MARK: -
Expand Down
11 changes: 9 additions & 2 deletions Classes/IPAArchive.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ - (UIImage *) appIcon
}
if ([bundleIconFiles count] == 0)
{
bundleIconFiles = [NSArray arrayWithObjects:@"Icon.png", @"[email protected]", nil];
bundleIconFiles = [NSArray arrayWithObjects:@"Icon.png", @"[email protected]", @"[email protected]", nil];
}

NSMutableArray *icons = [NSMutableArray array];
Expand Down Expand Up @@ -211,7 +211,14 @@ - (UIImage *) imageNamed:(NSString *)imageName
NSData *imageData = [self.ipa inflateFile:header attributes:&attributes];
CGDataProviderRef source = CGDataProviderCreateWithCFData((CFDataRef)imageData);
CGImageRef imageRef = CGImageCreateWithPNGDataProvider(source, NULL, false, kCGRenderingIntentDefault);
CGFloat scale = [imageName rangeOfString:@"@2x"].location != NSNotFound || [imageName rangeOfString:@"@2X"].location != NSNotFound ? 2 : 1;
CGFloat scale;
if ([[imageName lowercaseString] rangeOfString:@"@2x"].location != NSNotFound) {
scale = 2;
} else if ([[imageName lowercaseString] rangeOfString:@"@3x"].location != NSNotFound) {
scale = 3;
} else {
scale = 1;
}
image = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp];
CGImageRelease(imageRef);
CGDataProviderRelease(source);
Expand Down
28 changes: 28 additions & 0 deletions Classes/RunCMD.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// RunCMD.c
// iOS Artwork Extractor
//
// Created by Tom Kraina on 10/12/2018.
// Copyright © 2018 Cédric Luthi. All rights reserved.
//

#include "RunCMD.h"
#include <spawn.h>
#include <sys/types.h>
#include <sys/wait.h>

extern char **environ;

void run_cmd(char *cmd)
{
pid_t pid;
char *argv[] = {"sh", "-c", cmd, NULL};
int status;

status = posix_spawn(&pid, "/bin/sh", NULL, NULL, argv, environ);
if (status == 0) {
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid");
}
}
}
Loading