nativejilo.blogg.se

Add key xcodes
Add key xcodes











  1. #ADD KEY XCODES CODE#
  2. #ADD KEY XCODES SIMULATOR#
  3. #ADD KEY XCODES MAC#

#ADD KEY XCODES CODE#

To make Playground wait for the JSON response to return, we can add some code to tell the Playground to keep on running until we stop them : import UIKit After executing the last line task.resume(), Playground will stop running immediately, even before the JSON response is received, hence the completion handler of the URLSession will not get executed and the output didnt show.

add key xcodes

This is because by default, Playground will stop running when it reach the last line of the code. Let's say we have a URLSession code to get Car JSON data like this in Playground:Īfter executing it, you will notice that the response data is not shown in the console log, but when you try it in a Xcode project, it works! 😫 I often use Playground to test JSON response received from a web API, it's really fast to test without having to open simulator. Set to indefinite execution for asynchronous function You can stop worry about key conflict (for now). Now you can execute the Playground code by pressing ⌘ R just like in normal Xcode Project!Īs of Xcode 9, assigning ⌘R to Execute Playground won't conflict with Run as typical Xcode project dont have the Playground execute button and Playground dont have the run button of Xcode Project. You should see the 'Execute Playground' shortcut key created for Xcode like this : Select Xcode for the Application, type Execute Playground for the Menu Title (must follow the text exactly, else it might not work), then input ⌘R as the keyboard shortcut. You can get around this error by using the macOS system keyboard shortcut setting to override it. Sadly, an error will occur when you try to map ⌘R to Execute Playground as this key has already been mapped to "Run" :

add key xcodes

You might be used to press ⌘ R to run Xcode project code and want to use back the same key to execute Playground code as well. Now you can run the code in Playground by pressing the shortcut key you have just set. Select Key Bindings, search for Execute Playground and input the shortcut key you want This should reduce crash frequency in Playground and also lower the CPU usage.ĭon't like to move mouse around and prefer to use keyboard shortcuts? By default, Xcode doesn't have a shortcut key to execute playground code, you can assign a shortcut key to it like this : Then you can click the same button (▶️) again to run the code when you have finished typing. To reduce CPU usage, simply turn off auto run by selecting Manually Run like this : One reason Playground eat up CPU usage is because it will auto build and run your code every few seconds / keystroke.

#ADD KEY XCODES SIMULATOR#

Xcode playground stuck in Launching Simulator or Running? Read the workaround fix here.

  • Set to indefinite execution for asynchronous function.
  • Here are some tips to reduce Playground crashes / CPU usage, improve productivity and using Playground for testing JSON.

    #ADD KEY XCODES MAC#

    The problem with it is that it crashes really often and causes your mac fan to spin loudly.

    add key xcodes

    Playground is a great place to test out small chunk of code as you dont need simulator to see the output and the output is almost immediate. After updating to the latest Xcode (at that time), I hurried to type some code in it and amazed by its instant output, then it crashed like after 10 minutes, wtf Apple?! I was excited when Apple first announced Playground. Xcode Playground might be actually useful if it doesn't crash like every 15 minutes and suck up my CPU usage













    Add key xcodes