I've got 22,000 lines of SwiftUI in my app (Dvn8). I've seen this lots of times.
Most commonly, it's that your view is composed of more than 10 views, and if you'll either Group { } some of the components together, or break them out into separate functions using @ViewBuilder or AnyView, the compiler will suddenly be able to grok how to compile it all. This is something I never saw in UIKit, but it crops up a lot in SwiftUI.
Note, too, that it's not arbitrary. Once you've refactored into something the compiler can handle, it won't complain about it again.
I've also seen this crop up when I was lazy and allowed for auto type coercion - like, for example, if I've defined a var x = 0.0 but then later on attempt to access x as a CGFloat and then still later on as a Double. The compiler seems to dislike lazy coercions, so I've made a point of always being explicit in my declarations - that has seemed to minimize how often this error shows up.
Finally, if I just can't seem to find the culprit, I will go ahead and break the view into function calls that return @ViewBuilder sub-views. Almost always, this results in cleaner to read code for me, and easier to compile code for Xcode. And then I hit myself on the forehead, do my best Homer Simpson "Doh!" impersonation, and I increment iGottaRememberToDoThisMoreOften by 1.
In general, I would LOVE it if Xcode were more explicit in its errors - I've spent hours trying to track down some rather vague (although friendly!) error messages.
Post
Replies
Boosts
Views
Activity
Well, I finally figured it out myself. Turns out that somewhere around WatchOS 9 RC, the place where I had been calling workoutManager.requestingAuthorization() (ie, I was calling it from ContentView.onChange(of:scenePhase) ) became no longer valid, and I had to instead call .requestingAuthorization() from within the .onAppear() of the view which actually starts the workout.
I’ve not seen any documentation that relates to where in my code base I need to call the workout.requestingAuthorization(), and the fact that the workoutManager.elapsedTime was functioning gave me some headaches, but all’s well now.
Hey yellow8 - I did find a solution - and it was simple. My problem was in my entitlements files for the iCloud Key-Value Store. I needed to ensure that there was no “.” between the $(TeamIdentyifierPrefix) and my bundle identifier. So, in both the App.entitlements as well as the Widget.entitlements, the dict entries needed to be:
<?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.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)domain.myAppBundle</string>
</dict>
</plist>
Previously (and incorrectly), the value would have been this:
<string>$(TeamIdentifierPrefix).domain.myAppBundle</string>
Just that “.” was my headache.
OK, I've solved my issue. 1st of all, defining 2 NSPersistence : ObservableObjects most definitely wasn't the way to go:
@StateObject var app1DB = PersistenceApp1.shared
@StateObject var app2DB = PersistenceApp2.shared
I just needed one:
@StateObject var persistence = Persistence.shared
deeje's answer pointed me in the right direction, but what was still missing for me were the following 3 key ideas:
container's name: is just the name of the .xcdatamodeld - and that this has nothing to do with what I expected (ie, that it was somehow related to my CloudKit container ids “iCloud.com.company.App1”)
container = NSPersistentCloudKitContainer(name: "Model")
Within Model.xcdatamodeld I needed to define 2 separate configurations - with each configuration holding the Entities that are held within the the CloudKit containers:
"App1Config" - holds the Entity from iCloud.com.company.App1, and
"App2Config" - holds the Entity from iCloud.com.company.App2
I needed 2 store descriptions for each app, and to specify the sqlite backing stores to be used for each
var url1 = NSPersistentContainer.defaultDirectoryURL().appendingPathComponent("App1.sqlite")
let app1DB = NSPersistentStoreDescription(url: url1)
app1DB.configuration = "App1Config"
let url2 = NSPersistentContainer.defaultDirectoryURL().appendingPathComponent("App2.sqlite")
let app2DB = NSPersistentStoreDescription(url: url2)
app2DB.configuration = "App2Config"
container.persistentStoreDescriptions = [ app1DB, app2DB ]
From there, my App2 simply needs to read/write from/to the Entities as needed - and the container takes care of all the rest. I ❤️ CloudKit!
Just got bricked in iPadOS 16.1. It's been working until today, but I removed the iPad from the Magic Keyboard and kaboom! I've got a brick.
Work-around found!
I found this in the release notes:
Added View.scrollContentBackground, which permits customization of background colors for scrollable views like List. (45928055)
And so here’s the new version…
struct ContentView: View {
@State var text = "Type something here."
var body: some View {
ZStack {
Color.blue.ignoresSafeArea()
if #available(iOS 16.0, *) {
TextEditor(text:$text)
.multilineTextAlignment(.center)
.scrollContentBackground(Visibility.hidden) // new technique for iOS 16
.frame(height: 100)
.padding([.leading, .trailing], 40)
} else {
// Fallback on earlier versions
TextEditor(text:$text)
.multilineTextAlignment(.center)
.frame(height: 100)
.padding([.leading, .trailing], 40)
}
}
.onAppear {
// Fallback on earlier versions
UITextView.appearance().backgroundColor = .clear
}
}
}
iOS 16 beta 5 continues to exhibit this bug
FYI: I submitted FB10908604 regarding this
Same problem here. I tried turning on/off everything as suggested in this thread, even un-paired my Watch from iPhone. Nothing worked. Spent 5 hours trying to rectify.
And then I finally found a solution: I cleared the /Users/me/Library/Xcode/DerivedData directories for my app. (ie, any directory which begins with your app name.) That did it. Could have saved myself a 1/2 day of programming if I had tried that 1st.
YMMV
I have a very similar issue. I've got an app currently in the store that is:
a) showing App Clip Domain Status = "Bad JSON Content", and
b) won't allow Advanced App Clip Experiences due to the App Clip Experience URL = "This URL is not contained in your app's associated domains."
c) unable to recognize an App Clip Code
Here's my debugging steps:
This is the contents of my .well-known dir:
root:~/dvn8/ROOT/.well-known$ more apple-app-site-association
{
"appclips": {
"apps": { ["myappbundle.myreversedomain.Dvn8.Clip"] }
},
}
With each attempt to View Status of the "Bad JSON Content", I see 2 calls to apple-app-site-association - both of which return HTTP Status 200:
44.232.70.210 - - [17/Jun/2022:12:03:38 -0700] "GET /.well-known/apple-app-site-association HTTP/1.1" 200 80 "-" "AASA-Bot/1.0.0"
44.232.70.210 - - [17/Jun/2022:12:03:38 -0700] "GET /apple-app-site-association HTTP/1.1" 200 80 "-" "AASA-Bot/1.0.0"
With respect to creating an Advanced App Clip Experience in App Store Connect (“Edit Advanced Experiences”), and the error "This URL is not contained in your app's associated domains", my entitlements are as follows:
myMainApp.entitlements
* com.apple.developer.associated-domains: ( "appclips:dvn8.app" )
* com.apple.developer.associated-appclip-app-identifiers: ( "myappbundle.myreversedomain.Dvn8.Clip" )
myAppClip.entitlements
* com.apple.developer.associated-domains: ( "appclips:dvn8.app" )
* com.apple.developer.parent-application-identifiers: ( "myappbundle.myreversedomain.Dvn8" )
When I create an App Clip Code using the command line generator, and then I point any of my test devices at the code, I consistently get “No useable data found”. Of course, when running the App Clip from Xcode - it works beautifully. I just can’t figure out what I’m missing to get the Experience defined in App Store Connect, and why the App Clip Code doesn’t have useable data.
Many thanks for any thoughts on what I’m might be missing!!!
Similar problems here too - M1 MBAir (21A5522h). Never saw the issue prior to latest OS upgrade
Am I missing something in the above program listing?
This is such a fundamental basic requirement - to wrap @FocusState with @available(iOS 15) and then later in the code check #available(iOS 15) - that it's hard to believe that it is a bug. The more likely answer is that I'm not using these compiler directives correctly...
Any thoughts? Any help?
I had a very similar experience when trying to get iPadOS 15 beta 2 installed from my Mac which was running Monterey beta 2. I just kept trying, expecting to get different results. And lo & behold - after 3 days - I did: it finally just worked. My only suggestion is to just keep on trying…
The rather comical account of my trials: https://developer.apple.com/forums/thread/683943 (Note that the answer to this thread includes the exact steps I repeated until I finally got success.)
I had a very similar experience when trying to get iPadOS 15 beta 2 installed from my Mac which was running Monterey beta 2. I just kept trying, expecting to get different results. And lo & behold - after 3 days - I did: it finally just worked. My only suggestion is to just keep on trying…
The rather comical account of my trials: https://developer.apple.com/forums/thread/683943
So, it turns out that perseverance is key to this problem, too...
Despite having given up earlier today, I just couldn't stand by and watch my iPad become a paper-sized paper-weight - so I tried it a couple more times. Same exact procedure, each time expecting different results. Notwithstanding - finally success!!!
A big shout-out to the consumer-facing AppleCare support folks @ Apple, as it was they who suggested I try putting the iPad into Recovery Mode. The rep said he couldn’t guarantee it would work with beta software - but maybe it’d be worth a try…
So, here’s what I did to get iPadOS 15 beta 2 on my iPad:
1 - I shut down both my MBAir and my iPad Pro
2 - I connected both via USB-C cables
3 - I powered up both devices, and waited for them to fully boot
4 - I pressed the following buttons on the iPad to enter Recovery Mode:
1. Volume up (quick press)
2. Volume down (quick press)
3. Top / power button (press and hold - until laptop <- cable image appears)
4. Note: this may take several attempts (it sometimes took me over 12 tries - on each Recovery Mode attempt!) to get the “laptop <- cable” image - otherwise, it just reboots
5 - Launch Finder on MBAir
6 - Select iPad
7 - A dialog box appeared, select Restore
8 - Hold down the option key and select “Restore and Update” (so that I could select the .ipsw image - instead of contacting the Apple software update servers.
9 - Select the image “iPad_Pro_Spring_2021_15.0_19A5281j_Resore.ipsw”
10 - Cross fingers and repeat as necessary
Honestly, it took me 3 full days and tons of attempts. In the end, I have no idea what was actually causing my iPad to hang-up - and at this point I don't care. It works, I'm happy, and I've got a deadline to slay...