While accessing PHPicker, the following error occurred. However, I could access the image successfully.
2021-03-07 16:28:16.910394+0900 **** [4516:1164237] [default] [ERROR] Could not create a bookmark: NSError: Cocoa 257 “The file couldn’t be opened because you don’t have permission to view it.” }
How to clean up the app and all associated data from devices.
Symptom
XCode 12.4
iPhone 8
iOS 14.4
macOS Big Sur 11.2.1
When I was testing Nega Viewer App Clip which access the camera and photo library, suddenly PHPhotoLibrary.requestAuthorization did not ask permissions. I tried the following cases, and only #3 worked for me.
Solutions
Case #1
Remove the application from the iPhone. It did not work.
CASE #2
Remove the application from the iPhone.
Go to [Settings] >> [General] >> [Date & Time]
Set Automatically Off
Set future date
It did not work.
Case #3
Remove the application from the iPhone.
Power off iPhone and restart.
It worked. After the restart, it did not happen again.
Case #4
⌘ + Shift + 2, or Xcode >> Menu >> Window >> Devices and Simulators
Select the application and press the minus button to delete the app and all associated data.
Before I tried this, it has been fixed. I will try this next time.
テストデバイスでApp Clipのスキームを構築して実行し、App Clipがテストデバイスにキャッシュされていることを確認します。たとえば、Frutaサンプルコードプロジェクトでは、指示に従って構成してから、スキームを実行します。サンプルコードプロジェクトをダウンロードするには、Fruta: Building a Feature-Rich App with SwiftUI.にアクセスしてください。
テストデバイスで、[設定]アプリを開き、[Developer]> [Local Experience]に移動して、[Register Local Experience]を選択します。
Title とSubtitle のテキストを入力します。Frutaサンプルコードプロジェクトの場合、タイトル[Order a smoothie.]とサブタイトル[It’s yummy!]を入力します。
行動を促すフレーズ(たとえばOpen)を選択します。。
App Clipカードのヘッダー画像として使用する写真を選択します。
注意
テストデバイスでApp Clipのスキームを構築して実行し、デバイスにキャッシュするだけでなく、App Clipの.ipaファイルをデバイスに手動で追加することもできます。まず、App Clipの対応する完全なアプリをアーカイブします。次に、Xcodeの[Organizer]ウィンドウで、Ad Hoc またはDevelopment distribution にApp Clipのバイナリをエクスポートします。最後に、App Clipのエクスポートされた.ipaファイルを、Xcodeの[Devices and Simulators]ウィンドウで接続されているデバイスにドラッグします。
let provider = ASAuthorizationAppleIDProvider()
let groupUserDefaults = UserDefaults(suiteName: "group.com.example.appClipDataMigration")
let user = groupUserDefaults?.get("SavedUserID")
provider.getCredentialState(forUserID: user) { state, error in
if state == .authorized {
readFavoriteSmoothies(user)
}
}
While adding App Clip target to the original target, the following uncaught exception occurred. As for the normal app target works fine. Only on App Clip Target did not work.
2021-02-23 05:48:05.968176+0900 NegaViewerAppClip[7319:368124] [Storyboard] Unknown class _TtC10NegaViewer18MainViewController in Interface Builder file.
2021-02-23 05:48:06.032046+0900 NegaViewerAppClip[7319:368124] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[<UIViewController 0x7f93b5e20ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageViewOut.’
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[<UIViewController 0x7f93b5e20ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageViewOut.’
terminating with uncaught exception of type NSException
CoreSimulator 732.18.6 – Device: iPhone 12 Pro Max (31C0DAD9-EF0A-4822-A496-75B919FEB25E) – Runtime: iOS 14.4 (18D46) – DeviceType: iPhone 12 Pro Max
(lldb)
Cause
It happened while I was refactoring (renaming) the class.
In the main storyboard, the Module of MainViewController was specified the original application target. So, MainViewController is bundled only for the original application target.
Solution
Check “Inherit Module From Target” as follows and it worked.