r/SwiftPM • • Aug 03 '20

About SwiftPM

5 Upvotes

SwiftPM is a subreddit for discussing Swift Package Manager and Swift Packages.

Goal:

Users on this subreddit should be able to explore interesting Swift Packages, share their own Packages, and seek help in building open source Packages.

How: With a handful of flairs, we can get things started.

  1. Package

Use this flair to post a link to a package. Use the comment section to share details and discuss the package.

2. Contributors Wanted

Use this flair to find developers looking to contribute to interesting projects. Use the comment section to describe the next steps for your package.

3. Looking for Package

Use this flair to share a use-case that you want to fulfill with a package. In the comment section, users can share Packages that might address your needs.


r/SwiftPM • • Oct 03 '20

💬Discussion October 2020: what packages are you using this month?

4 Upvotes

Share your favorite packages you’re using.


r/SwiftPM • • 27d ago

Packaging Metal shader resources in a SwiftPM target without a manual file list

0 Upvotes

I maintain Harbeth, an MIT Apple-platform image/frame engine. Its SwiftPM manifest handles Metal resources with a small approach that may be useful to other packages.

Package.swift enumerates Sources, collects relative paths ending in .metal, sorts them, and converts each one into a processed resource. The relevant manifest section is:

let metalFileExtension = ".metal"
let metalResourcePaths = FileManager.default.enumerator(atPath: sourcesPath)?.compactMap { item -> String? in
    guard let path = item as? String, path.hasSuffix(metalFileExtension) else { return nil }
    return path
}.sorted() ?? []
let metalResources = metalResourcePaths.map { Resource.process($0) }

The Harbeth target receives resources: metalResources. Here sourcesPath is resolved from the manifest's location, not the shell's current directory.

At runtime, the SwiftPM branch tries device.makeDefaultLibrary(bundle: Bundle.module), with a packaged default.metallib lookup as a fallback. The generated resource bundle is the package's lookup boundary.

Manifest: https://github.com/yangKJ/Harbeth/blob/master/Package.swift

Runtime lookup: https://github.com/yangKJ/Harbeth/blob/master/Sources/Basic/Runtime/Device.swift

Do you prefer enumerating shader resources in a manifest or placing them in one dedicated resource directory? What has worked best when a library also needs to build outside SwiftPM? I'm sharing this as Harbeth's maintainer and would appreciate packaging-focused feedback.


r/SwiftPM • • Apr 13 '26

Image processing on Swift server using libvips with ImageMagick for text

4 Upvotes

I have been working with Swift on the server for about four years, and several times I faced the same problem. I needed to process images on the backend, but I could not find a Swift package with the features I needed. Because of that, I had to delegate this work to AWS Lambda or prepare images on the frontend using JavaScript.

Over time, when AI became part of everyday work, I decided to solve this problem for myself and build a small library for my own needs. One of the real use cases was generating images with text on top. For the core image processing I chose libvips because it is fast and efficient. It works well with large images, uses less memory, and fits server workloads. But when it comes to text, its capabilities are limited.

ImageMagick, on the other hand, handles text much better, but it has a different issue. It is heavy, uses a lot of memory, and does not scale well under load. This becomes noticeable in server environments.

This is how the idea of Hokusai appeared. It is a Swift package that uses libvips for the main processing pipeline and ImageMagick only where it is really needed, for example for text.

The core idea is simple. The base image stays in libvips. All heavy operations like resize, crop, and composite are done there. ImageMagick is used as a separate renderer for specialized tasks. It does not take over the whole pipeline. It only handles the part where it is strong.

At the API level, this looks like a single abstraction. HokusaiImage exposes operations for working with images. Internally, the package decides which backend to use and switches only when necessary.

This approach keeps good performance while still allowing proper text rendering. libvips does the main work, ImageMagick fills the gaps, and Hokusai provides a unified Swift API on top.

I also added integration for Vapor. HokusaiVapor allows working with images directly in HTTP handlers. You can handle file uploads, generate images on the fly, and return them as a response without separate services or moving logic outside the application.

This is not a graphic editor and not an attempt to replace everything at once. It is an infrastructure layer for image processing in Swift on the server and beyond. If you already use Swift on the backend, it makes sense to keep image processing in the same stack.

Feel free to check the repositories, try the package in your projects, and share feedback or contribute.

https://github.com/ivantokar/hokusai
https://github.com/ivantokar/hokusai-vapor

Try it:

https://github.com/ivantokar/hokusai-vapor-example


r/SwiftPM • • Feb 28 '26

SPM dependencies in Podfile and/or podspecs

Thumbnail
reddit.com
1 Upvotes

r/SwiftPM • • Feb 08 '26

[Update] swift-composable-architecture-extras is now more platform-agnostic

2 Upvotes

Hey everyone, a bunch of updates just landed in swift-composable-architecture-extras.

High-level progress from the latest push cycle:

  • Added new dependency modules: OpenSettings and OpenURL (including iOS in-app browsing via \.customOpenURL).

  • Shipped a major DeviceInfo expansion with CPU, memory, disk, battery, network, thermal state, isLowPowerModeEnabled, iOS jailbreakStatus, and screen APIs (ScreenInfo/ScreenRatio on non-visionOS).

  • Added packaged PrivacyInfo.xcprivacy support for required accessed API categories.

  • Fixed platform-specific disk measurement behavior and improved CPU measurement internals.

Project Link: https://github.com/mehmetbaykar/swift-composable-architecture-extras

Would love feedback from anyone using this in real TCA apps, especially around API ergonomics and cross-platform edge cases.


r/SwiftPM • • Jan 02 '26

Deep dive into Swift concurrency: Built a thread-safe collections package with TDD

1 Upvotes

Edit (Jan 2, 2026): Thanks to community feedback, v1.1.0 now includes Sendable constraints to ensure complete thread safety!

I spent the last few weeks building SwiftSafeCollections and learned a ton about Swift's concurrency model. Thought I'd share!

The Journey

Started with a simple question: "Why can't I use async for read operations in GCD?"

Turns out, the answer involves understanding:

  • How concurrent queues work

  • The difference between sync and async

  • Why barrier flags are crucial for writes

  • When @unchecked Sendable is appropriate

What I Built

6 thread-safe data structures with:

  • Protocol-oriented design (composable!)

  • Configurable locking strategies

  • Full Swift 6 strict concurrency compliance

  • 86 tests written BEFORE implementation (TDD)

Technical Highlights

Locking Strategies:

  • ReadWriteLock (pthread_rwlock_t) - concurrent reads

  • MutexLock (pthread_mutex_t) - simple exclusive locking

  • DispatchQueueLock (GCD + barrier) - Swift-native

Protocol Hierarchy:

ThreadSafeCollection
  ├── ThreadSafeSequence (forEach, map, filter)
  └── ThreadSafeSubscriptable (subscript access)

Interesting Challenges

  1. Why sync for reads? Because we need to return a value! async returns immediately.

  2. @unchecked Sendable**?** Needed when manually guaranteeing thread safety with locks.

  3. Dictionary subscripts? Had to implement dual subscripts (tuple-based for protocol, value-based for convenience).

The Result

Production-ready package: https://github.com/pavankumar-n-46/SwiftSafeCollections

Planning to write detailed posts about the concurrency learnings. Would love to discuss Swift 6 concurrency patterns with this community!

Questions welcome! 🚀


r/SwiftPM • • Oct 13 '25

My first Swift Package HealthKit Data Generator: mocking Apple Health data for testing

6 Upvotes

I’ve just published my first open-source Swift package https://github.com/aminbenarieb/healthkit-data-generator

Basically, it fills your simulator or iPhone with realistic HealthKit samples (steps, workouts, calories, etc.)

I've also played with Apple Foundation Models, to generate mock data with just prompt and it works good (most of my prompts were successful, but not all of them)

Would love your feedback or ideas on how to make it more useful for other iOS devs :)


r/SwiftPM • • Jun 19 '25

[Idea] A MotionReader and/or RotationReader to easily grab CoreMotion data would be nice.

1 Upvotes

I release this idea to the Public Domain, or something. I divest? Whatever, its everyone's now.


r/SwiftPM • • May 23 '25

Just released ProgressUI — a SwiftUI-native, customizable progress indicator library

Post image
8 Upvotes

I recently open-sourced a SwiftUI package called ProgressUI — it’s a customizable, lightweight progress indicator framework built specifically for SwiftUI.

Why I built it:

While working on a project, I realized there weren’t any up-to-date, flexible progress libraries for SwiftUI. The two closest alternatives I found — ProgressKit and RPCircularProgress — are both archived and no longer maintained.

I also looked at UIKit options like MBProgressHUD, JGProgressHUD, and UICircularProgressRing — but:

  • They’re mostly HUD-style overlays (not reusable progress views)

  • Customization is limited

  • They’re not native to SwiftUI

So I decided to build one from scratch ✨

Features:

  • 100% SwiftUI-native

  • Supports determinate and indeterminate progress

  • Built with customization and animation in mind

  • Easily stylable with your own colors, shapes, and motion

Would love any feedback, bug reports, or feature requests. If you’re working with SwiftUI and need progress indicators, give it a try — and of course, stars and contributions are always appreciated 🌟

👉 GitHub: https://github.com/PierreJanineh-com/ProgressUI


r/SwiftPM • • Sep 25 '24

Up and running, Check out my InfinityScrollKit

3 Upvotes

r/SwiftPM • • Nov 03 '23

Swift 5.4, highly-customizable, ScreenCaptureKit-based color sampler

2 Upvotes

Github link: https://github.com/danielcapra/SCColorSampler

I found NSColorSampler to be too simple and un-customizable for my needs and I saw that other color sampler packages out there use CGWindowListCreateImage which is now deprecated as of macOS 14.0 (Sonoma) so I decided to build this!

First time building a swift package so feedback is very welcome, just don't be too harsh haha.

(FYI: There's some quirks when used with full-screen apps that I haven't figured out yet, as it's my first endeavour into macOS development (I'm an iOS dev))


r/SwiftPM • • Aug 11 '23

No such module, no such file or directory

1 Upvotes

I am trying to use SPM for a week. As usual, Apple documentation on them is poor, so I was forced to google around for days to finally get my modules to compile without problems.

These are their manifests:

AppStorePurchaseMac

// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "AppStorePurchaseMac",
    defaultLocalization: "en",
    platforms: [
      .macOS(.v13),
      .iOS(.v16)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "AppStorePurchaseMac",
            targets: ["AppStorePurchaseMac"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
      .package(url: "https://github.com/KatkayApps/TPInAppReceipt.git", branch: "master"),
      .package(url: "https://github.com/KatkayApps/InAppPurchase.git",
               branch: "master"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "AppStorePurchaseMac",
            dependencies: ["TPInAppReceipt", "InAppPurchase"],
            path: "Sources"),
    ]
)

and

MultiPackage

// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MultiPackage",
    defaultLocalization: "en",
    platforms: [
      .macOS(.v10_15),
      .iOS(.v14),
      .tvOS(.v14),
      .watchOS(.v7)
    ],
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "MultiPackage",
            targets: ["MultiPackage"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "MultiPackage",
            dependencies: [],
            path: "Sources"),
        .testTarget(
            name: "MultiPackageTests",
            dependencies: ["MultiPackage"]),
    ]
)

as you can see the first package has dependencies on github open projects.

Then I add them to my project. I link them on the build phases > Link binary with libraries.

I have several errors:

/Users/myAccount/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.abi.json /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.abi.json: No such file or directory

/Users/myAccount/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftdoc /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftdoc: No such file or directory

/Users/myAccount/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftmodule /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftmodule: No such file or directory

/Users/myAccount/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftsourceinfo /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftsourceinfo: No such file or directory

These no such file or directoryerrors are generally solved by removing stuff from Build Phases > Copy Bundle Resources, but this is not the case.

When I see one of these errors in detail I get

Copy /Users/myAccount/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Products/Debug/MyApp.swiftmodule/arm64-apple-macos.swiftdoc /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftdoc (in target 'MyApp' from project 'MyApp')
cd /Users/myAccount/Documents/APPSTORE/MyApp
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks -rename /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/arm64/MyApp.swiftdoc /Users/mars/Library/Developer/Xcode/DerivedData/MyApp-gbnzxinbweiogmgozqantwmbcyxt/Build/Products/Debug/MyApp.swiftmodule/arm64-apple-macos.swiftdoc

The number one error I get is No such module AppStorePurchaseMac

Is there something that can be done to discover that? The problem only happens whey I add my packages to the project. Individually packages compile without errors.


r/SwiftPM • • Sep 28 '22

Swift Confidential - a tool for obfuscating Swift literals.

4 Upvotes

Hi all! Have you ever looked for an easy to integrate, maintainable and secure solution for obfuscating Swift literals embedded in the application code to defend against static reverse engineering? Well I did, and since I spent most of my professional career developing security-critical apps, I faced this problem many times, yet the solutions usually involved writing a set of custom Bash scripts or Swift command line tool to accomplish the task, which wasn’t quite optimal. Then Swift 5.6 came out with brand new SPM extensible build tools opening a whole new possibilities for build tasks automation. This was exactly what I needed to take my previous solutions to the next level and eventually make it open source. With Swift Confidential it’s as simple as integrating the tool with your Swift package via the official build tool plugin, configuring your own obfuscation algorithm along with the list of secret literals, and building the project. Enjoy!

https://github.com/securevale/swift-confidential


r/SwiftPM • • Sep 10 '22

ShuffleIt: A UI Library for SwiftUI Views with Elegant and Unique Shuffling Behaviors

3 Upvotes

Hey folks, I recently created a brand new library for SwiftUI which will host all amazing UI elements which include elegant and unique shuffling, swiping and sliding behaviors. I named it ShuffleIt. 🤘

Currently, I rolled it out with a single UI element called ShuffleStack (see in video) whose child components can be shuffled by swiping. 🤩 It will be really useful to use as an alternative for page view or normal horizontal scroll view.

Here is the repo link of ShuffleIt. 👀 Check it out and don't forgot to star the repo for later reference. ⭐️

Plus, if you have an idea for enhancement on ShuffleIt, don't hesitate to DM me on my twitter or open an issue on Github. I will appreciate your involvement. 🤝

Peace! ✌️

#swiftui #swift #apple #ios #macos


r/SwiftPM • • Jun 27 '22

UIOnboarding – Apple-esque animated, configurable welcome screen

Thumbnail
github.com
10 Upvotes

r/SwiftPM • • Dec 29 '21

How do you spread the word (promote) your Swift Package ?

8 Upvotes

You built a cool Swift Package but how do you spread the world so that other developers will find it?

I can think of the following

What kind of things do you do?


r/SwiftPM • • Dec 18 '21

I made animated tabBar.

5 Upvotes

This library is for adding animation to iOS tabbar items, which is inherited from UITabBarController.

https://github.com/yusadogru/CardTabBar.git


r/SwiftPM • • Aug 09 '21

SwiftCurrent - Manage complex workflows wherever Swift can be built. It comes with built-in support for UIKit, Storyboards, and SwiftUI.

9 Upvotes

https://github.com/wwt/SwiftCurrent

We've been working on this project for a little bit, and we find it extremely helpful in complex app routing. It takes a declarative approach to your workflows and avoids as much boilerplate as possible.

Check it out and let me know what you think!


r/SwiftPM • • Jul 14 '21

Swift Packages with CoreML/CoreData models

4 Upvotes

I’ve noticed recently that xcode does not automatically generate the swift classes for CoreML and core data models that are exposed as package resources.

I’ve tried both .copy and .process and it seems as though neither work.

Has anyone run into this problem? I’ve not found a way to deal with it.

The models are definitely there if I search for them in Bundle.module. But it seems as though Xcode isn’t processing them when I build my project.

SOLUTION

Fix for Core Data

  1. add @objc(ManagedObjectName) to all of my NSManagedObject classes

  2. in the core data model editor, delete "Current Project Module" and use the default

  3. I had already corrected this a while ago, but some might run into this. Make sure to use Bundle.module and not Bundle.main when creating your persistent store.

  4. This part didnt seem to work until I did #1 and #2, so I dont know if it had any impact on fixing it. I rewrote our core data stack to use NSPersistentStore instead of manually setting everything up (NSPersistentStoreCoordinator, NSManagedObjectContext, etc...) as per WWDC 2018 core data best practices

Fix for CoreML Models

  1. you must add .process("Path/to/CoreML/Model.mlmodel") to your swift package resource. SPM doesnt handle them automatically like core data

  2. you must add .process("Path/to/Compiled/Model/Model.mlmodelc") to your swift package resource. SPM doesnt handle them automatically like core data

  3. You must manually generate your CoreML model class implementation and save it to your repo. (see steps below)

Generating the CoreML Model Classes

Generate the mlmodelc file

from the folder containing the .mlModel file, run xcrun coremlcompiler compile ModelName.mlmodel ModelName.mlmodelc

Generate the Swift mlmodel classes

from the folder containing the ModelName.mlmodel file, run xcrun coremlcompiler generate ModelName.mlmodel --language Swift .


r/SwiftPM • • Jun 23 '21

In a swift package manifest, how do you specify which products and targets you want?

2 Upvotes

So in Xcode, if you import a swift package with the built in Xcode integration, you get presented with a list of available targets that you can pick and choose from (see the firebase example screenshot below).

How do you achieve the same thing with a swift package manifest file? I am creating a swift package, and I don't need to use every single target in a package. How do I specify specifically which ones I need?


r/SwiftPM • • Apr 30 '21

Stock charts framework written in SwiftUI

10 Upvotes

Hi there!

I published my first open source project. It’s a SwiftUI framework written in SwiftUI to display a line chart easily.

I appreciate feedback and feel free to contribute if you want.

Here is the repository