Once again, the most frustrating and weird error message: "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions"
struct TimePosition: View {
		var scale: Double
		var body: some View {
				GeometryReader { geometry in
						VStack {
								ForEach(0..<Int(geometry.size.height)/Int(1/self.scale), id:\.self) { y in
										Text(String(Double(y)/4.0)).position(x: geometry.size.width/2, y: CGFloat(y)).font(.system(size: 8.0)).foregroundColor(.gray)
								 }
						}
				}
		}
}
So, how exactly does one break this up?
Post
Replies
Boosts
Views
Activity
This code has a behavior that I think might be a bug, but I wanted to check to see if anyone spots a flaw in my thinking.
This code makes a scrollable containing a single view which itself encapsulated a longer-than-the-screen list. Note the UnitPoint on line 9, the y: component seems to be a percentage.
The bug is that the point requested must be on the screen. In this case, it seems to be around the 12, but with different numbers I get different results.
The only time it seems to be consistent is if the current scroll position is at the very top.
struct ListVsScrollview: View {
		var body: some View {
				NavigationView {
						ScrollViewReader { sv in
								VStack{
										Button("Move") { sv. ;sv.scrollTo(72, anchor: UnitPoint(x: 0.0, y: 0.1)) }
										ScrollView {
												VStack {
														Text("Hi").font(.title)
														ForEach(0...100, id: \.self) { number in
																Text("\(number)").font(.title)
														}
														Text("Low").font(.title)
												}.id(72)
										}
										.navigationBarItems(trailing: EditButton())
								}
						}
				}
		}
}
struct ListVsScrollview_Previews: PreviewProvider {
		static var previews: some View {
				ListVsScrollview()
		}
}
I'm trying to use the MIKMIDI framework. I'm using their source code because I want a particular tag. It builds fine, and passes its own tests. I drag it into the project, and it shows up in the Frameworks folder, but the compiler can't seem to find it. It's target membership is set correctly, Xcode *appears* to see it, and yet I get "No such module 'MIKMIDI'"
Search on this topic on the web is maddening, because nothing really seems to be complete. I'd like to ask for 2 pathways:
Library which comes with Xcode/macOS If I look at my target info panel in the project editor, I can add Frameworks and Libraries. I would like to add libpcre.
I hit the "+", scroll down and select libpcre.tbd. It dutifully adds an entry.
How do I now use this in a swift file, and see the various functions from the pcre library?
Library installed from homebrew
2. Say I have decided that pcre version 1 isn't enough, and I need to add libpcre2. I use "brew install pcre2", which installs the needed file in /usr/local/Cellar/pcre2/10.36/ .
How do I now show Xcode how to find these libraries, and use them in my swift file?
The Test
In both cases, my basic test is that I ought to be able to type
let recode = pcreTAB
and have Xcode show me the various symbols from the included library.
I have a local package and swift algorithms added to the project. I first added them while working on the iOS target.
If I switch to other targets, the packages don't work, even if I clear the caches and resolve them again.
The import error says "no such module", yet if I go to add the package, it says it can't add it, because it already there.
I'm using Xcode 13.2.1.
Using Xcode 14.0 beta
on MacOS 12.4
I have a simple app to play items in the Music library. I'm using MPMusicPlayerController.applicationQueuePlayer to play the music. Nowhere in my project do I refer to the systemMusicPlayer, nor do I have any instances of MPMusicPlayerController() alone.
Yet even if I quit the Music app, selecting a new song opens the Music app.
The code I use:
// inside a View
var mainPlayer = MPMusicPlayerController.applicationQueuePlayer
//at the end of the HStack representing a single song
.onTapGesture {
mainPlayer.setQueue(with: MPMediaItemCollection(items: [song]))
mainPlayer.prepareToPlay()
title = song.title ?? "-- No Title --"
mainPlayer.play()
}
Here's some code:
import SwiftUI
struct RRectPlay: View {
var body: some View {
Canvas { gc, size in
gc.translateBy(x: 20.0, y: 20.0)
gc.stroke(
Path(roundedRect: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 200.0), cornerSize: CGSize(width: 2.0, height: 2.0)),
with: .color(.black),
lineWidth: 20.0
)
}
}
}
struct RRectPlay_Previews: PreviewProvider {
static var previews: some View {
RRectPlay()
}
}
It shows a rounded rect, as requested:
If I add the fixedSize modifier to the preview:
RRectPlay().fixedSize()
The rectangle disappears:
If I add a border to see what's happened, I get this:
It seems like the definiation of "Ideal Size" ought to be something closer to the bounding box of the figure if there are no other items on the screen.
Can anyone elucidate me?
I have a cli program which does a thing for a while, and I'd like it to post a notification on the screen when it's done. Note that because it's a standalone program, not an app, it doesn't have a bundle, per se.
I tried to use UserNotifications, but I get an immediate error with the line
let center = UNUserNotificationCenter.current()
With the error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL
My entire program to produce this bug:
import Foundation
import UserNotifications
let center = UNUserNotificationCenter.current()
print("Hello, World!")
I'm getting this message in a launchd log. The service in question is a Focusrite thing.
What does it mean?
(system/com.focusrite.ControlServer) : cannot spawn: service is in penalty box
The peripheral seems to be working fine.
I have an app with looks at the @Environment(\.horizontalSizeClass) variable and it's mate vertical. On the iPhone 16 sim, if I'm in portrait orientation, It says my vertical class is .regular and horizontal is .compact.
If I rotate to landscape, it says vertical is now compact, and horizontal is still compact. That seems inconsistent.
I'm trying to wrap my head around designing for size class, how am I supposed to think about this?
What I want is two areas of the screen: The main area, which shows a graphic, and a much smaller control and data area, which has a button or two and a very narrow text display, which in my current app counts from 1 to 4. The button area
These areas ought never move from where they are, but their contents ought to rotate in place to reflect the orientation. If portrait, the button area is on the bottom, if landscapeLeft, the button are is to the right, if landscapeRight, the button area is to the left.
This currently sort of works if I test for the max of height or width from a Geometry Reader, but it doesn't handle landscapeRight or portraitUpsideDown correctly.