bpurinton

bpurinton

Hotwire Native for Rails Developers: Collected Errata from our class at the University of Chicago

Title: Hotwire Native For Rails Developers

Collected Errata from our class at the University of Chicago

Great book, Joe!

We have collected a number of sticking points and snags from our class of 25 students that all finished going through the book yesterday.

I’m just putting these all in one collected thread, rather than several threads:

Chapter 1

Android Emulator Version Mismatch

When I ran my app the first time in Android Studio, I got an error on the phone emulator screen: “Error loading screen”. If you see this, it may be because the phone emulator is running a lower version of the API SDK than the version you were told to set in the build.gradle.kts file in the book (version 35). If you see an “Error loading screen” error when you first run your app in Android Studio, you should go to “Device Manager” on the right side of the screen, delete the existing device (you will likely see “API XX” in the name, where XX is the version number of the API SDK that the emulator is running), then, once you delete that device, use the plus icon to create a new device. You can select “medium phone” and then download one of the images that it provides you with to install a version greater than or equal to the version you set in the build.gradle.kts file.

Chapter 4

Removing “Story Board Name” In Xcode

This may have just been some step I missed in a previous section, but: After setting up the Tab Model and Controller, my app wouldn’t start in Xcode, and just showed a blank screen. I had to navigate to the App/Resrouces/Info.plist file and use the - icon to remove the Storyboard Name key:

Using guard let ... in scene function

In addition, and I saw many other students requiring this, I had to use the following code in the scene function in my SceneDelegate.swift file:

  func scene(
        _ scene: UIScene,
        willConnectTo session: UISceneSession,
        options connectionOptions: UIScene.ConnectionOptions
    ) {
        guard let windowScene = scene as? UIWindowScene else { return }
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = tabBarController
        self.window = window
        window.makeKeyAndVisible()
    }

Without the guard let ... block at the bottom of the function there (which is not in the book), the app would build in Xcode, but just show a blank screen on simulator launch.

A small note about Likes tab

On page 84, the book mentions that you can add additional tabs to the tab bar, using Likes as an example. A number of our students got stuck here, since /likes are not actually an exposed route in the Rails app. We know what you meant, but a note here (e.g. “this is just an example, and this tab won’t work if you don’t expose a likes route in your Rails app”) would alleviate some confusion.

Manually update AndroidManifest.xml after reorganizing

On page 85, where the book says to drag MainActivity.kt into the new activities package in Android Studio, that move didn’t update the resource in the manifest/AndroidManifest.xml file. I had to manually update the android:name line to point to ".activities.MainActivity":

<!-- manifest/AndroidManifest.xml -->
<!-- ... -->
        <activity
            android:name=".activities.MainActivity"

Typo in onCreate in MainActivity

On page 96, the book did not change:

findViewById<View>(R.id.main_nav_host).applyDefaultImeWindowInsets()

The main_nav_host in that line to:

findViewById<View>(R.id.hikes_nav_host).applyDefaultImeWindowInsets()

hikes_nav_host, within the onCreate function in the MainActivity.kt file.

Chapter 7

Missing d-hotwire-native-class on link

On page 166-167, in the ch07_17 codeblock, there is a missing d-hotwire-native-block class in the link_to "Add a hike". This missing class appears in other codeblocks as well. Without it, the “Add” button won’t appear in the native apps.

Chapter 9

Registering your Mac to upload an archive

On pages 205-206 of the book, when trying to archive and upload a build in Xcode, I noticed this error message that prevented me from doing so:

The book doesn’t mention of this.

To fix the issue: first, I went to Sign In - Apple, and clicked on “Devices” in the “Certificates, IDs & Profiles” section.

Then, I clicked the blue plus icon to get to Sign In - Apple.

On that screen, I filled in the form like so:

I got my device’s “Unique Device Identifier (UUID)” by going into my laptop “Settings”, then clicking “General”, then clicking the “System Report” button to bring up a window where I found my device’s UUID to copy into the form in the browser.

Once I filled in the form with my laptop information, and clicked the “Continue” and “Register” buttons on the next screens, back in Xcode in the “Signing & Capabilities” section, I was able to “Try again” and get the error message to go away. Then, I could proceed as the book says to select “Product > Archive” in the Xcode menu bar.

Version updates for Play store uploads

Unlike Xcode / Apple, Android Studio / Play do not allow re-uploading code without version changes in the metadata. If you see an error like this in the Play store when creating an internal release after uploading the app-release.aab file:

Then, you know you need to update the versionCode and versionName in the App (second one in the list) build.gradle.kts file. Find these lines:

        versionCode = 1
        versionName = "1.0"

And increment them:

        versionCode = 2
        versionName = "1.1"

Then you’ll be able to “Build > Generate Signed App Bundle / APK”, and upload that new file to create a version incremented release in the Play store.

Chapter 10

Sandbox for APN key

On page 238, when registering a new key, to “Continue” after giving the key a name and checking the “Apple Push Notifications service (APNs)” service, I had to also click “Configure” next to the “Apple Push Notifications service (APNs)” service. You can select “Sandbox” (the defaults) on the next screens, and “Register”. Once you do that, you’ll be returned to the new key screen, and you can click “Continue”.

A word about this and some description of the Sandbox vs. Production configuration might be beneficial.

Small typo in credentials code

On page 258, in the codeblock (unnamed) at the bottom of the page in the example credentials file, fcm: should outdented one level, instead of indented as shown in the book.

Easy to miss removal of HotwireWebFragment

On page 264 of the book, I originally missed the step shown in the ch10_58 codeblock, where we remove these two lines from the HikingJournalApplication.kt application subclass:

import dev.hotwire.navigation.fragments.HotwireWebFragment

and

HotwireWebFragment::class,

without removing those, the app doesn’t function correctly. Maybe just some call-out text highlighting this removal just above or below the codeblock would be helpful.

Where Next?

Popular Pragmatic Bookshelf topics Top

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
HarryDeveloper
Hi @venkats, It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same eff...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
RobertRichards
Hair Salon Games for Girls Fun Girls Hair Saloon game is mainly developed for kids. This game allows users to select virtual avatars to ...
New

Sub Categories: