import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
// OK
// SwiftUI の ForEach は View を返すので OK
ForEach(1..<5) { i in Text("hello") }
// Error: Closure containing control flow statement cannot be used with result builder 'ViewBuilder'
// クロージャーを持つ制御文は 複数のView を構成する ViewBuilder として使えない
// 要は、次のように複数の Text からなる View を構成することができない
for i in 1..<5 { Text("hello") }
// Error: Type '()' cannot conform to 'View'
// forEach は View を返さない
[1,2,3,4].forEach{ d in Text("hello") }
}
}
}
run a unit test, then Multiple commands produce … error comes up.
Cause
Error Message is as follows.
Multiple commands produce ….. 1) Target ‘appname’ has … /appname.app’ 2) Target ‘appname_Twitter (iOS)’ has…./appname.app’
It means, there are two files with appname.app for two different targets.
Solution
Rename one of the product name, and clean rebuild. In my case, I renamed my app with Swifter from TARGETS >> Build Settings “Product Name” from appname to appname2.
When I was building an App Clip, the following warning was reported by XCode. Provisioning profile “iOS Team Provisioning Profile: com.aiharasoft.***App” for “***” contains entitlements that aren’t in the entitlements file: com.apple.developer.associated-appclip-app-identifiers. To use these entitlements, add them to your entitlements file. Otherwise, remove unused entitlements from your provisioning profile.
Solution
From https://developer.apple.com/, “Certificates, Identifiers & Profiles” >> “Profiles” >> Choose profile. Somehow, the Status got into Invalid.
And I edited the profile and saved, and the status turned to Active.Rebuild XCode and the warning has gone.
Another point is when I added “Associated Domains” from capabilities, only on debug was selected. Thus, two entitlements file for debug and release were created. I did not notice the two entitlements, debug and release files became inconsistent, and then uploaded to App Store Connect. So, the app got into into inconsistent state.
I’m not sure, but as the warning says, inconsistency between Provisioning Profile and *App.entitlements causes this warning.
Anyway, check the Profiles, entitlements, and the consistencies, first.
When I started debugging with XCode on a physical iPhone 8 device, the debugger stopped with “Finished running”. The app was successfully deployed, up and running on a device, but it could not start debugging.
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]ウィンドウで接続されているデバイスにドラッグします。