Your Second iOS and SwiftUI App, Episode 12: Image Binding | raywenderlich.com

The reason the images you’re adding to your library are not showing up is Book Images currently only display symbols. Let’s fix that!


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/25836622-your-second-ios-and-swiftui-app/lessons/12

With Swift 5.5 and XCode 13.1 it complains about the Image not being the proper type
Cannot convert value of type ‘Binding<Image?>’ to expected argument type ‘Binding<UIImage?>’

Updating the image binding to UIImage? fixes it but following the tutorial later makes everything not work any more.

Actually, I copied the code from Version 3 in Github and is working again.

1 Like

Does not seem to work video-yssa-materials/12-image-binding/Final at versions/2.0 · raywenderlich/video-yssa-materials · GitHub. Selecting Image does not show in the app.

@lancy98 @chargio Hi! Sorry about that. As @chargio mentioned, the Version 3 branch is the one you should be using, but we failed to update that to be the default branch before publishing the course.

I’ve updated the repo so it should point you to the most recent materials, now. :]

Hello @catie, Thank you for the reply. I was using version 2. Now that I downloaded version 3 - I can still see the same issue when running the project under the final folder.

There are two issues that I see when running the project under XCode 13.1

  1. Bunch of constraint warnings when running the project in the console.
  2. The image that I select in the picker does not display in the app. The console prints out the below log

2021-11-19 11:03:54.807985+1300 ReadMe[48417:7625491] [claims] Upload preparation for claim F4747C0A-2E72-49CB-88AD-DA55CBE7C312 completed with error: Error Domain=NSCocoaErrorDomain Code=260 “The file “version=1&uuid=CC95F08C-88C3-4012-9D6D-64A413D254B3&mode=compatible.jpeg” couldn’t be opened because there is no such file.” UserInfo={NSURL=file:///Users/user/Library/Developer/CoreSimulator/Devices/862B79EA-FE48-46FC-924D-DBC55465E018/data/Containers/Shared/AppGroup/6C94D220-5744-4B5B-813D-CF5680B9F3E7/File%20Provider%20Storage/photospicker/version=1&uuid=CC95F08C-88C3-4012-9D6D-64A413D254B3&mode=compatible.jpeg, NSFilePath=/Users/user/Library/Developer/CoreSimulator/Devices/862B79EA-FE48-46FC-924D-DBC55465E018/data/Containers/Shared/AppGroup/6C94D220-5744-4B5B-813D-CF5680B9F3E7/File Provider Storage/photospicker/version=1&uuid=CC95F08C-88C3-4012-9D6D-64A413D254B3&mode=compatible.jpeg, NSUnderlyingError=0x600003f913b0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}

Hi! Great questions, thanks for bringing them up.

1 - The constraint warnings are lingering SwiftUI bugs that you can safely ignore. They’re referencing UIKit constraints, which we can’t really do anything about when working with SwiftUI. Hopefully Apple will handle these in the future!

2 - The pink flower image is missing from the simulators. If you select any other image, it should work. I am sorry for not calling this out in the video itself, because it’s a bug that’s been around for a while, now, that you will run into anytime you’re using the photo picker. If you dig to find the missing file referenced in the console, you’ll see there is a matching .heic file there, but not the .jpeg it’s looking for. And the .heic file is empty!

Empty Flower Image

It still shows up in the simulator’s Photos library because there is a valid thumbnail file hanging around in:

Library/CoreSimulator/Devices/[ENTER DEVICE ID HERE]/data/Media/PhotoData/Thumbnails/V2/DCIM/100APPLE/IMG_0006.HEIC