├── Assets └── TipFolder.png ├── Tips └── GitAliases │ ├── gitl.png │ └── GitAliases.md ├── .gitignore ├── README.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md └── LICENSE /Assets/TipFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotteg/SwiftDevTips/HEAD/Assets/TipFolder.png -------------------------------------------------------------------------------- /Tips/GitAliases/gitl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scotteg/SwiftDevTips/HEAD/Tips/GitAliases/gitl.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | gitignore 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | # CocoaPods 24 | # 25 | # We recommend against adding the Pods directory to your .gitignore. However 26 | # you should judge for yourself, the pros and cons are mentioned at: 27 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 28 | # 29 | # Pods/ 30 | -------------------------------------------------------------------------------- /Tips/GitAliases/GitAliases.md: -------------------------------------------------------------------------------- 1 | # Create Git Aliases to speed up working with Git in the CLI 2 | 3 | 1. Open **Terminal.app**. 4 | 2. `cd ~/` to switch to your home directory. 5 | 3. `open .gitconfig` to open your `.gitconfig` file in your default text editor. 6 | 4. Add this text: 7 | ``` 8 | [alias] 9 | b = branch 10 | co = checkout 11 | l = log --graph --all --decorate --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative 12 | #logg = log --abbrev-commit --all --decorate --graph --oneline 13 | s = status 14 | shw = show --pretty --name-only 15 | ``` 16 | 17 | Now you can use these aliases to reduce the number of keystrokes to do some of the most common actions in Git. And you'll also get nicely formatted, syntax-highlighted log graphs. 18 | 19 | For example: 20 | 21 | `git l -5` will print a formatted log of the last five commits. 22 | 23 | ![](gitl.png) 24 | 25 | Check out [this post](https://haacked.com/archive/2014/07/28/github-flow-aliases/) for additional alias ideas. 26 | 27 | Submitted by [@scotteg](https://twitter.com/scotteg). 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift Dev Tips 2 | 3 | A crowd-sourced collection of tips for Swift developers. 4 | 5 | --- 6 | 7 | ## [Contents](#contents) 8 | - [**The Tips**](#the-tips) 9 | - [**Swift**](#swift) 10 | - [**General Swift**](#general-swift) 11 | - [**Scripting**](#scripting) 12 | - [**Platforms**](#platforms) 13 | - [**iOS**](#ios) 14 | - [**macOS**](#macos) 15 | - [**watchOS**](#watchos) 16 | - [**tvOS**](#tvos) 17 | - [**Linux**](#linux) 18 | - [**Vapor**](#vapor) 19 | - [**Kitura**](#kitura) 20 | - [**Perfect**](#perfect) 21 | - [**Tools**](#tools) 22 | - [**Xcode**](#xcode) 23 | - [**Instruments**](#instruments) 24 | - [**Simulator**](#simulator) 25 | - [**Terminal / CLI**](#terminal-cli) 26 | - [**Miscellaneous**](#miscellaneous) 27 | - [**Got a Tip**?](got-a-tip) 28 | 29 | --- 30 | 31 | ## [The Tips](the-tips) 32 | 33 | ### [Swift](#swift) 34 | 35 | #### [General Swift](#general-swift) 36 | - 37 | 38 | #### [Scripting](#scripting) 39 | - 40 | 41 | ### [Platforms](#platforms) 42 | - 43 | 44 | #### [iOS](#ios) 45 | - 46 | 47 | #### [macOS](#macos) 48 | - 49 | 50 | #### [watchOS](#watchos) 51 | - 52 | 53 | #### [tvOS](#tvos) 54 | - 55 | 56 | #### [Linux](#linux) 57 | - 58 | 59 | #### [Vapor](#vapor) 60 | - 61 | 62 | #### [Kitura](#kitura) 63 | - 64 | 65 | #### [Perfect](#perfect) 66 | - 67 | 68 | ### [Tools](#tools) 69 | - 70 | 71 | #### [Xcode](#xcode) 72 | - [Easily find balancing braces and hide/show code](https://twitter.com/scotteg/status/1255916101638201344?s=20) 73 | - [Move selected lines keyboard shortcut](https://twitter.com/scotteg/status/1215275498152087553?s=20) 74 | - [Do the Derived Data Dance to solve a surprisingly large number of problems](http://deriveddata.dance) 75 | - [Open file in target editor](https://twitter.com/scotteg/status/1250486906091114501?s=20) 76 | - [Run without building](https://twitter.com/DonnyWals/status/1215196512851984385?s=20) 77 | - [Multiple cursors](https://twitter.com/dsteppenbeck/status/1258783540277383169?s=20) 78 | - [Delete empty line indents](https://twitter.com/scotteg/status/1273591332523642880?s=20) 79 | 80 | #### [Instruments](#instruments) 81 | - [Profile slow SwiftUI code](https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-instruments-to-profile-your-swiftui-code-and-identify-slow-layouts) 82 | 83 | #### [Simulator](#simulator) 84 | - 85 | 86 | #### [**Terminal / CLI**](#terminal-cli) 87 | - [Open an Xcode project with xed](https://twitter.com/scotteg/status/1257757872026460163?s=20) 88 | - [Open an Xcode project/workspace with open](https://twitter.com/PaulSolt/status/1258210368985468928?s=20) 89 | - [Create Git aliases to speed up your workflow](Tips/GitAliases/GitAliases.md) 90 | 91 | #### [**Miscellaneous**](#miscellaneous) 92 | - [Create beautiful images of source code to share](https://carbon.now.sh/?bg=rgba(171%2C%20184%2C%20195%2C%201)&t=dracula&wt=none&l=swift&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=56px&ph=56px&ln=false&fl=1&fm=Hack&fs=14px&lh=133%25&si=false&es=2x&wm=false) 93 | - [Get formatted code to paste into presentation slides](https://twitter.com/scotteg/status/1259501161402503169?s=20) 94 | 95 | --- 96 | 97 | ## [Got a Tip?](got-a-tip) 98 | 99 | Great! Please review and follow the [Contributing Guidelines](CONTRIBUTING.md) to share your tip. 100 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at scott.gardner@mac.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | 3 | Before submitting a tip, please review the [Code of Conduct](CODE_OF_CONDUCT.md). 4 | 5 | **Some tips about submitting a tip** 6 | 7 | - Add your tip the highest level category. For example, a tip about creating an extension on `DateFormatter` would go it **Swift**, even if you only include a screenshot demonstrating usage in an iOS app. 8 | - Add your tip to the bottom of the list. 9 | - Not all submitted tips will be included. 10 | - Tips may be edited before being published. 11 | - [Create an issue](https://github.com/scotteg/SwiftDevTips/issues) or submit a separate pull request to suggest an edit to an existing tip. 12 | 13 | --- 14 | 15 | ## What constitutes a tip? 16 | 17 | A tip is a specific helpful suggestion. If it is non-specific or feels like it is promoting a person or product or sharing a rumor — it is probably not a tip. 18 | 19 | **Examples** 20 | 21 | ✅ `Double-click on a curly brace to highlight the enclosed content.` 22 | 23 | 🚫 `[This awesome app](http://example.com) will let you create iOS apps with no code.` 24 | 25 | 🚫 `Inspired by [Sabre's Pyramid](https://theoffice.fandom.com/wiki/Pyramid), Apple is working on a triangular-shaped iPad.` 26 | 27 | --- 28 | 29 | ## Contributing your tip is easy. 30 | 31 | 1. **[Fork this repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)** 32 | 2. **[Add your tip](CONTRIBUTING.md)** 33 | 3. **[Submit a pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)** 34 | 35 | --- 36 | 37 | ## Format 38 | 39 | There are two kinds of tips you may be interested to submit: 40 | 41 | - A tip that refers to an external source, such as a blog post, tweet, etc. 42 | - A new tip that you would like to add directly to this repo. 43 | 44 | ### Choose one of the following formats based on the type of tip you are submitting: 45 | 46 | #### Refer to external source 47 | 48 | - Choose this format to share an article, blog post, tweet, etc. 49 | - Link specifically to the original tip whenever possible. 50 |
*Example:*
51 | `[Easily find balancing braces and hide/show code](https://twitter.com/scotteg/status/1255916101638201344?s=20)` 52 | 53 | #### Add new tip content 54 | - **The entire tip—including attribution and links—is 140 characters or less** 55 | - Add the tip inline. 56 |
*Examples:* 57 | - [Easily find balancing braces and hide/show code](https://twitter.com/scotteg/status/1255916101638201344?s=20) 58 | - Double-click on a curly brace to highlight the enclosed content. 59 | - **The tip is greater than 140 characters** 60 | - Create a new Markdown file in `/Tips`. 61 | - Create a parent folder if your tip will include additional assets. 62 |
*Example:* 63 | ![](Assets/TipFolder.png) 64 | - Write your tip in a succinct and easy to read format. Feel free to use pictures or videos, however, please optimize visual content for quick loading and optimal viewing. In most cases, this will be downsizing content to a max width of 2400 pixels. For example, a full-size screenshot of your Xcode window on a 15" MacBook Pro in default resolution is currently 3360 x 2100. This should be downsized to 2400 x 1500. 65 | - Feel free to include one link to your preferred online identity, social media, portfolio, etc. 66 |
*Example:* 67 | 68 | In `README.md` under **Xcode**:
69 | `[How to easily find balancing braces](/Tips/FindBalancingBraces.md)` 70 | 71 | In **/Tips/FindBalancingBraces.md**: 72 | 73 | ``` 74 | Enable the code-folding ribbon to easily find balanced braces and hide/show code. You can also double-click on a folded code ellipsis marker (⋯) to unfold it. 75 | ![](AnimatedGIFDemonstratingThisCoolTip.gif) 76 | 77 | Submited by [@scotteg](https://twitter.com/scotteg). 78 | ``` 79 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | --------------------------------------------------------------------------------