Jonathan · @JTostitos
168 followers · 387 posts · Server techhub.social

Got an issue trying to access a singleton from a swift package. It gives me this error: "Class property 'shared' is not a member type of
'UserPreferences'"

Anyone know why this might be the case when it works perfectly fine when accessing it from within the package itself? Package is based on Swift 5.9 and on Xcode 15 beta 5.

#swift #SwiftLang #swiftui #iosdev #ios17

Last updated 2 years ago

SwiftStudio.app · @swiftstudio
178 followers · 10 posts · Server indieapps.space

Come a little bit closer baby
Get it on, get it on
‘Cause tonight is the night when two become one

How many differences can you spot? 🤭

#xcode #swiftstudio #SwiftLang #swift

Last updated 3 years ago

Jon Reid · @qcoding
713 followers · 367 posts · Server techhub.social

Let's add microtests to existing code!
I'll be 13 hours from now on twitch.tv/qcoding, working on the TripService kata in .

#livecoding #LegacyCode #swift #UnitTesting #SwiftLang

Last updated 3 years ago

Jon Reid · @qcoding
689 followers · 361 posts · Server techhub.social

How can you write assertions to verify optionals, getting the most from failures? qualitycoding.org/unit-test-op

#xctest #swift #SwiftLang #unittests

Last updated 3 years ago

Jon Reid · @qcoding
661 followers · 348 posts · Server techhub.social

Let's add microtests to existing code!
I'll be 1.5 hours from now on twitch.tv/qcoding, working on the TripService kata in .

#livecoding #LegacyCode #SwiftLang #swift #UnitTesting

Last updated 3 years ago

Jon Reid · @qcoding
651 followers · 342 posts · Server techhub.social
Jon Reid · @qcoding
643 followers · 338 posts · Server techhub.social

Let's add tests to existing code!
I'll be 2.5 hours from now on twitch.tv/qcoding. I'll be looking at some real-world ("legacy" meaning "without tests").

#livecoding #swift #SwiftLang #LegacyCode #UnitTesting

Last updated 3 years ago

Jon Reid · @qcoding
640 followers · 313 posts · Server techhub.social

ViewControllerPresentationSpy now updated for Xcode 14 support.
This is the easiest way to microtest view controller presentation and dismissal.
github.com/jonreid/ViewControl

#unittests #uikit #SwiftLang #iosdev #UnitTesting

Last updated 3 years ago

Jon Reid · @qcoding
640 followers · 313 posts · Server techhub.social

Update on my battle between swizzling and 's new concurrency rules. It took 3.5 hours, but I finally found a workaround.

Where I had

private static func swizzleMocks() {…}

I now have

private nonisolated static func swizzleMocksIgnoringActorIsolation() {
perform((swizzleMocks))
}

@objc private static func swizzleMocks() {…}

I'm skirting around Swift by doing a perform selector via the Obj-C runtime.

Besides that, I declared the test spies as MainActor, and also the test suites.

#SwiftLang #selector

Last updated 3 years ago

Raúl Ferrer · @raulferrer
4 followers · 5 posts · Server techhub.social

Secure your data in Keychain in Swift. New post is out! Don’t miss it! 😉

raulferrer.dev/blog/keychain_s

#iosdev #swift #SwiftLang

Last updated 3 years ago

Jon Reid · @qcoding
606 followers · 280 posts · Server techhub.social

Just had a great time mentoring someone who wanted to learn outside-in . We went from a tap on a table view cell to a "present the detail" protocol. The test used a spy, but the real code wanted the skeleton of the real presenter.
Then we TDD'd the presenter, confirming it pushed a detail view controller to a navigation spy.
The rest is TDDing that the new view controller actually shows the detail info.

#tdd #SwiftLang #iosdev

Last updated 3 years ago

Jon Reid · @qcoding
602 followers · 272 posts · Server techhub.social

Holy crap , your zeal for correctness over ease-of-use is killing me… I had working code that is now broken, with no changes from me.

My previously fine static func now leads to errors. Fine, I'll mark my stuff as MainActor. Happy?

No. Because now you say I can't call my cleanup from deinit, since the cleanup is MainActor but deinit might be called from any thread. But it is, that's how I use it. It cleans up after itself. This is a useful pattern. Let me through, dammit!

#SwiftLang

Last updated 3 years ago

Jon Reid · @qcoding
566 followers · 235 posts · Server techhub.social

I've drafted a blog post about the death of . Will hold onto it until the new year. Subheadings:
- What Killed AppCode?
- Swift Refactorings We'll Now Never See in AppCode
- What's the Future of and Code Generation in ?

#appcode #refactoring #SwiftLang

Last updated 3 years ago

Jon Reid · @qcoding
562 followers · 231 posts · Server techhub.social

How do you test a custom test assertion? It depends. Usually, by hand, unless… stackoverflow.com/a/74880885/2

#SwiftLang #xctest

Last updated 3 years ago

Jon Reid · @qcoding
539 followers · 221 posts · Server techhub.social

Writing microtests for a CancellableImageLoader. I was able to write the first 3 tests without changing how it uses a Task:

test_showsPlaceholderWhileLoading
test_loadsImageFromURL
test_showsLoadedImage

But to test canceling the task, I extracted protocols to create seams:

- Cancellable (slice of Task)
- AbstractTaskFactory with implementers DetachedTaskFactory and TestingTaskFactory

This let me write:

test_secondImageLoadCancelsFirstImageLoad

These 4 microtests run in 22ms.

#SwiftLang

Last updated 3 years ago

Jon Reid · @qcoding
536 followers · 218 posts · Server techhub.social

I went to bed thinking about a new conference talk: "What If?" The goal would be to expand people's thinking about what is possible. Maybe even inspire new toolmakers. Based on a talk by Llewellyn Falco, it would be a coding demo showing my preferred Swift tools:

• AppCode (RIP, just to inspire) showcasing automated refactoring
• TCR (test && commit || revert) for refactoring (impractical in Xcode, easy in AppCode)
• ApprovalTests (the one piece you can use in Xcode, but very few people know about it)

folks: Would you come to such a talk?

#SwiftLang

Last updated 3 years ago

ObjectBox · @objectbox
20 followers · 3 posts · Server techhub.social

Hey Swift fans, here is our Christmas present 🎅 for you:

🎁 ObjectBox Swift 1.8.0 🎁
github.com/objectbox/objectbox

>> Build with Xcode 14.1 and Swift 5.7.1
>> Enjoy many internal improvements -> full list here cpp.objectbox.io/#latest-versi

#SwiftLang #iosdeveloper #iosdev

Last updated 3 years ago

SwiftStudio.app · @swiftstudio
0 followers · 1 posts · Server indieapps.space
Michael Brown · @mluisbrown
41 followers · 50 posts · Server techhub.social

Heads up if you are using TCA and mixing ReducerProtocol with old style reducers. Without explicit types, compile times can explode. Our app reducer went from 10s to 100s until we added explicit types with just a single ReducerProtocol 🤯

#SwiftLang

Last updated 3 years ago

Michael Brown · @mluisbrown
41 followers · 50 posts · Server techhub.social

This code has a major bug which is caused by an irritating Swift inconsistency. Can you spot it?

#SwiftLang

Last updated 3 years ago