u/OakAndCobble

▲ 22 r/SwiftUI

How heavily do you lean on Apple's UI?

Would you/ have you built an entire app with virtually no custom components? So, using pretty much only what SwiftUI gives you – like its TextField, its navigation bar, its List, and so – instead of DIY-ing that stuff. If yes, how did it turn out?

Can you give any examples of apps on the App Store that look good and highly Apple-like?

reddit.com
u/OakAndCobble — 9 days ago
▲ 6 r/swift

SPM question

Hi, I am having issues defining multiple targets in a swift package. I have my main target /(and) library, and then I am trying to make a second target with no accompanying library that I'll only use internally in the package. Folder structure looks like this:

Package.swift
Sources
    | – MyLibrary              <- Same level as
       |– IrrelevantStuff

    | - MyInternalTarget      <- this. Both under sources dir
       |– InternalStuff
            |- MyFile.swift

According to Xcode, I cannot preview inside of MyFile.swift because

- ”MyFile.swift” not found in any targets

- The source must belong to at least one target in the current scheme in order to use previews

But my manifest seems to be properly written.

let package = Package(
    name: "MyLibrary",
    platforms: [.iOS(.v26)],
    products: [
        .library(
            name: "MyLibrary",
            targets: ["MyLibrary"]
        ),
    ],
    targets: [
        .target(
            name: "MyLibrary",
            path: "Sources/MyLibrary"
        ),
        .target(
            name: "MyInternalTarget",
            path: "Sources/MyInternalTarget"
        )
    ],
    swiftLanguageModes: [.v6]
)

What's going on here?

reddit.com
u/OakAndCobble — 9 days ago

Issue with protocols - "any View cannot conform to View"

Hello,

What is the solution to this problem, assuming that you are not supposed to use `AnyView`, which I hear over and over again?

Given this protocol:

protocol MyProtocol {
    associatedtype V: View
    var content: () -> V { get }
}

if I want to store a heterogenous collection of MyProtocol,

let collection: [any MyProtocol]

then the underlying `V` type of each is erased to `any View`, which (supposedly) does not conform to `View`.

Is there no way to "unbox" the existential `any View` to get the underlying `View` back? That unboxing idea is something I heard in a few WWDC videos but it seems like it does not apply to `View`.

reddit.com
u/OakAndCobble — 16 days ago

Morning,

Can I extract the auth user ID from 'req' inside a function? As in, in my frontend, I have a supabase client with the auth configured with a particular user. When that user sends function requests, I want to get their supabase auth user ID.

Deno.
serve
(async (req <- this 'req') => { ... }

Also, how can I simulate authenticated user function calls inside Bruno (Postman alternative)?

Thanks.

Edit:

When I say simulate authenticate user, what I mean is I have a dummy user account in supabase and I want to send requests from Bruno as that user.

reddit.com
u/OakAndCobble — 19 days ago

I tried to ask a question on the typescript subreddit and they've yet to approve the post, so I'm hoping I can get a quicker response here.

Can anyone explain why I am getting an error on the last line where I try to reference a member of the map? Any member, not just entries() results in the same error: Uncaught (in promise) TypeError: newDraft.itemsPerCategory.entries is not a function. It seems like there is no way to get the interpreter to recognize that the parsed json is of type DraftOrder (despite the fact that I see the DraftOrder type hint in my IDE).

export class DraftOrder {

    itemsPerCategory: Map<LaundryCategoryType, number>

    constructor(itemsPerCategory: Map<LaundryCategoryType, number>) {
        this.itemsPerCategory = itemsPerCategory
    }

    static 
empty
(): DraftOrder {
        return new DraftOrder(new 
Map
<LaundryCategoryType, number>)
    }

}

// Creating new draft, converting to json
const map = new 
Map
([[
LaundryCategory
.LIGHT, 2], [
LaundryCategory
.MEDIUM, 3]])
const jsonString = 
JSON
.stringify(
    new DraftOrder(map),
    (_, value) => {
        if (value instanceof 
Map
) {
            return 
Object
.fromEntries(value)
        }

        return value
    }
)
console
.log(jsonString)

// Converting json back to draft
const parsed = 
JSON
.parse(jsonString)
console
.log(parsed)

const newDraft = (parsed as unknown) as DraftOrder
console
.log(newDraft.itemsPerCategory.entries())
reddit.com
u/OakAndCobble — 23 days ago

How do I manually inject dependencies into RequestController classes? I just started learning spring and from my bit of research, all I've come up with is the Autowired and Component/Service annotations.

I am still having a hard time understanding how exactly I tell spring what to build. If the dependency of my controller needs dependencies injected into it, what do I do? How do I specify which implementation of a dependency I want built? And so on.

Essentially, how do I get a bit more control of dependency creation and injection in a non-trivial situation, like the ones seen in examples on the internet?

Thanks in advance for any responses.

reddit.com
u/OakAndCobble — 24 days ago