Categories
Hackster.io

Elephant Edge Webinar 1: The Software

The ElephantEdge challenge is calling on the community to build ML models using the Edge Impulse Studio and tracking dashboards using Avnet’s IoTConnect, which will be deployed onto 10 production-grade collars manufactured by our engineering partner, Institute IRNAS, and deployed by Smart Parks.

In this first of two ElephantEdge webinars you’ll learn about the problems park rangers are facing and how to get started with IoTConnect and Edge Impulse Studio.

Contest Link: https://www.hackster.io/contests/ElephantEdge

Categories
ProgrammableWeb

How to Install Microsoft’s VS Code Source Code Editor On Mac or Linux

Since its introduction, Visual Studio Code, often called simply “VS Code”, has quickly moved to the top of editor choices by programmers. It’s easily one of the most configurable, developer-friendly editors available. Even though it’s created by Microsoft, Linux and Mac users have embraced it as well. It’s fully open-source, and free, and all of the source code for it is available on GitHub. The editor runs inside a framework called Electron, which is basically a sandboxed version of the Chrome browser. As such, most of the editor’s own code is written in JavaScript. The editor is highly extensible, providing thousands of official and community-built extensions supporting different themes, syntax highlighting for nearly every language imaginable, editing extensions, code snippets, most source code control systems, and more. (for version control, Git is supported out-of-the-box.) Developers are encouraged to create their own extensions and share them with the community through the official Extensions Marketplace.

Installing on Linux

There are several ways you can install VS Code on Linux, depending on your distribution.

Installing on Debian and Ubuntu

For Debian and Ubuntu, don’t try to use the apt package manager. Instead, follow these instructions.

First, go over to the VS Code Download Page and download the .deb file.

Open up a terminal or shell prompt. Switch to the directory containing your downloads (typically ~/Downloads, which will be the Downloads directory in your home directory).

cd ~/Downloads

Display a list of the directory’s contents and check for the name of the file you downloaded:

ls -ltr

The file should be the last one listed, and the filename will start with “code_” and end with “.deb.”

The next step requires superuser privileges. To establish your username as a superuser, you’ll need to log in as an existing superuser with “root” privileges. Typically, the username is “su” (for “superuser”) or “root” and the password is one that you established when you first installed Debian. Once you’ve logged in as a user with root privileges,run this command:

usermod -aG sudo <username>

replacing <username> with your actual username. For example,

Usermod -aG sudo jeffc

Now, install the .deb file using this command at the shell prompt:

sudo dpkg -i filename

where you replace filename with the name you discovered above.

After that you can delete the .deb file you had downloaded by using the remove command:

rm <filename>

Now you can skip to the section in this article called “Testing it Out.”

Technical Note: Although you can use VS Code without knowing this, you might be interested to know that the VS Code installer updates your system’s package installer by adding an entry for Microsoft’s package repository. Henceforth, VS Code will automatically update itself behind the scenes using your package installer.

Installing on Red Hat, Fedora, SUSE, CentOS

For these other distributions, you can use the package manager by following these steps. First, open up the terminal. (For example, if your distribution has Gnome, you can click the Activities menu, and then search for Terminal.)

As with Debian, you’ll need superuser privileges. If you don’t already have them, log in as an existing user with root privileges (same as noted in the Debian section above) and run the following command:

usermod -aG wheel <username>

replacing <username> with your actual username. (On these distributions, the “wheel” group has access to sudo privileges, hence the word “wheel” in the command.)

Next, paste the following command into the terminal:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

This will import the key file for Microsoft’s repository. Then paste and run this command at the shell prompt (make sure you get all the lines, as it’s a single command):

sudo sh -c 'echo -e "[code]nname=Visual Studio Codenbaseurl=https://packages.microsoft.com/yumrepos/vscodenenabled=1ngpgcheck=1ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'

Next paste and run this command, which will update yum’s cache:

sudo dnf check-update

And finally, paste the following line, which will install VS Code:

sudo dnf install code

Now you can skip ahead to the section in this article called “Testing it Out.”

Installing on Mac

The first step is to download the latest version of VS Code (don’t use the Homebrew package manager). Go here and click the Mac version. This will download a .zip file. Click the downloaded file at the bottom of your browser (or open the browser’s downloads list and click the .zip file in there.) The Mac’s archive utility will open and automatically unzip the file. The unzipped file will be called “Visual Studio Code” and will appear in the Finder in the same directory as the .zip file (likely your Downloads directory). While in Finder, drag that file to the left, into the Applications folder. Now VS Code is installed. However, the path isn’t set yet. Normally this is fine, but you’ll likely want to open VS Code from the command line in Mac’s Terminal application. Fortunately, VS Code includes a macro built right into it that will set the path for you. We’ll do that next.

Go ahead and open VS Code by double-clicking its filename in the Applications folder. (The first time you’ll see a warning that it was downloaded from the Internet. No problem, just click the Open button that’s in the warning box.)

After VS Code opens, click the View menu, and choose Command Palette. (If you like hotkeys, you can instead hold down both Command and Shift, and then press P.) You’ll see a text box appear at the top of the screen; this is the Command Palette.

Start typing the words “Shell Command” and you’ll see a dropdown list of commands that start with that. Find the one (it’s probably first) called “Shell Command: Install ‘code’ command in PATH.” Click it.

Shell Command: Install 'code'

In the lower-right corner you’ll see a message:

Shell command 'code' successfully installed in PATH.

You’re good to go! Go ahead and exit VS Code by clicking the Code menu, and then choose Quit Visual Studio Code.

Now open a terminal window. You can use the built-in Terminal program found inside the Mac’s Utilities folder (which itself is in the Applications folder), or if you have a favorite one (such as iTerm2) you can use that instead. Then you’re ready for the next step, “Testing it Out.”

Testing it Out

Now you can test it out. At the shell or Terminal prompt, simply type:

code .

The “.” tells VS Code to launch in the current directory. If you like, you can omit it and VS Code will launch in a default directory or the directory you last ran it in. Or you can specify a complete path, e.g.:

code /home/<username>/develop

Note for the bash experts: The “code” command is just a launcher. After using it to launch VS Code, you’re immediately returned to the shell prompt. (You don’t need to run it in the background with an & after it.)

Here are some quick observations. The code editor panel takes up most of the screen, as you would expect.

The code editor panel

On the left is a pane called the Explorer, which includes quick access to your files. The top is a list of all the currently opened files. (If you don’t want that there, you can collapse it by pressing the drop-down arrow to the left of the words “OPEN EDITORS“.) Under that is a project tree. For more information on using VS Code and finding your way around, check out the official tutorials, found here.

Setting Configuration Options

Here at ProgrammableWeb, we’re building a large set of tutorials that will all use a common set of configurations. To make this as simple as possible, we’re going to have a root development directory under which you can save your projects. Because of the number of projects, we suggest opening your code editor so that it points to the current project directory (whatever project you’re working on at the time), rather than the root of all the projects. We’re also going to use a standard set of configurations and plugins for the editors.

Visual Studio Code has a huge array of options and you have a couple of different ways to control them. First, there’s a settings page that lists common settings and places for you to enter in the settings, as shown in the following image. Behind the scenes, however, VS Code stores your settings in a JSON file that you’re free to manually edit. What’s cool here is that you can add custom configurations in this file that aren’t present in the main settings page, and you’ll still be able to use the main settings page. It’s not strictly one or the other.

To open the main settings page, Start VS Code and do one of the following:

  • Click File -> Preferences -> Settings
  • Click the Gear (found in the lower left) -> Settings
  • Hold down Ctrl and press the comma

You should see the settings page open in VS Code’s code editor area, as shown here.

The settings page in VS Code's code editor area

To close the settings page, simply click the close button on the tab at the top.

Note: VS Code allows you to include optional settings on a per-project basis. We’re not going to use this feature here at ProgrammableWeb; however, if you want to try it out you can read up on it here.

Tabs vs Spaces
Indenting sub-sections of code such as the internals of an if-then-else statement or a do-while loop is an important habit for ease of readability. Not just for you, but for others that may have to view your code later. Like other code editors, VS Code has an indentation feature. Although this is a hotly debated topic, we’re going to set our indentations to spaces instead of tabs for one simple reason: Spaces work better for copying and pasting code from our web pages into the editors. (You are welcome to reformat to tabs afterward if you prefer.) We’re going to use four spaces to allow for easier reading of our code.

Language caveat: Unlike most other languages, Python relies on indentation levels and is picky about consistency between spaces and tabs. If you choose to convert any python code from spaces to tabs, you must make sure you do it for the entire file. Otherwise you’ll get errors as soon as you run the program.

To set the indentation to spaces, look at the status bar at the bottom of the VS Code window; you’ll see the words “Tab Size” or “Spaces” followed by a number. “Tab Size” means you’re set up to indent using tabs; Spaces means you’re set up to indent using spaces. The number you see is the size of the indentation. If you already see “Spaces: 4” then you’re good to go. Otherwise, click “Tab Size” or “Spaces“, and a popup will open whereby you can configure the tabs, spaces, and indentation size, as shown below.

To set the indentation to spaces, look at the status bar at the bottom of the VS Code window

Click “Indent Using Spaces” to set your preference to spaces. Next, a similar popup will appear with a list of numbers; choose 4. You can then convert the currently-open file if you like by again clicking either Tab Size or Spaces, and then click “Convert Indentation to Spaces.”

Fonts and Sizes
This is up to you, as we all have a different vision and visual needs. VS Code lets you choose the fonts and sizes you prefer; we’ll show you how here. Note, however, that because VS Code technically runs inside its own Chromium-based browser, you can set the zoom level, just like in Chrome. This means you use both approaches to get the look and feel to your liking. (Try this: With VS Code open, hold down Ctrl and type a + key, which might require pressing Shift depending on which + key you use. You’ll see the entire app zoom just like inside a browser. Reverse it by pressing Ctrl and the minus key.)

To set the font family and font sizes, open up the settings, and on the left of the Settings pane, expand Text Editor; under that, click on Font, as shown here:

To set the font family and font sizes, open up the settings, and on the left of the settings pane, expand Text Editor; under that, click on Font

Unfortunately, the font family name is one area where VS Code isn’t particularly user-friendly. The issue is that VS Code runs inside a browser, and as such uses HTML/CSS syntax for font family names. HTML/CSS font families are typically lists of font names surrounded by single quotes (when the font name has spaces), with commas between the font names. The browser starts from the left and goes through the list until it finds the first font that exists on the system.

There’s no dropdown list or picker of any kind. You just have to know what fonts are available on your system, and you can type them in here. Fonts on Linux-based systems are usually in /usr/share/fonts (and subdirectories under that) or /usr/local/share/fonts. On the Mac, hold down the Command key and press Space; in the search box that opens type Font. Find “Font Book” in the results list and click it; the Font Book app will open to show you your fonts.

The size is more straightforward. Under Font Size simply type the size of the font you want in the editor.

Recommended Extensions

Our tutorials make use of several languages, and as such, you’ll need the plugins to support these languages. By default, VS Code supports all of the languages we’re using; however, the VS Code marketplace includes many free extensions that offer additional functionality for these languages, such as extra syntax highlighting and navigation, code linting, and more.

You can also access the marketplace by simply searching inside VS Code. To do so, do one of the following:

  • Click File -> Preferences -> Extensions
  • Click the Gear (found in the lower left) -> Extensions
  • Hold down Ctrl and Shift and press X

On the left side you’ll see a list of extensions with a search box at the top, as shown below.

On the left side you'll see a list of extensions with a search box at the top

Try typing “C#“. (You don’t need to press enter.) Below that, in the left pane, you’ll see a huge list of free extensions, some built by Microsoft and its partners, and some built by the community members. To see details of an extension, click on it, and a full-page description will open in the editor pane of VS Code. There, you can find user reviews (which we encourage you to read and consider) and the number of people who installed it (a good indicator of the quality of the extension; some have several million downloads, which suggests a strong approval). The better extensions will also include full instructions on their detail pages on how to use the extension. You can install an extension by clicking the little green “Install” button by the extension’s title in the left pane, or by clicking the green Install button at the top of the detail page.

Important: Many extensions require you to restart VS Code after installing them. The green Install button will be replaced by a blue button with the words “Reload Required.” You can click that button to restart VS Code. (All your existing editor windows will remain open.)

You can also install extensions right from the Marketplace page in the browser. Search for an extension, click on it to open its details page, click the “Install” button; your browser will download the extension and open it in VS Code, where it will be installed.

To remove an extension, the green Install button in VS Code gets replaced by a gear icon. Click it for a menu, and in that menu click “Uninstall.” Then you’ll see the familiar blue “Reload Required” button that you’ll want to click.

Here are the extensions we recommend you install, listed by language, along with instructions on how to install them. You can install all of these, or only those for the languages you prefer. These extensions offer syntax highlighting, popups for suggestions as you’re typing (known as Intellisense), and more. Each extension includes documentation when you open the details page showing all the features the extension provides.

Java: There are many Java extensions available; we recommend browsing the list by simply searching the Marketplace for “Java.” At the very least, we encourage you to install two that Microsoft created, building on work by Red Hat. One is a full Java extension pack, found here, and the other is an integrated debugger, found here.

Node.js and JavaScript: VS Code by default has strong support for node.js and therefore JavaScript (which is the language of node.js). As such, we don’t ask you to install any particular node.js extensions. (However, the community has built several that you are welcome to explore; simply type “node” into the Marketplace search box.)

TypeScript: As TypeScript was invented by Microsoft, VS Code also has strong native support. Note that there is, however, an official extension built by Microsoft called JavaScript and TypeScript Nightly. The purpose of this extension is to allow you to stay on top of the nightly updates to the TypeScript language. We only recommend installing this if you’re a very serious TypeScript developer who wants to stay on the bleeding edge.

Python: Microsoft’s official Python extension can be found here. Important for Mac: If you’re a Mac user, you need to install a separate version of Python from the one that ships with MacOS. You can find the details here. (You’re still free to use the version that ships with Mac; however, the plugin won’t integrate with that version.)

C#: Microsoft has partnered with another company called OmniSharp to create the official C# extension. You can find it here.

Go (also known as golang): The official maintainers of the Go language (who work at Google) have built a VS Code extension for Go, which you can find here.

PHP: There isn’t an official PHP extension, but there are several that millions of people have installed. For additional Intellisense features, go here. For PHP debugging features, install this extension.

Dart: There is no official Dart extension by either Microsoft or the Dart language team; however, there is an extension built by community members that has wide support, with over 1.5 million downloads. We therefore recommend this plugin.

C++: Microsoft’s official C++ extension can be found here. This extension supports many different C++ compilers, not just Microsoft’s. Specifically, for Linux, the support is for GNU Compiler Collection (gcc), and for MacOS the support is for Clang (which is included with the XCode IDE for Mac).

Rust: The official Rust language maintainers created an extension for Rust.

Ruby: Although we don’t use Ruby often here at ProgrammableWeb, if you’re into it, we recommend this extension. Please pay close attention to the instructions regarding enabling the language server.

SQL: There are many SQL database server extensions available. Microsoft has an official one for SQL Server and one for PostgreSQL. There is limited support for other servers (such as MySQL or Oracle), but by default, VS Code provides syntax highlighting for SQL files.

Other languages: This list is all the languages we use (or intend to use) in ProgrammableWeb’s tutorials. But there’s an extension for nearly any programming language that exists. For example, if you use Ada, there’s an extension for that. Or Fortran, or even COBOL. If you have a favorite language not listed here, enter it in the Marketplace search box and there will likely be an extension for it. (And if not, you can build one.)

Launching the Integrated Terminal

Visual Studio Code includes an integrated terminal, allowing you to run shell commands right from within VS Code. The terminal works the same way as any other terminal; it includes a prompt that shows you your current directory. You can type all the usual bash commands (such as “ls” and “cd“) as well as git commands if you’re using git. You can learn more about it here. The terminal opens below the code editor as shown below.

Visual Studio Code includes an integrated terminal, allowing you to run shell commands right from within VS Code

To create a new terminal, do one of the following:

  • Click the Terminal menu -> New Terminal
  • Click the Terminal menu -> New Terminal
  • Press Ctrl+Shift+` (that’s the back-tick character, usually to the left of the 1 key).

Optional: Integrating with git

Git is by the most used source code control software right now. We have decided to use git for our source code control, in conjunction with the website GitHub, which hosts code that’s stored in git. You are not required to use git to use our samples; you can even download the samples as .zip files from our respective GitHub project pages and not use git at all. But if you choose to use git, you can easily submit suggestions for improvements to our code.

By default, VS Code comes with full git integration. As such, we do not recommend downloading any additional extensions to use our sample code. Note, however, that we typically do not recommend only trying to use git from within VS Code. Our reasoning is that most developer teams typically still use the command-line version of git, and many tasks are, quite frankly, a bit more intuitive to use at the command line rather than inside VS Code. Therefore we’re taking a two-pronged approach to git:

  1. When you’re editing code that is inside a git repo, note the letters that appear beside your files in the Explorer as you add and modify files (see the screenshot below). The files that are untracked (i.e. not added to the repo) have a letter U to the right of them. Files that are tracked and you’ve changed get an M (for “modified”) next to them. Files that are tracked by git and haven’t been modified get no icon.
  2. When you need to do any git work (e.g. create branches, add and commit files), we recommend using the command-line. (You’re welcome to use either the integrated terminal for its ease of access, or you can do it in an OS shell such as bash.)
By default, VS Code comes with full git integration

Our future projects here at ProgrammableWeb will have freely-available repos on Github. (And we welcome pull requests with suggested changes; we’re making this a community-driven project.)

Go to Source
Author: <a href="https://www.programmableweb.com/user/%5Buid%5D">jeffcogswell</a>

Categories
ProgrammableWeb

Motion Layout API Leads Android Studio 4 Features

Google this week released Android Studio 4, the newest version of its core Android developer environment. Android Studio 4 is meant to give developers more tools so they can design and build apps faster and smarter. The platform arrives mere days before the Android 11 beta launch, which is expected on June 11. Google pushed back the launch of Android 11 in response to COVID-19. Android Studio 3.6 arrived in February.

The company added several core functions to Android Studio 4, including a new Motion Editor, Build Analyzer, and Java 8 APIs. Google also says that it overhauled the CPU Profiler user interface to make it more intuitive.

“Whether you’re working from your kitchen table on a laptop or from a home office, you need tools that keep up with you,” said Adarsh Fernando, Product Manager, in a blog post. “Android Studio 4.0 is the result of our drive to bring you new and improved tools for coding smarter, building faster, and designing the apps your users depend on.”

Google explained that the MotionLayout API should help developers manage motion and widget animations in their apps. The new Motion Editor delivers an interface meant specifically for creating, editing, and previewing MotionLayout animations. It can generate them automatically, with support for constraints, transitions, and other attributes. The resulting code is merely a click away. The new Layout Inspector allows developers to debug their UIs by providing access to updated data and insights on how resources are being used. These include dynamic layout hierarchy detailed view attributes, and a live 3D model of the UI. Last, the Layout Validation window lets developers preview their layouts on different screen sizes and resolutions simultaneously to ensure it works on a range of hardware. 

Java 8 language APIs are now onboard regardless of the associated app’s minimum API level. This allows the Android Gradle plugin to support the Android Studio Build analyzer, which means developers can create complex feature-on-feature dependencies between dynamic modules. A list is available here. Other Java-related adjustments include the ability to enable or disable discrete build features, as well as support for Kotlin DSL script files. 

On the developing and profiling front, developers will find improvements to the R8 rules, which include a smart editor for code shrinkers, an update to the IntelliJ IDEA platform, Android-specific live template performance bumps for Kotlin, and Clangd support. 

The quickest and easiest way to get Android Studio 4 is via the update tools within the app itself. Alternatively, you can snag the download here.

Go to Source
Author: <a href="https://www.programmableweb.com/user/%5Buid%5D">EricZeman</a>

Categories
3D Printing Industry

Domestic Data Streamers 3D prints interactive installation for Cisco Live 2020

Domestic Data Streamers, an independent data design studio based in Barcelona, used BCN3D Technologies 3D printers to create its interactive installation for the Cisco Live 2020 event earlier this year.  Using the BCN3D Epsilon, the creative studio was able to design, produce and set up its Recommendation Wall installation within 4 weeks, in time for […]

Go to Source
Author: Anas Essop

Categories
UnrealEngine

Integrating Unreal into Apple’s Mac ecosystem

Hi, folks! I’m Kyle Erf, the technical director at Moving Pieces Interactive, a small studio in Brooklyn, New York. We’re the creators of Dodo Peak, a modern take on beloved arcade platformers from the 1980s.

Earlier this year, we had the privilege of releasing Dodo Peak as one of the launch titles on Apple’s new Arcade subscription service. One of the main selling points for Apple Arcade is that games work across all devices, including Macs. To release Dodo Peak on Apple Arcade, we had to integrate with Apple’s Mac App Store ecosystem along with Apple services like iCloud and Game Center. 

There are good reasons why anyone targeting a Mac release should consider doing this:
 

  • On the Mac App Store, your game can organically reach players who aren’t plugged into more games-focused digital stores.
  • Using iCloud or Game Center to handle things like leaderboards and cloud saves means you can rely on free, trusted, first-party services rather than integrating third-party infrastructure into your app.
  • Apple Arcade requires Game Center and iCloud as part of its promise of cloud saves accessible across devices.

You’ll be happy to learn Unreal supports Game Center and iCloud for iOS targets out of the box. The bad news is that the same support isn’t built-in for builds targeting macOS. Until recently, targeting your Unreal game to the Mac App Store was a much less common use case. 

Fortunately, anyone can manually work around these feature gaps. Over the last few months, I accidentally became an expert on integrating Unreal games with Apple services on Mac, and I’d like to get all that knowledge out there so you don’t have to piece it together yourself. This guide will cover both how to integrate your Mac game with Apple services and how to package your game for the Mac App Store.
TechBlog_MacIntegration_Feature_Image_Dodo.jpg

Setting up your Mac app in the Apple developer portal

The first step toward getting your game working with Apple services and up on the Mac App Store is configuring your app in Apple’s backend. There are plenty of guides that show you how to do this, but for the sake of completion, here is a quick checklist of what you’ll have to do:
 

  1. Join the Apple Developer Program (this costs a yearly $99 fee).
  2. Create your app via the Identifiers section of the Certificates, Identifiers & Profiles page.
    1. Give your app a useful bundle ID like “com.mycompany.mygame”.
    2. Enable iCloud and Game Center capabilities, plus any others you want.
    3. Note: if you already have a working app identifier for an iOS version of your game, you can auto-generate a Mac identifier for it by selecting the “Mac” capability from the iOS app identifier’s settings.
  3. Create certificates for your account in the Certificates section of the Certificates, Identifiers & Profiles page.
    1. Locally, create a Certificate Signing Request.
    2. Use it to create and download certificates for:
      1. Mac Development
      2. Mac App Distribution
      3. Mac Installer Distribution
  4. Add any test or development Macs you own in the Devices section of the Certificates, Identifiers & Profiles page.
    1. You can find Mac UDIDs via the System Report feature.
  5. (Optional) Create an iCloud container via the Identifiers section of the Certificates, Identifiers & Profiles page.
    1. Edit your app identifier and assign the container using the button next to the iCloud capability.
  6. Create and download relevant provisioning profiles.
    1. Create a Mac Development provisioning profile.
      1. Be sure to select your newly-created app identifier, certificates, and devices.
    2. Create a Mac App Store provisioning profile.
  7. Create a new macOS app in App Store Connect and select your new bundle identifier.
  8. Open your project in Unreal. In your project settings, go to Platforms > iOS, and set your Bundle Identifier to be your new Bundle ID.

That’s the boring part. This will all come in handy later when it comes time to package or test your game. The next section will go over how to actually write code around features like Game Center and iCloud.
TechBlog_MacIntegration_HighResCharacters_cropped.png

Integrating your Mac game with Apple APIs

Since the engine doesn’t have the hooks you need for your games to talk to iCloud or Game Center on macOS, you’ll have to implement them yourself. A quick scan of Apple’s documentation shows us that the only way to crack the shell of their operating system APIs and get at the nutrient-rich center is by using Objective-C or Swift. 

That’s a little scary to hear, since Unreal uses C++. So how do you do it? Are you in for a nasty time compiling and linking static libraries? Nope!

You can get around it the same way the Unreal Engine source does: with a powerful, little-publicized feature of Xcode called Objective-C++.

What is Objective-C++?

Objective-C++ is what it sounds like: the ability to inline Objective-C code inside of your C++ (or vice versa). Both C++ and Objective-C are supersets of C, meaning they support all of the syntax of vanilla C plus additional features. While there are cases where the two languages are at odds, for the most part, using both of them together in Xcode just works. 

For folks looking for a more in-depth guide to Objective-C++, I’d recommend this Medium article. There are a few dangers to avoid around Objective-C’s reference counting-based memory management, but for the most part, things just work. For now, let’s get to what you came here for: code samples.
 

Supporting Game Center on Mac

Apple has their own guides on how to code for Game Center, but the short version goes something like:
 

  1. Authenticate your player
  2. Use that authenticated player to make calls to achievements, leaderboards, and so on

Before you can compile any of the following code, you’ll need to surface the requisite libraries to your package via Unreal’s build system. In your game’s Build.cs file, add the following logic to your constructor:
 

 if (Target.Platform == UnrealTargetPlatform.Mac) {
            PublicFrameworks.AddRange(new string[]{"GameKit"});
        }

Here’s a sample of how one might authenticate their player using Objective-C++. Note I am passing an Objective-C callback to the authenticateHandler, but the code inside that callback function can contain C++.
 

#include <GameKit/GameKit.h>

void UMyBlueprintFunctionLibrary::GameCenterSignIn() {
#if WITH_EDITOR
    // do not run in editor
#elif PLATFORM_MAC
    // asynchronously log into GameCenter. In your code I recommend wiring this up
    // with delegates or UBlueprintAsyncActionBase so that you can handle cases
    // where logging in takes a while.
    dispatch_async(dispatch_get_main_queue(), ^{
        [[GKLocalPlayer localPlayer]
         setAuthenticateHandler:^(NSViewController *_Nonnull viewController, NSError *error) {
             if ([[GKLocalPlayer localPlayer] isAuthenticated])
             {
                 // Success
                 return;
             }
             if (error)
             {
                 // Failure
             }
             else if (viewController)
             {
                 // display login
                 GKDialogController *presenter = [GKDialogController sharedDialogController];
                 presenter.parentWindow = [NSApp keyWindow];
                 [presenter presentViewController:(NSViewController * _Nonnull) viewController];
             }
         }];
    });
#endif
}

Here’s some example code that unlocks achievements.
 

#include <GameKit/GameKit.h>

void UMyBlueprintFunctionLibrary::WriteAchievement(FString ID, float Percent)
{
#if PLATFORM_MAC
    if (![[GKLocalPlayer localPlayer] isAuthenticated])
        return;
    
    // convert FString to NSString
    NSString *nsID = [NSString stringWithUTF8String:TCHAR_TO_ANSI(*ID)];
    
    GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier:nsID];
    achievement.percentComplete = Percent;
    achievement.showsCompletionBanner = YES;
    [GKAchievement reportAchievements:@[ achievement ]withCompletionHandler:^(NSError *error) {
        if (error != nil)
        {
            NSLog(@"%@", [error localizedDescription]);
        }
    }];
#endif
}

And here’s code calling out to Game Center’s leaderboard API.
 

#include <GameKit/GameKit.h>

void UMyBlueprintFunctionLibrary::WriteScoreToLeaderboard(FString LeaderboardID, int Integer) {
#if PLATFORM_MAC
    if (![[GKLocalPlayer localPlayer] isAuthenticated])
        return;
    
    // convert FString to NSString
    NSString *nsID = [NSString stringWithUTF8String:TCHAR_TO_ANSI(*LeaderboardID)];
    
    GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:nsID];
    score.value = Integer;
    
    [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
        if (error != nil)
        {
            NSLog(@"%@", [error localizedDescription]);
        }
    }];
#endif
}

As a final warning: calling Game Center functions from your code within the Unreal Editor can lead to some weird behavior, so I suggest you wrap your Game Center code in #if WITH_EDITOR macros or disable these features in unpackaged versions of your game in some other way.
TechBlog_MacIntegration_Wireframe1.png

Using iCloud for cloud saves

This guide will not explain all the intricacies of iCloud. Apple has some primers you should take a look at before diving into using iCloud to add cloud save support to your title.

For your purposes, you can think of iCloud as a big key-value store that your players can write to and read from. There are several ways to model save data for iCloud:
 

  1. Treat each field of your save object as its own field in iCloud (for example, your player’s level field would be an Integer called “Level,” their character’s name would be a String called “Name,” and so on).
  2. Serialize your save object to binary data and upload the entire save as one binary glob to a single iCloud field.

For Dodo Peak, my team decided to go with option #2, since it allowed us to use the same serialization logic Unreal uses to write saves out to disk.

Once again, before we can run any code, we’ll have to tell the build system to use the CloudKit library:
 

if (Target.Platform == UnrealTargetPlatform.Mac) {
            PublicWeakFrameworks.Add("CloudKit");
        }

Here’s some EXAMPLE code that serializes a SaveGame object and uploads it to iCloud:
 

#include <CloudKit/CloudKit.h>
#include "GameFramework/SaveGame.h"
#include "Kismet/GameplayStatics.h"
#include "Serialization/MemoryReader.h"
#include "Serialization/MemoryWriter.h"
#include "Serialization/ObjectAndNameAsStringProxyArchive.h"


void UMyBlueprintFunctionLibrary::WriteSaveToCloud(USaveGame* MySave) {
    TArray<uint8> ObjectBytes;
    FMemoryWriter MemoryWriter(ObjectBytes, true);
    FObjectAndNameAsStringProxyArchive Ar(MemoryWriter, false);
    MySave->Serialize(Ar);
    
    CKContainer *defaultContainer =
        [CKContainer containerWithIdentifier:@"iCloud.unrealtutorial.mygame"];
    if (defaultContainer == nil)
    {
        // initialization failed
        return;
    }
    else
    {
        CKDatabase *DB = [defaultContainer privateCloudDatabase];
        CKRecordID *recordId = [[[CKRecordID alloc] initWithRecordName:@"save_game_id"] autorelease];
        // RecordType "SaveGame" is configured in Apple's online iCloud dashboard
        CKRecord *record = [[CKRecord alloc] initWithRecordType:@"SaveGame" recordID:recordId];
        // Convert Unreal data array to NSData bytes
        NSData *data = [NSData dataWithBytes:ObjectBytes.GetData() length:ObjectBytes.Num()];
        record[@"SaveData"] = data;
        
        // use CKModifyRecordsOperation to allow updating existing records
        CKModifyRecordsOperation *modifyRecords =
        [[CKModifyRecordsOperation alloc] initWithRecordsToSave:@[ record ]
                                              recordIDsToDelete:nil];
        modifyRecords.savePolicy = CKRecordSaveAllKeys;
        modifyRecords.qualityOfService = NSQualityOfServiceUserInitiated;
        modifyRecords.perRecordCompletionBlock = ^(CKRecord *results, NSError *error) {
            if (error != nil)
            {
                NSLog(@"icloud save error: %@", error);
            }
            else
            {
                NSLog(@"icloud save success: %@", results);
            }
        };
        [DB addOperation:modifyRecords];
    }
}

And here’s EXAMPLE code that loads SaveGame data from iCloud and reads the binary data into a new SaveGame object:
 

#include <CloudKit/CloudKit.h>
#include "GameFramework/SaveGame.h"
#include "Kismet/GameplayStatics.h"
#include "Serialization/MemoryReader.h"
#include "Serialization/MemoryWriter.h"
#include "Serialization/ObjectAndNameAsStringProxyArchive.h"

UCustomSaveGame* UMyBlueprintFunctionLibrary::LoadFromCloud() {
    CKContainer *defaultContainer =
    [CKContainer containerWithIdentifier:@"iCloud.unrealtutorial.mygame"];
    if (defaultContainer == nil)
    {
        return nullptr;
    }
    else
    {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUEPREDICATE"];
        CKDatabase *publicDatabase = [defaultContainer privateCloudDatabase];
        CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"save_game_id"];
        
        __block NSData *data = nil;
        // hold onto results in this block to keep data from being GC'd from under us
        __block CKRecord *holdResults;
        
        // NOTE: this should be synchronized using delegates, semaphores, or some other means
        [publicDatabase
         fetchRecordWithID:recordID
         completionHandler:^(CKRecord *results, NSError *error) {
             holdResults = results;
             if (error != nil)
             {
                 NSLog(@"icloud load error: %@", error);
             }
             else
             {
                 NSLog(@"icloud load success: %@", results);
                 data = [[NSData alloc] initWithData:(NSData *) results[@"SaveData"]];
             }
         }];
        
        // DO NOT SYNCHRONIZE WITH A SLEEP -- this is for example purposes only
        usleep(3000000); // wait for async load
                
        // read data into a save object
        TArray<uint8> ObjectBytes;
        ObjectBytes.AddUninitialized(data.length);
        FMemory::Memcpy(ObjectBytes.GetData(), data.bytes, data.length * sizeof(uint8));
        FMemoryReader MemoryReader(ObjectBytes, true);
        FObjectAndNameAsStringProxyArchive Ar(MemoryReader, true);
        UCustomSaveGame *LoadedSave = Cast<UCustomSaveGame>(                                                                UGameplayStatics::CreateSaveGameObject(UCustomSaveGame::StaticClass()));

        LoadedSave->Serialize(Ar);
        return LoadedSave;
    }
}

The above code is just to get you started. Everyone’s needs are different and to fully implement cloud saves for your game, you’ll have to consider things like:
 

  • How often is your game saving? How often are you loading? Should you talk to the cloud for each save and load or just some?
  • Do you need to support multiple devices writing and reading to the same iCloud record?
  • How do you handle offline progress?
  • How will your game handle cases where your player’s local save might conflict with the data in the cloud?

Note that if you try and run any Mac iCloud code from the editor or after exporting your app, your game will throw an exception complaining about a missing entitlement. Like with Game Center, I advise you to exclude any iCloud code from running in your editor.

The next section outlines how to actually run that iCloud code in your development builds.
TechBlog_MacIntegration_HighresScreenshot00009.png

Signing and packaging your game

Time to wrap all this up, literally. The final hill to climb on your path toward running your Unreal game with Apple APIs and uploading it to the Mac App Store requires configuring your game’s code signature, entitlements, and Plist.

One could write a blog post just on these, but in quick summary:
 

  • Codesigning is Apple’s way of ensuring executable code is actually from who it says it is, and that the code has not been tampered with. Find out more here.
  • Entitlements are key-value pairs embedded into your app during code signing that denote certain secure OS features your app can take advantage of, like iCloud. Find out more here.
  • An Information Property List or “Info.plist” includes essential configuration data for your application as well as the App Store, including things like the location of your App Icon or supported languages. Find out more here.

If you’re familiar with how Unreal handles packaging with provisioning profiles and certificates for iOS, this will be a lot like that, but you’ll have to do the steps Unreal and Xcode would normally do for you on your own.
 

Packaging and signing for local development

Before you push your game to the App Store, you’ll probably want to make sure it, you know, works. So how do you make a build that can run locally? As mentioned earlier, your game will crash if you try and call an iCloud function without signing your application with iCloud entitlements.

So let’s fix those missing entitlements. The process is straightforward but tedious. To introduce new entitlements into a Mac application, you’ll need to supply the app with a provisioning profile and then sign it with necessary entitlements. Here’s how.

From Unreal, package your game. Then, in a terminal, navigate to the directory containing your newly-exported app. Create a copy of your Development provisioning profile, then rename it to “embedded.provisionprofile”. Copy that provisioning profile to “YourGame.app/Contents/embedded.provisionprofile”.

To bring it all together with a new code signature, you’ll first have to create an XML file with the entitlements you’d like to add to the application. That file might look something like: 
 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.application-identifier</key>
    <string>TEAMID.com.mycompany.mygame</string>
    <key>com.apple.developer.icloud-container-environment</key>
    <string>Development</string>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudKit</string>
    </array>
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.com.mycompany.mygame</string>
    </array>
    <key>com.apple.developer.game-center</key>
    <true/>
    <key>com.apple.security.app-sandbox</key>
    <true/>
</dict>
</plist>

Make sure you change the above XML so that:
 

  • Your com.apple.application-identifier is your full app bundle identifier (important: make sure the bundle identifier starts with your team ID, which is a string of letters and numbers like “3Y1CL48M1K”).
  • Change the com.apple.developer.icloud-container-identifiers array to contain your iCloud container ID.

Save this text file as “entitlements.plist”.

(As an aside, you can view any application’s entitlements with codesign -dv --entitlements - AppName.app, which may come in handy for debugging.)

To properly sign the app, you’ll have to first sign all of the executable code then sign the app itself. You can do this all with one command using:
 

codesign --deep -f -v -s "3rd Party Mac Developer:" --entitlements entitlements.plist MyGame.app

And that’s it! Double-click your app in Finder and you should be able to play your game and make iCloud and Game Center requests!

Packaging and signing for distribution

Sending your App to the Mac App Store follows the same steps but is slightly more involved. Go through these steps manually one time to understand them, and then write your own script to do it automatically.

First, export your game as a Shipping package with Distribution enabled.

Next, edit your plist to get any additional information you might want to send to your store page. For example, you can list supported controllers with GCSupportedGameControllers and use CFBundleLocalizations to set supported languages (the App Store cannot automatically detect Unreal’s localization support) as well as manually edit version numbers and bundle IDs. You must set LSApplicationCategoryType for your app to be accepted by the Application Loader.

Copy your Distribution provisioning profile to then rename it to “embedded.provisionprofile”. Copy the provisioning profile to “YourGame.app/Contents/embedded.provisionprofile”.

Now, unlike signing your development builds, we’ll have to do a little cleanup of our exported .app in order to get it approved by the Mac App Store. 

Firstly, the Mac App Store does not support 32-bit executable code (neither do versions of macOS 10.15 and up). Unreal automatically bundles some dynamic audio libraries with your game that contain 32-bit code, so we’ll have to remove that code. Thankfully, this has been a fairly common problem over the course of computer science history and so there are tools to do just that. You can take advantage of the lipo command and run:
 

lipo MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/Ogg/Mac/libogg.dylib -remove i386 -output MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/Ogg/Mac/libogg.dylib

lipo MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/Vorbis/Mac/libvorbis.dylib -remove i386 -output MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/Vorbis/Mac/libvorbis.dylib

lipo MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_16/osx32/libopenvr_api.dylib -remove i386 -output MyGame.app/Contents/UE4/Engine/Binaries/ThirdParty/OpenVR/OpenVRv1_0_16/osx32/libopenvr_api.dylib

Next, Unreal adds a single sub-component to your exported game that already has its own Bundle ID, which drives the Application Loader crazy. This component is the “RadioEffectUnit.component.” As far as I can tell, it’s an audio effect, though I’m not sure why it is treated this way by the build system. The good news is that if you aren’t using the RadioEffectUnit, you can just remove it from your app:
 

rm -rf MyGame.app/Contents/Resources/RadioEffectUnit.component
rm -rf MyGame.app/Contents/UE4/Engine/Build

With this cleanup out of the way, we can resume signing the build.

To prepare your code signature, you’ll first have to create an XML file with the entitlements you’d like to add to the application. That file might look something like:
 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.application-identifier</key>
    <string>TEAMID.com.mycompany.mygame</string>
    <key>com.apple.developer.icloud-container-environment</key>
    <string>Production</string>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudKit</string>
    </array>
    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.com.mycompany.mygame</string>
    </array>
    <key>com.apple.developer.game-center</key>
    <true/>
    <key>com.apple.security.app-sandbox</key>
    <true/>
</dict>
</plist>

Make sure you change the above XML so that:
 

  • Your com.apple.application-identifier is your full app bundle identifier (important: make sure the bundle identifier starts with your team ID, which is a string of letters and numbers like “3Y1CL48M1K”).
  • Change the com.apple.developer.icloud-container-identifiers to contain your iCloud container ID.

Save this text file as “entitlements.plist”.

It’s signing time! For distribution, you’ll have to sign the game binary, all dynamic libraries, and finally the .app itself. We did this with:
 

codesign -f -v -s "3rd Party Mac Developer Application:" --entitlements entitlements.plist MyGame.app/Contents/MacOS/MyGame

This command signs all dynamic libraries (.dylibs) in the file using find:  
 

find MyGame.app/Contents/ | grep .dylib | xargs codesign -f -v -s "3rd Party Mac Developer Application:" --entitlements entitlements.plist

Then sign the whole app: 
 

codesign -f -v -s "3rd Party Mac Developer Application:" --entitlements entitlements.plist MyGame.app/

With everything signed, we can now package the app. To generate an uploadable .pkg, run: 
 

productbuild --component MyGame.app/ /Applications --sign "3rd Party Mac Developer Installer:" MyGame.pkg

Now open the Application Loader app on your system. Click the “choose” button and select your new .pkg file. The Application Loader will scan your package for any errors then upload it to the App Store Connect portal.
TechBlog_MacIntegration_HighresScreenshot00002.png

Common packaging problems

Finally, I have a few quick issues to point out that might come up during your journey.

First, if you encounter any problems with packaging, the ongoing thread for these issues in the Unreal forums is: https://forums.unrealengine.com/community/community-content-tools-and-tutorials/68346-how-to-create-the-proper-pkg-file-for-deployment-to-the-macstore/page2

Next, the Application Loader might reject your app with the reason “ERROR ITMS-90135: The executable could not be re-signed for submission to the App Store. The app may have been built or signed with non-compliant or pre-release tools.” This error message is truly a nightmare, since it basically means “something is wrong but we are not able to tell you what.” My team hit this issue for several days, and in our case, it turned out we were including debug symbols in our build, which was breaking the app processing. Make sure you uncheck “Include Debug Files” in your project settings.

Finally, the most common Application Loader rejection reason we’ve seen has to do with our application icon. There are a variety of tools and techniques for generating a .icns file that is up to spec, but in our case, our workflow ended up using App Wrapper 3 to generate an icon set from a PNG file.

Go to Source
Author: Moving Pieces Interactive Technical Director Kyle Erf

Categories
ProgrammableWeb

Test VS Queries without Leaving VS Code with GraphQuill

GraphQuill, a Virtual Studio (VS) Code extension that performs GraphQL API testing within the VS Code environment, was recently released as an open-source project on GitHub and added to Microsoft’s Visual Studio Marketplace. The goal of GraphQuill is to eliminate the need for switching between VS Code and GraphiQL, Postman, or some other API development tool during development and testing.

“With GraphQuill, our basic idea was to give devs working on GQL projects a quicker and easier way to test their queries without having to leave VS code,” Austin Ruby of the GraphQuill team commented in a blog post announcement.

To achieve its goal, Ruby’s team sought to build GraphQuill by addressing five goals. First, users should be able to run their server with their API. Second, devs should be able to write queries in line with the rest of their code. Third, users should be able to efficiently parse queries from their code. Fourth, it should be able to listen to the current file for changes and know when to query the API. Finally, it should actually query the API and print the results to the VS Code terminal.

In addition to these five core concepts, GraphQuill includes additional features helpful to developers. Developers can output the current schema in the GraphQuill output channel. Additionally, the team has published a dockertized version and locally hosted (PostgreSQL and MongoDB) database versions. For more information, check out GraphQuill on GitHub.

Go to Source
Author: <a href="https://www.programmableweb.com/user/%5Buid%5D">ecarter</a>

Categories
Hackster.io

Seeed Opens Pre-Orders for NPi i.MX6ULL Dual-Ethernet Dev Board

Seeed Studio has begun taking pre-orders for the NPi i.MX6ULL development board, targeting those working in the industrial control and transportation sectors with features including up to 8GB of on-board storage, dual Ethernet ports, and a real-time clock (RTC) as standard, plus the promise of Raspberry Pi HAT compatibility.

Including carrier board, the NPi comes in at just 100x60mm. (📷: Seeed Studio)

Based on an i.MX6ULL computer-on-module (COM) attached to a custom breakout board, the NPi includes an NXP Arm Cortex-A7 processor running up to 800MHz, 512MB of DDRL3 RAM, a choice of 256MB of NAND flash or 8GB of eMMC storage, and an on-board battery-backed real-time clock. Connectivity includes two 100Mb Ethernet ports, a single USB 2.0 Host connection, a USB Type-C port for operation in device mode, a microSD slot for additional storage, FPC LCD interface with touch input, and two 40-pin GPIO headers.

Back of the board. (📷: Seeed Studio)

The GPIO headers are worthy of a second look: The primary header boasts compatibility with the Raspberry Pi GPIO pinout, with Seeed promising that a range of Hardware Attached on Top (HAT) modules designed for the Raspberry Pi will work unmodified on the NPi — including the company’s own HAT products, which add audio, CAN-BUS, or Grove connectivity. The secondary header, meanwhile, offers additional connectivity above and beyond that available on a Raspberry Pi.

The module plus carrier is, Seeed explains, targeted at “industrial control, rail transit, drone control, and audio output,” though there’s a warning in the company’s product documentation: It has rated the COM component at an operating temperature of -20℃ to 80℃, but has not tested the breakout board’s operating range — something that may make it ill-suited for embedding in more extreme environments.

The NPi i.MX6ULL packs plenty of features in a small footprint. (📷: Seeed Studio)

Pre-orders are now open, ahead of a late October shipping date, priced at $39 for the 256MB NAND and $44 for the 8GB eMMC variants. Seeed Studio has promised support for Debian, Ubuntu, and Yocto Linux through its fork of the BeagleBoard Image Builder.

Go to Source
Author: Gareth Halfacree

Categories
3D Printing Industry

Desktop Metal expands capabilities of Studio System with H13 3D printable tool steel

Award winning 3D printer manufacturer Desktop Metal has launched H13 tool steel for its Studio System. Demonstrating exceptional hot hardness and abrasion resistance, H13 is an incredibly versatile material suitable for both hot and cold tooling applications. Ric Fulop, CEO and co-founder of Desktop Metal, stated: “Expanding the Studio System materials portfolio to include H13 tool steel […]

Go to Source
Author: Tia Vialva

Categories
ProgrammableWeb

Stoplight Announces API Visual Editor

Stoplight, a provider of API design management solutions, has announced the release of Stoplight Studio, a new visual API editor that aims to simplify OpenAPI development. The new interface includes tools designed to enable real-time API testing and to streamline collaboration.

The company claims that the new editor will provide users with a no-code solution that could enable less experienced customers to get started designing and deploying APIs quickly. 

The solution also provides users with built-in mock servers that have pre-configured connections to several Git providers, allowing users to test APIs in real-time and then easily share their work with collaborators.

Disclosure: MuleSoft, the parent company to ProgrammableWeb, is a competitor to the company mentioned in this article.

Go to Source
Author: <a href="https://www.programmableweb.com/user/%5Buid%5D">KevinSundstrom</a>