Scratch Link is a helper application which allows Scratch 3.0 to communicate with hardware peripherals. Scratch Link replaces the Scratch Device Manager and Scratch Device Plug-in.
System Requirements:
Minimum | |
---|---|
macOS | 10.10 "Yosemite" |
Windows 10 | Version 1709 (build 16299) "Fall Creators Update" or newer |
To use Scratch Link with Scratch 3.0:
- Install and run Scratch Link
- Open Scratch 3.0
- Select the "Add Extension" button (looks like Scratch blocks with a
+
at the bottom of the block categories list) - Select a compatible extension such as the micro:bit or LEGO EV3 extension.
- Follow the prompts to connect your peripheral.
- Build a project with the new extension blocks. Scratch Link will help Scratch communicate with your peripheral.
The general network protocol and all supported hardware protocols are documented in Markdown files in the
Documentation
subdirectory. Please note that network protocol stability and compatibility are high priorities for
this project. Changes to the protocol are unlikely to be accepted without very strong justification combined with
thorough documentation.
Please use markdownlint to check documentation changes before submitting a pull request.
These steps are necessary regardless of platform.
Scratch Link provides Secure WebSocket (WSS) communication and uses digital certificates to do so. These certificates are not provided in this repository.
To prepare certificates for Scratch Link development:
- Obtain the raw certificates: see
Certificates/convert-certificates.sh
for details. Those outside the Scratch Team will need to provide their own certificates for unofficial builds. cd Certificates
and run./convert-certificates.sh
to prepare the necessary certificate files.
The macOS version of this project is in the macOS
subdirectory. It uses Swift 4.x and the Swift Package Manager.
Developer prerequisites on macOS, most of which are available through Homebrew:
- Xcode Command Line Tools
- Install with
xcode-select --install
- Install with
- git
- pngcrush
- swiftlint (optional)
- Swift Version Manager swiftenv (optional)
- If you have Swift 5 or above / Xcode 10.2 or above
swiftenv
might be the best way to get Swift 4.x
- If you have Swift 5 or above / Xcode 10.2 or above
The build is primarily controlled through make
:
- Build the app bundle with
make
, which will automatically:- Compile Scratch Link code using
swift build
- Create an app bundle at
dist/Scratch Link.app
- Copy all necessary frameworks and dylibs into the app bundle
- Generate and/or copy other resources into the app bundle (certificates, icons, etc.)
- Compile Scratch Link code using
- Build PKG installers with
make dist
, which runs both of these:- Build a PKG for the Mac App Store with
make dist-mas
- Build a PKG for non-Store distribution ("Developer ID") with
make dist-devid
- Build a PKG for the Mac App Store with
- Run the app in any of these ways:
- Use Finder to activate the
Scratch Link
bundle in thedist
directory - Run
"dist/Scratch Link.app/Contents/MacOS/scratch-link"
- Debug output will appear in the terminal
- Type
open "dist/Scratch Link.app"
in a terminal- Debug output will not appear in the terminal
- Use Finder to activate the
- Create an Xcode project file with
make xcodeproj
- If your workflow uses the Xcode project file (Xcode, AppCode, etc.) you should re-run this command each time you add or remove source files.
- Any changes you make to the Xcode project file will be discarded when you run this command.
- You may not be able to run the project using the Xcode project file, but completion and building should work.
The Windows version of this project is in the Windows
subdirectory.
Prerequisites:
- Visual Studio 2017 (Community Edition is sufficient)
- Windows 10.0.16299 SDK (install with Visual Studio)
- WiX Toolset (tested with 3.11.1)
- WiX Toolset Visual Studio Extension (tested with 0.9.21.62588)
Build, run, and debug by opening the Solution (*.sln
) file in Visual Studio 2017.
This section applies to Scratch Team members only.
To build and sign the ScratchLinkSetup
installer (MSI), you must install the appropriate signing certificate.
Contact another Scratch Team member to obtain the certificate, then install it with these steps:
- Open "Manage User Certificates"
- Expand "Personal"
- Right-click "Certificates" under "Personal"
- Select "Import..."
- Follow the steps to import the signing certificate.
- You may need to change the file browser to
Personal Information Exchange (*.pfx;*.p12)
. - When prompted, enter the password for the certificate file you're importing.
- On the last step, make sure the certificate store is listed as "Personal"
- You may need to change the file browser to
You can verify that you've installed the correct certificate by comparing the thumbprint in the Certificate Manager to
the one listed in the post-build event in the ScratchLinkSetup
project.
- Building the
ScratchLinkSetup
project may fail with aSystem.IO.DirectoryNotFoundException
if the Windows case sensitivity flag is enabled on any directory in the path to the Scratch Link project files. This flag can become enabled when WSL is used to create or manipulate directories.- Solution: Use
fsutil file queryCaseSensitiveInfo myDirName
to check ifmyDirName
has its case sensitivity flag set. If so, usefsutil file setCaseSensitiveInfo myDirName disable
to clear the flag. - More detail: wixtoolset/issues#5809
- Solution: Use
- The
make
step may fail if the path to the Scratch Link directory contains whitespace.- Solution: Move Scratch Link to a directory without whitespace in the path.
- More detail: http://savannah.gnu.org/bugs/?712 and scratchfoundation#66