Photo: From Imgur

Some time ago, I saw that E-God wrote a cool new toy called Code Friend, which I privately suggested to e-God to promote and let iOSTips readers experience. E-god said that the function is not perfect yet, and I will share it when it is better, and then I have the following sharing.

There is no such experience, we often need to open the terminal, jump to the current project directory, and then execute pod install; To clear the cache during compilation, we need to turn on Xcode preferences, select Location, and jump to the DerivedData directory. A few years after Xcode was updated, you were thinking about which file to delete every day with 128GB. If you think about it carefully, there are a lot of such repetitive work every day.

XcodeWay recommended

XcodeWay: XcodeWay: XcodeWay: XcodeWay: XcodeWay: XcodeWay: XcodeWay: XcodeWay: XcodeWay No longer manually clear the Xcode DerivedData cache.

function

  • Open the project root directory with one click
  • Open terminal with one click and jump to project root
  • Open the DerivedData directory in one click
  • Open the Provisioning Profiles directory in one click
  • Open Archives directory in one click
  • Open the DeviceSupport directory in one click
  • A key Pod Install
  • A key Pod update
  • Clear DerivedData in one click

extensible

If you have other good ideas, implement the Navigator protocol and add more cool features.

protocol Navigator {  func navigate()
  var title: String { get }
}
Copy the code

The installation

Portal: github.com/GesanTung/X…

Logically, the article can end here, but Lao Feng thinks that we should not only know how to use tools, but also know how to make tools, and even make tools by ourselves.

Xcode plugins Tips

Before Xcode8, Apple tacitly allowed developers to customize Xcode plugins. At the end of 2015, a malicious plug-in (XcodeGhost) was implanted into Xcode. At that time, many developers downloaded this Xcode through unofficial channels, and this malicious software used the plug-in mechanism. To avoid this type of potential malware, at WWDC 2016 Apple announced the Xcode Source Editor Extension as the only way for third parties to extend Xcode. This means that Xcode plugins such as Xvim and Injection Plugin cannot be used by Xcode loading from Xcode 8 onwards. In fact, although Xcode plugins are officially not supported, we can still use these efficiency plugins by re-checking Xcode. Plugins are not the main thread today.

Step 1: Make a certificate

Step 2: Re-sign Xcode

codesign -f -s XcodeSigner /Applications/Xcode.app

After re-signing, earlier plug-ins such as Injection Plugin, Xvim and so on can continue to be used. However, one point is that Xcode after re-signing cannot submit App to AppStroe, so we may need to install another official Xcode version to submit App. Of course, many team build uploads are now automated, so we don’t have to worry about submission.

Introduction of Xcode Extensions

Back to the key point of this article, our topic today is Xcode Extensions. In fact, both Baidu and Google introduce it in many articles. Here I quote the official introduction:

New Xcode extensions for the source editor let you customize your coding experience. Use extensions to navigate within your editor’s text, and select, modify, and transform your code. Bind your favorite extensions to a keyboard shortcut to make common reformatting tasks a snap. Xcode includes a new template so you can easily create editor extensions and distribute them on the Mac App Store, or sign your extensions with your Developer ID to share them online. And because extensions run in a separate process, Xcode stays safe and stable.

Due to the simplicity of the interfaces exposed by XcodeKit, even Xcode10 offers limited functionality, But there are developers out there who make really interesting Xcode Extensions and go to Xcode->Xcode Extensions and you can see a lot of great Extensions published in the AppStore.

XcodeWay implementation

XcodeWay is currently limited to operating on files currently selected by Xcode, such as adding comments to current files, doing Code Lint on current files, etc. What about features like one-click removal of DerivedData?

XcodeWay fork is from onmyway133. The function provided by the author before is simple, that is, opening various directories. I made some modifications standing on the shoulder of the big guy, supporting Pod operation, file deletion operation and emulator deletion operation (you should know that the Xcode emulator used for several years may have more than 20 GB). The main mechanism is to execute AppleScript scripts via Extensions, and to perform operations on various files in the Extensions. The key code is as follows:

1. Run the AppleScript script method

Implement Pod Install code

Select Do Pod Install

Recommended reading:

  • Github.com/theswiftdev…
  • Github.com/GesanTung/X…
  • Code Friend: Develop Xcode Extensions X using JavaScript