├── .gitignore ├── LICENSE ├── README.md ├── SketchToXcode.png ├── SketchToXcodeDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SketchToXcodeDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── do_sketch_app_icon.sh ├── do_sketch_pdf_slices.sh ├── do_sketch_png_slices.sh └── yourSketchFile.sketch /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SketchToXcode 2 | 3 | ![SketchToXcode.png](https://raw.githubusercontent.com/gliyao/SketchToXcode/master/SketchToXcode.png) 4 | 5 | You don't need to manage assets manually. This script help you export all the assets you need from your Sketch file. 6 | 7 | ## Requirement 8 | 1. Sketch app 9 | 2. sketchtool - cli tool for Sketch (http://bohemiancoding.com/sketch/tool/) 10 | 11 | ## Sketch file setup 12 | 1. An artboard "AppIcon" and its size is 1024x1024 13 | 2. Slices for your icons. (Slice name as assets name, and it must design by 2x pixel) 14 | 15 | ## Steps 16 | 1. Put {script}.sh and your Sketch file to project root. 17 | 2. Adjust paramaters you need 18 | 1. PROJECT_NAME 19 | 2. SKETCH_FILE 20 | 3. Open terminal at your project root 21 | 4. Run {script}.sh 22 | 23 | ## 3 scripts for 3 purpose 24 | 1. do_sketch_app_icon.sh 25 | 2. do_sketch_pdf_slices.sh 26 | 3. do_sketch_png_slices.sh 27 | 28 | ## Related link 29 | Also provide XCode plugin version. 30 | SketchExporter - https://github.com/gliyao/SketchExporter -------------------------------------------------------------------------------- /SketchToXcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gliyao/SketchToXcode/00f261d07ee8506458a2591bc4d3877683db819c/SketchToXcode.png -------------------------------------------------------------------------------- /SketchToXcodeDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8ABC0BFB1B026786007EA7C0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABC0BFA1B026786007EA7C0 /* main.m */; }; 11 | 8ABC0BFE1B026786007EA7C0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABC0BFD1B026786007EA7C0 /* AppDelegate.m */; }; 12 | 8ABC0C011B026786007EA7C0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABC0C001B026786007EA7C0 /* ViewController.m */; }; 13 | 8ABC0C041B026786007EA7C0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8ABC0C021B026786007EA7C0 /* Main.storyboard */; }; 14 | 8ABC0C061B026786007EA7C0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8ABC0C051B026786007EA7C0 /* Images.xcassets */; }; 15 | 8ABC0C091B026786007EA7C0 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8ABC0C071B026786007EA7C0 /* LaunchScreen.xib */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 8ABC0BF51B026786007EA7C0 /* SketchToXcodeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SketchToXcodeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 8ABC0BF91B026786007EA7C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 21 | 8ABC0BFA1B026786007EA7C0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | 8ABC0BFC1B026786007EA7C0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | 8ABC0BFD1B026786007EA7C0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | 8ABC0BFF1B026786007EA7C0 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 25 | 8ABC0C001B026786007EA7C0 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 26 | 8ABC0C031B026786007EA7C0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 8ABC0C051B026786007EA7C0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 28 | 8ABC0C081B026786007EA7C0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 29 | 8ABC0C131B026786007EA7C0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 8ABC0C141B026786007EA7C0 /* SketchToXcodeDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SketchToXcodeDemoTests.m; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 8ABC0BF21B026786007EA7C0 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 8ABC0BEC1B026786007EA7C0 = { 45 | isa = PBXGroup; 46 | children = ( 47 | 8ABC0BF71B026786007EA7C0 /* SketchToXcodeDemo */, 48 | 8ABC0C111B026786007EA7C0 /* SketchToXcodeDemoTests */, 49 | 8ABC0BF61B026786007EA7C0 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 8ABC0BF61B026786007EA7C0 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 8ABC0BF51B026786007EA7C0 /* SketchToXcodeDemo.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 8ABC0BF71B026786007EA7C0 /* SketchToXcodeDemo */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 8ABC0BFC1B026786007EA7C0 /* AppDelegate.h */, 65 | 8ABC0BFD1B026786007EA7C0 /* AppDelegate.m */, 66 | 8ABC0BFF1B026786007EA7C0 /* ViewController.h */, 67 | 8ABC0C001B026786007EA7C0 /* ViewController.m */, 68 | 8ABC0C021B026786007EA7C0 /* Main.storyboard */, 69 | 8ABC0C051B026786007EA7C0 /* Images.xcassets */, 70 | 8ABC0C071B026786007EA7C0 /* LaunchScreen.xib */, 71 | 8ABC0BF81B026786007EA7C0 /* Supporting Files */, 72 | ); 73 | path = SketchToXcodeDemo; 74 | sourceTree = ""; 75 | }; 76 | 8ABC0BF81B026786007EA7C0 /* Supporting Files */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 8ABC0BF91B026786007EA7C0 /* Info.plist */, 80 | 8ABC0BFA1B026786007EA7C0 /* main.m */, 81 | ); 82 | name = "Supporting Files"; 83 | sourceTree = ""; 84 | }; 85 | 8ABC0C111B026786007EA7C0 /* SketchToXcodeDemoTests */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 8ABC0C141B026786007EA7C0 /* SketchToXcodeDemoTests.m */, 89 | 8ABC0C121B026786007EA7C0 /* Supporting Files */, 90 | ); 91 | path = SketchToXcodeDemoTests; 92 | sourceTree = ""; 93 | }; 94 | 8ABC0C121B026786007EA7C0 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 8ABC0C131B026786007EA7C0 /* Info.plist */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | /* End PBXGroup section */ 103 | 104 | /* Begin PBXNativeTarget section */ 105 | 8ABC0BF41B026786007EA7C0 /* SketchToXcodeDemo */ = { 106 | isa = PBXNativeTarget; 107 | buildConfigurationList = 8ABC0C181B026786007EA7C0 /* Build configuration list for PBXNativeTarget "SketchToXcodeDemo" */; 108 | buildPhases = ( 109 | 8ABC0BF11B026786007EA7C0 /* Sources */, 110 | 8ABC0BF21B026786007EA7C0 /* Frameworks */, 111 | 8ABC0BF31B026786007EA7C0 /* Resources */, 112 | ); 113 | buildRules = ( 114 | ); 115 | dependencies = ( 116 | ); 117 | name = SketchToXcodeDemo; 118 | productName = SketchToXcodeDemo; 119 | productReference = 8ABC0BF51B026786007EA7C0 /* SketchToXcodeDemo.app */; 120 | productType = "com.apple.product-type.application"; 121 | }; 122 | /* End PBXNativeTarget section */ 123 | 124 | /* Begin PBXProject section */ 125 | 8ABC0BED1B026786007EA7C0 /* Project object */ = { 126 | isa = PBXProject; 127 | attributes = { 128 | LastUpgradeCheck = 0630; 129 | TargetAttributes = { 130 | 8ABC0BF41B026786007EA7C0 = { 131 | CreatedOnToolsVersion = 6.3.1; 132 | }; 133 | }; 134 | }; 135 | buildConfigurationList = 8ABC0BF01B026786007EA7C0 /* Build configuration list for PBXProject "SketchToXcodeDemo" */; 136 | compatibilityVersion = "Xcode 3.2"; 137 | developmentRegion = English; 138 | hasScannedForEncodings = 0; 139 | knownRegions = ( 140 | en, 141 | Base, 142 | ); 143 | mainGroup = 8ABC0BEC1B026786007EA7C0; 144 | productRefGroup = 8ABC0BF61B026786007EA7C0 /* Products */; 145 | projectDirPath = ""; 146 | projectRoot = ""; 147 | targets = ( 148 | 8ABC0BF41B026786007EA7C0 /* SketchToXcodeDemo */, 149 | ); 150 | }; 151 | /* End PBXProject section */ 152 | 153 | /* Begin PBXResourcesBuildPhase section */ 154 | 8ABC0BF31B026786007EA7C0 /* Resources */ = { 155 | isa = PBXResourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | 8ABC0C041B026786007EA7C0 /* Main.storyboard in Resources */, 159 | 8ABC0C091B026786007EA7C0 /* LaunchScreen.xib in Resources */, 160 | 8ABC0C061B026786007EA7C0 /* Images.xcassets in Resources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXResourcesBuildPhase section */ 165 | 166 | /* Begin PBXSourcesBuildPhase section */ 167 | 8ABC0BF11B026786007EA7C0 /* Sources */ = { 168 | isa = PBXSourcesBuildPhase; 169 | buildActionMask = 2147483647; 170 | files = ( 171 | 8ABC0C011B026786007EA7C0 /* ViewController.m in Sources */, 172 | 8ABC0BFE1B026786007EA7C0 /* AppDelegate.m in Sources */, 173 | 8ABC0BFB1B026786007EA7C0 /* main.m in Sources */, 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXSourcesBuildPhase section */ 178 | 179 | /* Begin PBXVariantGroup section */ 180 | 8ABC0C021B026786007EA7C0 /* Main.storyboard */ = { 181 | isa = PBXVariantGroup; 182 | children = ( 183 | 8ABC0C031B026786007EA7C0 /* Base */, 184 | ); 185 | name = Main.storyboard; 186 | sourceTree = ""; 187 | }; 188 | 8ABC0C071B026786007EA7C0 /* LaunchScreen.xib */ = { 189 | isa = PBXVariantGroup; 190 | children = ( 191 | 8ABC0C081B026786007EA7C0 /* Base */, 192 | ); 193 | name = LaunchScreen.xib; 194 | sourceTree = ""; 195 | }; 196 | /* End PBXVariantGroup section */ 197 | 198 | /* Begin XCBuildConfiguration section */ 199 | 8ABC0C161B026786007EA7C0 /* Debug */ = { 200 | isa = XCBuildConfiguration; 201 | buildSettings = { 202 | ALWAYS_SEARCH_USER_PATHS = NO; 203 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 204 | CLANG_CXX_LIBRARY = "libc++"; 205 | CLANG_ENABLE_MODULES = YES; 206 | CLANG_ENABLE_OBJC_ARC = YES; 207 | CLANG_WARN_BOOL_CONVERSION = YES; 208 | CLANG_WARN_CONSTANT_CONVERSION = YES; 209 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 210 | CLANG_WARN_EMPTY_BODY = YES; 211 | CLANG_WARN_ENUM_CONVERSION = YES; 212 | CLANG_WARN_INT_CONVERSION = YES; 213 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 214 | CLANG_WARN_UNREACHABLE_CODE = YES; 215 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 216 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 217 | COPY_PHASE_STRIP = NO; 218 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 219 | ENABLE_STRICT_OBJC_MSGSEND = YES; 220 | GCC_C_LANGUAGE_STANDARD = gnu99; 221 | GCC_DYNAMIC_NO_PIC = NO; 222 | GCC_NO_COMMON_BLOCKS = YES; 223 | GCC_OPTIMIZATION_LEVEL = 0; 224 | GCC_PREPROCESSOR_DEFINITIONS = ( 225 | "DEBUG=1", 226 | "$(inherited)", 227 | ); 228 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 231 | GCC_WARN_UNDECLARED_SELECTOR = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 233 | GCC_WARN_UNUSED_FUNCTION = YES; 234 | GCC_WARN_UNUSED_VARIABLE = YES; 235 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 236 | MTL_ENABLE_DEBUG_INFO = YES; 237 | ONLY_ACTIVE_ARCH = YES; 238 | SDKROOT = iphoneos; 239 | TARGETED_DEVICE_FAMILY = "1,2"; 240 | }; 241 | name = Debug; 242 | }; 243 | 8ABC0C171B026786007EA7C0 /* Release */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_WARN_BOOL_CONVERSION = YES; 252 | CLANG_WARN_CONSTANT_CONVERSION = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_EMPTY_BODY = YES; 255 | CLANG_WARN_ENUM_CONVERSION = YES; 256 | CLANG_WARN_INT_CONVERSION = YES; 257 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 258 | CLANG_WARN_UNREACHABLE_CODE = YES; 259 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 260 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 261 | COPY_PHASE_STRIP = NO; 262 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 263 | ENABLE_NS_ASSERTIONS = NO; 264 | ENABLE_STRICT_OBJC_MSGSEND = YES; 265 | GCC_C_LANGUAGE_STANDARD = gnu99; 266 | GCC_NO_COMMON_BLOCKS = YES; 267 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 268 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 269 | GCC_WARN_UNDECLARED_SELECTOR = YES; 270 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 271 | GCC_WARN_UNUSED_FUNCTION = YES; 272 | GCC_WARN_UNUSED_VARIABLE = YES; 273 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 274 | MTL_ENABLE_DEBUG_INFO = NO; 275 | SDKROOT = iphoneos; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | VALIDATE_PRODUCT = YES; 278 | }; 279 | name = Release; 280 | }; 281 | 8ABC0C191B026786007EA7C0 /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = SketchToXcodeDemo/Info.plist; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | }; 289 | name = Debug; 290 | }; 291 | 8ABC0C1A1B026786007EA7C0 /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | INFOPLIST_FILE = SketchToXcodeDemo/Info.plist; 296 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 297 | PRODUCT_NAME = "$(TARGET_NAME)"; 298 | }; 299 | name = Release; 300 | }; 301 | /* End XCBuildConfiguration section */ 302 | 303 | /* Begin XCConfigurationList section */ 304 | 8ABC0BF01B026786007EA7C0 /* Build configuration list for PBXProject "SketchToXcodeDemo" */ = { 305 | isa = XCConfigurationList; 306 | buildConfigurations = ( 307 | 8ABC0C161B026786007EA7C0 /* Debug */, 308 | 8ABC0C171B026786007EA7C0 /* Release */, 309 | ); 310 | defaultConfigurationIsVisible = 0; 311 | defaultConfigurationName = Release; 312 | }; 313 | 8ABC0C181B026786007EA7C0 /* Build configuration list for PBXNativeTarget "SketchToXcodeDemo" */ = { 314 | isa = XCConfigurationList; 315 | buildConfigurations = ( 316 | 8ABC0C191B026786007EA7C0 /* Debug */, 317 | 8ABC0C1A1B026786007EA7C0 /* Release */, 318 | ); 319 | defaultConfigurationIsVisible = 0; 320 | defaultConfigurationName = Release; 321 | }; 322 | /* End XCConfigurationList section */ 323 | }; 324 | rootObject = 8ABC0BED1B026786007EA7C0 /* Project object */; 325 | } 326 | -------------------------------------------------------------------------------- /SketchToXcodeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SketchToXcodeDemo 4 | // 5 | // Created by Liyao on 2015/5/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SketchToXcodeDemo 4 | // 5 | // Created by Liyao on 2015/5/13. 6 | // 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SketchToXcodeDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.liyao.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SketchToXcodeDemo 4 | // 5 | // Created by Liyao on 2015/5/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SketchToXcodeDemo 4 | // 5 | // Created by Liyao on 2015/5/13. 6 | // 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /SketchToXcodeDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SketchToXcodeDemo 4 | // 5 | // Created by Liyao on 2015/5/13. 6 | // 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /do_sketch_app_icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -l 2 | #!/bin/bash -l 3 | PROJECT_NAME="SketchToXcodeDemo" 4 | SKETCH_FILE="yourSketchFile.sketch" 5 | 6 | PROJECT_DIR=`pwd` 7 | IMAGES_ASSETS_DIR="$PROJECT_DIR"/"$PROJECT_NAME"/"Images.xcassets" 8 | ICONS_DIR="PROJECT_DIR"/"Icons" 9 | 10 | function exportAppIcon() 11 | { 12 | # import artboard "AppIcon" as images.appiconset 13 | sketchtool export artboards "$SKETCH_FILE" \ 14 | --output="$IMAGES_ASSETS_DIR"/AppIcon.appiconset \ 15 | --formats="png" \ 16 | --item="AppIcon" 17 | 18 | cd "$IMAGES_ASSETS_DIR"/AppIcon.appiconset 19 | 20 | APP_ICON="AppIcon.png" 21 | # iphone 22 | cp -p "$APP_ICON" "29.png" 23 | sips -Z 29 "29.png" 24 | 25 | cp -p "$APP_ICON" "29@2x.png" 26 | sips -Z 58 "29@2x.png" 27 | 28 | cp -p "$APP_ICON" "29@3x.png" 29 | sips -Z 87 "29@3x.png" 30 | 31 | cp -p "$APP_ICON" "40@2x.png" 32 | sips -Z 80 "40@2x.png" 33 | 34 | cp -p "$APP_ICON" "40@3x.png" 35 | sips -Z 120 "40@3x.png" 36 | 37 | cp -p "$APP_ICON" "57.png" 38 | sips -Z 57 "57.png" 39 | 40 | cp -p "$APP_ICON" "57@2x.png" 41 | sips -Z 114 "57@2x.png" 42 | 43 | cp -p "$APP_ICON" "60@2x.png" 44 | sips -Z 120 "60@2x.png" 45 | 46 | cp -p "$APP_ICON" "60@3x.png" 47 | sips -Z 180 "60@3x.png" 48 | 49 | # iPad 50 | cp -p "$APP_ICON" "pad29.png" 51 | sips -Z 29 "pad29.png" 52 | 53 | cp -p "$APP_ICON" "pad29@2x.png" 54 | sips -Z 58 "pad29@2x.png" 55 | 56 | cp -p "$APP_ICON" "pad40.png" 57 | sips -Z 40 "pad40.png" 58 | 59 | cp -p "$APP_ICON" "pad40@2x.png" 60 | sips -Z 80 "pad40@2x.png" 61 | 62 | cp -p "$APP_ICON" "pad50.png" 63 | sips -Z 50 "pad50.png" 64 | 65 | cp -p "$APP_ICON" "pad50@2x.png" 66 | sips -Z 100 "pad50@2x.png" 67 | 68 | cp -p "$APP_ICON" "pad72.png" 69 | sips -Z 72 "pad72.png" 70 | 71 | cp -p "$APP_ICON" "pad72@2x.png" 72 | sips -Z 144 "pad72@2x.png" 73 | 74 | cp -p "$APP_ICON" "pad76.png" 75 | sips -Z 76 "pad76.png" 76 | 77 | cp -p "$APP_ICON" "pad76@2x.png" 78 | sips -Z 152 "pad76@2x.png" 79 | 80 | cat << EOF > Contents.json 81 | { 82 | "images" : [ 83 | { 84 | "size" : "29x29", 85 | "idiom" : "iphone", 86 | "filename" : "29.png", 87 | "scale" : "1x" 88 | }, 89 | { 90 | "size" : "29x29", 91 | "idiom" : "iphone", 92 | "filename" : "29@2x.png", 93 | "scale" : "2x" 94 | }, 95 | { 96 | "size" : "29x29", 97 | "idiom" : "iphone", 98 | "filename" : "29@3x.png", 99 | "scale" : "3x" 100 | }, 101 | { 102 | "size" : "40x40", 103 | "idiom" : "iphone", 104 | "filename" : "40@2x.png", 105 | "scale" : "2x" 106 | }, 107 | { 108 | "size" : "40x40", 109 | "idiom" : "iphone", 110 | "filename" : "40@3x.png", 111 | "scale" : "3x" 112 | }, 113 | { 114 | "size" : "57x57", 115 | "idiom" : "iphone", 116 | "filename" : "57.png", 117 | "scale" : "1x" 118 | }, 119 | { 120 | "size" : "57x57", 121 | "idiom" : "iphone", 122 | "filename" : "57@2x.png", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "size" : "60x60", 127 | "idiom" : "iphone", 128 | "filename" : "60@2x.png", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "size" : "60x60", 133 | "idiom" : "iphone", 134 | "filename" : "60@3x.png", 135 | "scale" : "3x" 136 | }, 137 | { 138 | "size" : "29x29", 139 | "idiom" : "ipad", 140 | "filename" : "pad29.png", 141 | "scale" : "1x" 142 | }, 143 | { 144 | "size" : "29x29", 145 | "idiom" : "ipad", 146 | "filename" : "pad29@2x.png", 147 | "scale" : "2x" 148 | }, 149 | { 150 | "size" : "40x40", 151 | "idiom" : "ipad", 152 | "filename" : "pad40.png", 153 | "scale" : "1x" 154 | }, 155 | { 156 | "size" : "40x40", 157 | "idiom" : "ipad", 158 | "filename" : "pad40@2x.png", 159 | "scale" : "2x" 160 | }, 161 | { 162 | "size" : "50x50", 163 | "idiom" : "ipad", 164 | "filename" : "pad50.png", 165 | "scale" : "1x" 166 | }, 167 | { 168 | "size" : "50x50", 169 | "idiom" : "ipad", 170 | "filename" : "pad50@2x.png", 171 | "scale" : "2x" 172 | }, 173 | { 174 | "size" : "72x72", 175 | "idiom" : "ipad", 176 | "filename" : "pad72.png", 177 | "scale" : "1x" 178 | }, 179 | { 180 | "size" : "72x72", 181 | "idiom" : "ipad", 182 | "filename" : "pad72@2x.png", 183 | "scale" : "2x" 184 | }, 185 | { 186 | "size" : "76x76", 187 | "idiom" : "ipad", 188 | "filename" : "pad76.png", 189 | "scale" : "1x" 190 | }, 191 | { 192 | "size" : "76x76", 193 | "idiom" : "ipad", 194 | "filename" : "pad76@2x.png", 195 | "scale" : "2x" 196 | } 197 | ], 198 | "info" : { 199 | "version" : 1, 200 | "author" : "xcode" 201 | } 202 | } 203 | EOF 204 | rm "$APP_ICON" 205 | cd $PROJECT_DIR 206 | } 207 | 208 | function exportIcons() 209 | { 210 | echo `pwd` 211 | # export icon as pdf vector 212 | sketchtool export slices "$SKETCH_FILE" \ 213 | --output="$ICONS_DIR" \ 214 | --formats="pdf" \ 215 | --scales="0.5" 216 | 217 | # create assets to XCode 218 | cd $ICONS_DIR 219 | 220 | for file in *.pdf 221 | do 222 | 223 | fname=${file%%@*} 224 | 225 | # create imageset file 226 | assets_name="$fname".imageset 227 | icon_assets_dir="$IMAGES_ASSETS_DIR"/"$assets_name" 228 | createJSONwithAssetsName "$file" 229 | 230 | # copy imageset file to XCode 231 | mkdir -p "$icon_assets_dir" 232 | /bin/cp "$file" "$icon_assets_dir"/"$file" 233 | /bin/cp Contents.json "$icon_assets_dir"/Contents.json 234 | done 235 | 236 | cd $PROJECT_DIR 237 | 238 | # remove unused files 239 | rm -rf "$ICONS_DIR" 240 | } 241 | 242 | function createJSONwithAssetsName() 243 | { 244 | cat << EOF > Contents.json 245 | { 246 | "images" : [ 247 | { 248 | "idiom" : "universal", 249 | "filename" : "$1" 250 | } 251 | ], 252 | "info" : { 253 | "version" : 1, 254 | "author" : "xcode" 255 | } 256 | } 257 | EOF 258 | } 259 | 260 | # sketch flow 261 | exportAppIcon 262 | -------------------------------------------------------------------------------- /do_sketch_pdf_slices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -l 2 | #!/bin/bash -l 3 | PROJECT_NAME="SketchToXcodeDemo" 4 | SKETCH_FILE="yourSketchFile.sketch" 5 | 6 | PROJECT_DIR=`pwd` 7 | IMAGES_ASSETS_DIR="$PROJECT_DIR"/"$PROJECT_NAME"/"Images.xcassets" 8 | ICONS_DIR="PROJECT_DIR"/"Icons" 9 | 10 | function exportAppIcon() 11 | { 12 | # import artboard "AppIcon" as images.appiconset 13 | sketchtool export artboards "$SKETCH_FILE" \ 14 | --output="$IMAGES_ASSETS_DIR"/AppIcon.appiconset \ 15 | --formats="png" \ 16 | --item="AppIcon" 17 | 18 | cd "$IMAGES_ASSETS_DIR"/AppIcon.appiconset 19 | 20 | APP_ICON="AppIcon.png" 21 | # iphone 22 | cp -p "$APP_ICON" "29.png" 23 | sips -Z 29 "29.png" 24 | 25 | cp -p "$APP_ICON" "29@2x.png" 26 | sips -Z 58 "29@2x.png" 27 | 28 | cp -p "$APP_ICON" "29@3x.png" 29 | sips -Z 87 "29@3x.png" 30 | 31 | cp -p "$APP_ICON" "40@2x.png" 32 | sips -Z 80 "40@2x.png" 33 | 34 | cp -p "$APP_ICON" "40@3x.png" 35 | sips -Z 120 "40@3x.png" 36 | 37 | cp -p "$APP_ICON" "57.png" 38 | sips -Z 57 "57.png" 39 | 40 | cp -p "$APP_ICON" "57@2x.png" 41 | sips -Z 114 "57@2x.png" 42 | 43 | cp -p "$APP_ICON" "60@2x.png" 44 | sips -Z 120 "60@2x.png" 45 | 46 | cp -p "$APP_ICON" "60@3x.png" 47 | sips -Z 180 "60@3x.png" 48 | 49 | # iPad 50 | cp -p "$APP_ICON" "pad29.png" 51 | sips -Z 29 "pad29.png" 52 | 53 | cp -p "$APP_ICON" "pad29@2x.png" 54 | sips -Z 58 "pad29@2x.png" 55 | 56 | cp -p "$APP_ICON" "pad40.png" 57 | sips -Z 40 "pad40.png" 58 | 59 | cp -p "$APP_ICON" "pad40@2x.png" 60 | sips -Z 80 "pad40@2x.png" 61 | 62 | cp -p "$APP_ICON" "pad50.png" 63 | sips -Z 50 "pad50.png" 64 | 65 | cp -p "$APP_ICON" "pad50@2x.png" 66 | sips -Z 100 "pad50@2x.png" 67 | 68 | cp -p "$APP_ICON" "pad72.png" 69 | sips -Z 72 "pad72.png" 70 | 71 | cp -p "$APP_ICON" "pad72@2x.png" 72 | sips -Z 144 "pad72@2x.png" 73 | 74 | cp -p "$APP_ICON" "pad76.png" 75 | sips -Z 76 "pad76.png" 76 | 77 | cp -p "$APP_ICON" "pad76@2x.png" 78 | sips -Z 152 "pad76@2x.png" 79 | 80 | cat << EOF > Contents.json 81 | { 82 | "images" : [ 83 | { 84 | "size" : "29x29", 85 | "idiom" : "iphone", 86 | "filename" : "29.png", 87 | "scale" : "1x" 88 | }, 89 | { 90 | "size" : "29x29", 91 | "idiom" : "iphone", 92 | "filename" : "29@2x.png", 93 | "scale" : "2x" 94 | }, 95 | { 96 | "size" : "29x29", 97 | "idiom" : "iphone", 98 | "filename" : "29@3x.png", 99 | "scale" : "3x" 100 | }, 101 | { 102 | "size" : "40x40", 103 | "idiom" : "iphone", 104 | "filename" : "40@2x.png", 105 | "scale" : "2x" 106 | }, 107 | { 108 | "size" : "40x40", 109 | "idiom" : "iphone", 110 | "filename" : "40@3x.png", 111 | "scale" : "3x" 112 | }, 113 | { 114 | "size" : "57x57", 115 | "idiom" : "iphone", 116 | "filename" : "57.png", 117 | "scale" : "1x" 118 | }, 119 | { 120 | "size" : "57x57", 121 | "idiom" : "iphone", 122 | "filename" : "57@2x.png", 123 | "scale" : "2x" 124 | }, 125 | { 126 | "size" : "60x60", 127 | "idiom" : "iphone", 128 | "filename" : "60@2x.png", 129 | "scale" : "2x" 130 | }, 131 | { 132 | "size" : "60x60", 133 | "idiom" : "iphone", 134 | "filename" : "60@3x.png", 135 | "scale" : "3x" 136 | }, 137 | { 138 | "size" : "29x29", 139 | "idiom" : "ipad", 140 | "filename" : "pad29.png", 141 | "scale" : "1x" 142 | }, 143 | { 144 | "size" : "29x29", 145 | "idiom" : "ipad", 146 | "filename" : "pad29@2x.png", 147 | "scale" : "2x" 148 | }, 149 | { 150 | "size" : "40x40", 151 | "idiom" : "ipad", 152 | "filename" : "pad40.png", 153 | "scale" : "1x" 154 | }, 155 | { 156 | "size" : "40x40", 157 | "idiom" : "ipad", 158 | "filename" : "pad40@2x.png", 159 | "scale" : "2x" 160 | }, 161 | { 162 | "size" : "50x50", 163 | "idiom" : "ipad", 164 | "filename" : "pad50.png", 165 | "scale" : "1x" 166 | }, 167 | { 168 | "size" : "50x50", 169 | "idiom" : "ipad", 170 | "filename" : "pad50@2x.png", 171 | "scale" : "2x" 172 | }, 173 | { 174 | "size" : "72x72", 175 | "idiom" : "ipad", 176 | "filename" : "pad72.png", 177 | "scale" : "1x" 178 | }, 179 | { 180 | "size" : "72x72", 181 | "idiom" : "ipad", 182 | "filename" : "pad72@2x.png", 183 | "scale" : "2x" 184 | }, 185 | { 186 | "size" : "76x76", 187 | "idiom" : "ipad", 188 | "filename" : "pad76.png", 189 | "scale" : "1x" 190 | }, 191 | { 192 | "size" : "76x76", 193 | "idiom" : "ipad", 194 | "filename" : "pad76@2x.png", 195 | "scale" : "2x" 196 | } 197 | ], 198 | "info" : { 199 | "version" : 1, 200 | "author" : "xcode" 201 | } 202 | } 203 | EOF 204 | rm "$APP_ICON" 205 | cd $PROJECT_DIR 206 | } 207 | 208 | function exportIcons() 209 | { 210 | echo `pwd` 211 | # export icon as pdf vector 212 | sketchtool export slices "$SKETCH_FILE" \ 213 | --output="$ICONS_DIR" \ 214 | --formats="pdf" \ 215 | --scales="0.5" 216 | 217 | # create assets to XCode 218 | cd $ICONS_DIR 219 | 220 | for file in *.pdf 221 | do 222 | 223 | fname=${file%%@*} 224 | 225 | # create imageset file 226 | assets_name="$fname".imageset 227 | icon_assets_dir="$IMAGES_ASSETS_DIR"/"$assets_name" 228 | createJSONwithAssetsName "$file" 229 | 230 | # copy imageset file to XCode 231 | mkdir -p "$icon_assets_dir" 232 | /bin/cp "$file" "$icon_assets_dir"/"$file" 233 | /bin/cp Contents.json "$icon_assets_dir"/Contents.json 234 | done 235 | 236 | cd $PROJECT_DIR 237 | 238 | # remove unused files 239 | rm -rf "$ICONS_DIR" 240 | } 241 | 242 | function createJSONwithAssetsName() 243 | { 244 | cat << EOF > Contents.json 245 | { 246 | "images" : [ 247 | { 248 | "idiom" : "universal", 249 | "filename" : "$1" 250 | } 251 | ], 252 | "info" : { 253 | "version" : 1, 254 | "author" : "xcode" 255 | } 256 | } 257 | EOF 258 | } 259 | 260 | # sketch flow 261 | createJSONwithAssetsName 262 | -------------------------------------------------------------------------------- /do_sketch_png_slices.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -l 2 | PROJECT_NAME="SketchToXcodeDemo" 3 | SKETCH_FILE="yourSketchFile.sketch" 4 | 5 | PROJECT_DIR=`pwd` 6 | IMAGES_ASSETS_DIR="$PROJECT_DIR"/"$PROJECT_NAME"/"Images.xcassets" 7 | ICONS_DIR="$PROJECT_DIR"/"Icons" 8 | 9 | function exportIcons() 10 | { 11 | echo `pwd` 12 | # export icon as pdf vector 13 | sketchtool export slices "$SKETCH_FILE" --output="$ICONS_DIR" --formats="png" --scales="0.5" 14 | sketchtool export slices "$SKETCH_FILE" --output="$ICONS_DIR" --formats="png" --scales="1" 15 | sketchtool export slices "$SKETCH_FILE" --output="$ICONS_DIR" --formats="png" --scales="1.5" 16 | 17 | # create temp directory to export assets 18 | if [ ! -d "$DIRECTORY" ]; then 19 | mkdir "$ICONS_DIR" 20 | fi 21 | 22 | # create assets to XCode 23 | cd "$ICONS_DIR" 24 | 25 | for file in *.png 26 | do 27 | 28 | if [[ $file == *"@"* ]] 29 | then 30 | fname=${file%%@*} 31 | else 32 | fname=${file%%.*} 33 | fi 34 | echo "$fname"; 35 | 36 | 37 | # create imageset file 38 | assets_name="$fname".imageset 39 | icon_assets_dir="$IMAGES_ASSETS_DIR"/"$assets_name" 40 | 41 | 42 | # copy imageset file to XCode 43 | mkdir -p "$icon_assets_dir" 44 | /bin/cp "$file" "$icon_assets_dir"/"$file" 45 | 46 | createContentJsonWithPNGAssets "$fname" 47 | /bin/cp Contents.json "$icon_assets_dir"/Contents.json 48 | done 49 | 50 | cd "$PROJECT_DIR" 51 | 52 | # remove unused files 53 | rm -rf "$ICONS_DIR" 54 | } 55 | 56 | function createContentJsonWithPNGAssets() 57 | { 58 | cat << EOF > Contents.json 59 | { 60 | "images" : [ 61 | { 62 | "idiom" : "universal", 63 | "filename" : "$1@0.5x.png", 64 | "scale" : "1x" 65 | }, 66 | { 67 | "idiom" : "universal", 68 | "filename" : "$1.png", 69 | "scale" : "2x" 70 | }, 71 | { 72 | "idiom" : "universal", 73 | "filename" : "$1@1x.png", 74 | "scale" : "3x" 75 | } 76 | ], 77 | "info" : { 78 | "version" : 1, 79 | "author" : "xcode" 80 | } 81 | } 82 | EOF 83 | } 84 | 85 | 86 | # sketch flow 87 | exportIcons 88 | -------------------------------------------------------------------------------- /yourSketchFile.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gliyao/SketchToXcode/00f261d07ee8506458a2591bc4d3877683db819c/yourSketchFile.sketch --------------------------------------------------------------------------------