Swift Packages

RSS for tag

Create reusable code, organize it in a lightweight way, and share it across Xcode projects and with other developers using Swift Packages.

Posts under Swift Packages tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Xcode : Package.resolved file is getting deleted on branch switching in git
Hi Team , We are having an issue that when we open the Xcode and switch any git branches(either through Xcode or using any other git GUI tools) the package.resolved file is getting deleted automatically So we need to reset the git each time on a branch switch to regenerate the package.resolved file Please note if the Xcode is quit and if we do the branch switching from an external git GUI, this issue is not happening Also there is no change is added to the package.resolved file between these two branhces , So theoritically there is no need of updating this file while we switch the branch
2
0
99
2d
Sudden errors that never happened before
Hello, I've been working on my macos app for months, today I opened XCode, and it's full of the same errors "Value of type 'URL' has no member 'url''" and "Cannot convert value of type 'Binding' to expected argument type 'CGFloat'". I didn't change ANYTHING, I didn't update nor remove anything, the 3rd party module I'm using didn't get updated, this is all out of the blue! I tried to clean the build folder, erase the derivated data, rebuild a new project, these errors won't go away...worst part is that another of my app use the same codes and there I see the errors but the app still compiles and build!!
0
0
113
6d
SPM Package resources bundle id format has changed in Xcode 16
I have a project that uses local SPM packages for modularization. In one of my local SPM packages I have a .storyboard file that gets packaged as a resource in the SPM package and consumed inside the parent. In Xcode 15.4, the resource bundle for my local SPM Package has the bundle id PackageName-TargetName-resources. I use this inside a parent storyboard to reference the storyboard from the SPM package. In Xcode 16, however, the resource bundle for my SPM Package gets assigned the bundle id packagename.TargetName.resources. This, of courses, introduces a crash in builds of my app done with Xcode 16 due to the incorrect bundle id. There is no documentation of this change that I could find by Apple or by the SPM team. Apple Team: There is a Feedback Report FB14803020 with the build files attached from Xcode 15.4 and Xcode 16. I cannot attach those here due to the public nature of this forum
1
0
110
3d
Learning Management System (LMS) Framework for Swift App
Is there any good framework that can be used in educational app as Learning Management System (LMS). Should be full fledge for creating courseware for E Learning App. Should be compatible with all Apple Platforms. Any help or link will be greatly appreciated. As I didn't found anything that mentions designed for Xcode. All LMS belong to Web based apps.
0
0
140
1w
com.apple.dt.deviceprocesscontrolservice Code=8
Hello, I get this error: How can I fix it and hope you can help me. greetings Fabian SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'de.polygondata.BikeComputer.BikeComputerWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'de.polygondata.BikeComputer.BikeComputerWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0x600000c36e50 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}} Domain: DTXMessage Code: 1 User Info: { DVTErrorCreationDateKey = "2024-08-16 17:14:32 +0000"; } SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'de.polygondata.BikeComputer.BikeComputerWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'de.polygondata.BikeComputer.BikeComputerWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0x600000c36e50 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000c37150 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (de.polygondata.BikeComputer.BikeComputerWidget)}}, FBSOpenApplicationRequestID=0xbf3b, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}} Domain: DTXMessage Code: 1
0
0
112
1w
Swift Package Manager not building external dependencies correctly
I have created my own SPM through File -> New -> Package Package.swift looks like: // swift-tools-version: 5.10 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "MyPackage", platforms: [.iOS(.v16), .macCatalyst(.v16), .macOS(.v14)], products: [.library(name: "MyPackage", targets: ["MyPackage"]),], dependencies: [ .package(path: "../external-package") ], targets: [ .target(name: "MyPackage", path: "Sources"), .testTarget(name: "MyPackageTests", dependencies: ["MyPackage"]), ] ) When I run swift build the error says: '.../MyPackage/.build/arm64-apple-macosx/debug/external-package.build/external-package-Swift.h' not found and surely, when I go to directory: .../MyPackage/.build/arm64-apple-macosx/debug/external-package.build/ there are only 2 files in there: module.modulemap & output-file-map.json All source files from external-package are missing, therefore swift build fails. The only solution I've found is to copy external-package.build folder manually into: '.../MyPackage/.build/arm64-apple-macosx/debug/` What am I missing here? Should swift build create those files in there, or they should be resolved somehow differently? Note: external-package is not in any way unique, this happens to any added dependency I'm running on macOS 14.6.1 on Apple Silicon M1 Pro with Xcode 15.4
1
0
133
1w
CSV File Load Into Swift
Hi, I am fairly new Xcode/Swift and am trying to load a CSV File for use in my development. I have placed the CSV file in my Assets folder but when I try to create my Data Model and load the CSV file. I run into the error: No exact matches in call to initializer. Below is the code. I have attached CSV File. Any help fixing this error would be greatly appreciated. Thanks in advance for your help. Brian Hospital_Demographic_Data_Sample.csv import Foundation import CSV struct HospitalData: Codable { let providerNumber: String let hospital: String let address: String let city: String let state: String let zip: String let wageIndex: Double let caseMix: Double let averageCharge: Double let discharges: Int let totalCharges: Double let adjTotalCharges: Double // Add other fields as needed based on the columns in your CSV file } func loadHospitalData() -> [HospitalData]? { guard let filePath = Bundle.main.path(forResource: "Hospital_Demographic_Data", ofType: "csv") else { print("File not found") return nil } do { let csv = try CSV(url: URL(fileURLWithPath: filePath)) var hospitalDataList = [HospitalData]() // Initialize as an empty array for row in csv.namedRows { if let providerNumber = String(row["Provider CCN"] ?? ""), // Replace "Provider CCN" with actual column name let hospital = String(row["Hospital Name"] ?? ""), // Replace with actual column name let address = String(row["Street Address"] ?? ""), let city = String(row["City"] ?? ""), // Replace with actual column name let state = String(row["State Code"] ?? ""), // Replace with actual column name let zip = String(row["Zip Code"] ?? ""), // Replace with actual column name let wageIndex = Double(row["Wage Index"] ?? ""), let caseMix = Double(row["Case Max"] ?? ""), let averageCharge = Double(row["Base Charge"] ?? ""), // Replace with actual column name let discharges = Int(row["Medicare Discharges"] ?? ""), let totalCharges = Double(row["Total Charges"] ?? ""), let adjTotalCharges = Double(row["Total Wage Normalized Charges"] ?? "") { // Replace with actual column name let hospitalData = HospitalData( providerNumber: providerNumber, hospital: hospital, address: address, city: city, state: state, zip: zip, wageIndex: wageIndex, caseMix: caseMix, averageCharge: averageCharge, discharges: discharges, totalCharges: totalCharges, adjTotalCharges: adjTotalCharges ) hospitalDataList.append(hospitalData) } } return hospitalDataList } catch { print("Failed to load CSV file: \(error)") return nil } } // Usage Example func main() { if let hospitalData = loadHospitalData() { for data in hospitalData { print("Hospital: (data.hospital), City: (data.city), Average Charge: (data.averageCharge)") } } }
1
0
129
1w
Getting build errors for my Package.swift Swift Package Manifest
Using Xcode 15.4 and macOS Sonoma 14.6.1 and Reality Composer Pro 1.0. Lately (I believe since updating to Xcode 15.4, not sure..), I'm getting build errors that I didn't get before. The error is saying that "the package manifest at /Package.swift cannot be accessed (/Package.swift doesn't exist in file system)". When I click for more information and bring up the Resolve Packages - Log, it gives a red X error "Resolving Package Graph Failed" I'm not sure why I'm recently getting this error. My Reality Composer Pro Package is part of my project and listed in my project navigator as it has been. The Package.swift file is in the same file location as it has always been and I believe it is correct. I tried removing the package from my project navigator then dragging and dropping it back into the project navigator, but I'm still getting the error. Note: this error is only appearing on a working branch for a new version I'm working on. The error does not appear on my production (main) branch even though it is the same package and location in Finder and appears the same way in the main branch project navigator. I get these same errors on Xcode 16 Beta 5.
4
0
251
5d
Import swift package dependency to project with ci/cd
Hi, I have a question about packages in swift. I need to import package from this link https://github.com/jedisct1/swift-sodium. Readme show the way to import it with xcode. But I need to do it with gitlab-ci so I can't open xcode there and add dependency manually. And this is my question. Is there any possibility to add package dependency to target with xcodebuild or swift-cli? I've tried to do this with cocoapods but unfortunately it not working in my case. It is importing Sodium library but not Clibsodium package. I'll be very glad if someone could help me wth this case.
0
0
118
3w
Static property 'shared' is not concurrency-safe because it is non-isolated global shared mutable state
Hi all, I am fairly new to Swift development so go easy on me! I am working through a few examples of using Reality Kit content within my projects and whilst trying to work on adding gestures to RealityKit entities, I have come across a weird issue. Downloading and running the example here This works fine for me. When adding the same things to my own code - in this case a class called EntityGestureState to my GestureComponent file (within the reality kit project) I constantly get this error: "Static property 'shared' is not concurrency-safe because it is non-isolated global shared mutable state" Even just troubleshooting with something as simple as: public class EntityGestureState { // The entity currently being dragged if a gesture is in progress. // Singleton shared instance static let shared: EntityGestureState = EntityGestureState() } I immediately get the error and from a bunch of trial and error and reading different sources I can't seem to get around this. Could anyone help here? I am running on Xcode 16 beta 3 so am wondering if it's a bug but also more than likely user-error.
2
0
357
2w
Swift Package Registry support in Xcode
I know that Xcode doesn't have explicit support in the UI for Package Registries yet, but can use packages referenced by ID if the registry is set up through the CLI. I also see that xcodebuild has support for SCM to registry transformation (resolving and downloading packages through a registry, even if the packages are referenced using their Github URLs) through command line arguments like "-defaultPackageRegistryURL" and "-packageDependencySCMToRegistryTransformation". Is there any way to achieve the same thing in Xcode itself?
1
1
155
3w
In Xcode 16 beta 3, adding a framework to a target doesn't work?
In Xcode 16.0 beta 3 (16A5202i) I'm trying to add a framework to a target. I'm clicking the '+' button under Target > General > Frameworks, Libraries, and Embedded Content: When I do this, the dialog that appears doesn't list any frameworks: I feel like I'm doing something wrong or missing something obvious. This issue is easy to reproduce by creating a new project in Xcode. I tried reverting using Xcode 15 to add the framework that way, but Xcode 15 is unable to load the project file that Xcode 16 wrote. Incidentally, Add Other > Add Package Dependency has no effect when selected: Assuming this is a bug I should submit feedback about, is there another method I can use in the meantime to add a framework to my target so I can continue working? This is blocking development. Thank you for any help you provide.
7
3
297
3w
How to Use RealityKitContent Package for App Targets Lower Than iOS 18.0
I am trying to display a 3D model in iOS app using RealityView. The same 3D model is displayed successfully in the visionOS app. Everything works perfectly only when I set my project’s minimum deployment target to iOS 18.0. However, my app’s minimum deployment target is iOS 15.0. When I use the RealityKitContent package to load the 3D model, it fails to compile and gives me the following error: Compiling for iOS 15.0, but module 'RealityKitContent' has a minimum deployment target of iOS 18.0: /Users/Library/Developer/Xcode/DerivedData/RealityViewForiOS-cbfkgimsqngtuegqwvezusvscllf/Index.noindex/Build/Products/Debug-iphonesimulator/RealityKitContent.swiftmodule/arm64-apple-ios-simulator.swiftmodule I have made the RealityKitContent package optional and tried importing using the following condition: #if canImport(RealityKitContent) import RealityKitContent #endif Despite this, it still fails to compile and produces the same error. I have not found a workaround for using the RealityKitContent package with app targets lower than iOS 18.0. Here is my package definition: let package = Package( name: "RealityKitContent", platforms: [ .visionOS(.v1), .macOS(.v15), .iOS(.v18) ], products: [ .library( name: "RealityKitContent", targets: ["RealityKitContent"]), ], dependencies: [], targets: [ .target( name: "RealityKitContent", dependencies: []), ] ) Here is the code I am using to load the 3D model with RealityView using the RealityKitContent package: import SwiftUI import RealityKit #if canImport(RealityKitContent) import RealityKitContent #endif struct ContentView: View { var body: some View { VStack { if #available(iOS 18.0, *) { RealityView { content in if let scene = try? await Entity(named: "Scene", in: realityKitContentBundle) { content.add(scene) } } update: { content in if let scene = content.entities.first { let uniformScale: Float = 3.0 scene.transform.scale = [uniformScale, uniformScale, uniformScale] } } } else { // Fallback for earlier versions } } } } #Preview { ContentView() } Any help or guidance on how to use the RealityKitContent package for app targets lower than iOS 18.0 would be greatly appreciated.
0
2
203
3w
Linker errors when building with Xcode 15 and CocoaPods — building for iOS
** BUILD FAILED ** The following build commands failed: Ld /Users/siddesh/Library/Developer/Xcode/DerivedData/App-ddpkkzvberburtewkcvoihnirgjh/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/Logging.build/Objects-normal/x86_64/Binary/Logging normal x86_64 (in target 'Logging' from project 'Pods') (1 failure) Testing with xcodebuild. -> mySDK_Staging (8.8.0) - WARN | attributes: Missing required attribute license. - WARN | license: Missing license type. - WARN | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred. - WARN | [iOS] license: Unable to find a license file - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. - NOTE | xcodebuild: note: Using codesigning identity override: - - NOTE | [iOS] xcodebuild: note: Building targets in dependency order - NOTE | [iOS] xcodebuild: note: Target dependency graph (20 targets)
0
0
139
Jul ’24