Hello, I am trying to obtain the RealityKit URL. Can someone share please?
Swift Packages
RSS for tagCreate 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
I have a project which contains local packages. One of the packages has an explicit dependency on package A, but the main project also has the same dependency. Both of them are pinned to the exact version at all times.
Should I manage "shared" dependencies at the project level for local packages? This seems counter intuitive at first, but this question is originating from me fighting with a "Build service could not create build operation: unable to load transferred PIF: The workspace contains multiple references with the same GUID" error in Xcode 16 (all versions). It happens when I switch branches. Closing and reopening Xcode does resolve the issue, but it's a real flow killer.
The guide below doesn't mention dependency graph best practice.
https://developer.apple.com/documentation/xcode/organizing-your-code-with-local-packages
Thank in advance.
When using Xcode's "Build for Testing", I have noticed the resulting MyApp.xctestrun file has an array of CodeCoverageBuildableInfos. This array has all of our built targets. They all have an Architectures array property. For all of our targets this is set to x86_64 when we build for Any iOS Simulator. This is irrespective of what we have "ARCHS" and "ONLY_ACTIVE_ARCH" set to (in our case we only want arm64).
We do have a number of local swift packages defined, each with their own test targets. We are using a test plan for these tests.
This is causing issues when processing the resulting xcresult file since it is complaining that it can't find objects for the correct architecture when calculating code coverage.
No object file for requested architecture
No coverage data found. (Underlying Error: No object file for requested architecture)
I've not been able to get past the endless spinner when trying to add a Swift Package with a GitHub URL. I deleted Xcode, and reinstalled and it then things worked for the first package I tried… but when I went back to add another it's busted again. Any suggestions? I've reinstalled, cleared Derived Data… no dice
Setup:
PLATFORM AND VERSION: iOS
Development environment: Xcode Version 16.0 (16A242d), macOS 14.6.1
Run-time configuration: iOS 15-18 tried with same error.
When building the app despite the fact it's pure Swift code getting error:
CaPark.swift file is here:
import Foundation
class CarPark: Identifiable, Decodable {
var carParkId: String
var address: String
var totalLots: String
var lotsAvailable: String?
var lotType:String
var lat: Double
var lng: Double
var couponEps: String
var agency: String
}
Issue seems like started after xcode update to version mentioned above.
What i've tried:
Clean ups
Reinstallation of Xcoce
Rollback to previous versions of Xcode
Start clean project from VCS
App is published and multiple versions were uploaded to AppStore, this problem is new and came out of nowhere.
Let me know if additional info is required.
Thank you!
I have a Swift Package that includes XCFrameworks which are exported as binary targets. If I include any of the product in Frameworks and Libraries section of a notification service extension target, build succeeds while the extension crashes with dynamic linker error:
Library not loaded: @rpath/MoEngageRichNotification.framework/MoEngageRichNotification
My workaround is to include the same product in app target's Frameworks and Libraries section and add @executable_path/../../Frameworks to LD_RUNPATH_SEARCH_PATHS settings for extension target.
Is this a known limitation of XCode when using SPM?
I am trying to add a Swift Package from a private Gitlab repository to my Xcode 16 project, and it fails. First symptom is Unable to load the Read Me in the Xcode SPM package browser. And when I add the package, I get a repo.git could not be resolved error.
I've used ProxyMan to sniff the network calls issued by Xcode, and it looks like my Gitlab credentials are not provided as part of the GET request when, for example, Xcode tries to fetch the README.md file from the repository. And when I try to add the package, there are no HTTP network calls issued by Xcode at all.
I have tried adding a Gitlab account to Xcode's Accounts preference pane, and entering the repository's credentials directly when adding the package. Both yield the same result.
Here's a screen capture of Xcode trying to fetch the README:
https://share.cleanshot.com/FNRHm6fq
I am unable to test this in Xcode 15, as I have upgraded my Mac to Sequoia and Xcode 15 can't be installed on this version of macOS.
I have submitted FB15370281 for this issue.
I have a normal UIKit project with a package dependency containing some SwiftUI. Opening the package on its own, I can preview the SwiftUI. However, when I have the package as a dependency, I get the dreaded message saying Active scheme does not build this file regardless of choosing the app or package scheme.
Why can't I get a preview?
Using Xcode 16
I'm trying to make an xcframework from my static library (SPM btw) with macros. My script doesn't work properly
My SPM declaration of macros:
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import CompilerPluginSupport
import PackageDescription
let package = Package(
name: "SomeMacr",
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .macCatalyst(.v13)],
products: [
.library(
name: "SomeMacr",
targets: ["SomeMacr"]
),
.executable(
name: "SomeMacrClient",
targets: ["SomeMacrClient"]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0")
],
targets: [
.macro(
name: "SomeMacrMacros",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
]
),
.target(name: "SomeMacr", dependencies: ["SomeMacrMacros"]),
.executableTarget(name: "SomeMacrClient", dependencies: ["SomeMacr"]),
.testTarget(
name: "SomeMacrTests",
dependencies: [
"SomeMacrMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax")
]
)
]
)
My .sh script:
xcodebuild archive \
-scheme $1 \
-sdk iphoneos \
-archivePath "Products/archives/ios_devices.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $1 \
-sdk iphonesimulator \
-archivePath "Products/archives/ios_simulators.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild archive \
-scheme $1 \
-sdk macosx \
-archivePath "Products/archives/macos.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
xcodebuild -create-xcframework \
-library Products/archives/ios_devices.xcarchive/Products/Library/Frameworks/lib$1.a \
-library Products/archives/ios_simulators.xcarchive/Products/Library/Frameworks/lib$1.a \
-library Products/archives/macos.xcarchive/Products/Library/Frameworks/lib$1.a \
-output Products/xc/$1.xcframework
It requires destination (But in other tutorials, authors clearly shows, that after this script I will get an xcframework)
xcodebuild: error: Building a Swift package requires that a destination is provided using the "-destination" option. The "-showdestinations" option can be used to list the available destinations
But when I setup the destination it was compiled to exec file, which I don't mind how to include to another SPM package / or xcframework
What am I doing wrong?
Since upgrading to Xcode 16, I've noticed that when I add new files to my local Swift packages, the "Update Package" option is no longer available when I right-click on my local package.
In previous versions of Xcode, I used this feature to make Xcode recognize newly added files without any issues.
Now, with Xcode 16, the only way I've found to get Xcode to recognize new files is to remove and re-add the entire package, which is obviously not ideal.
I've tried cleaning the build folder and rebuilding the project, but it doesn't seem to help.
Is there a new workflow or method in Xcode 16 to refresh or update local Swift packages without needing to remove and re-add them every time?
Any suggestions or workarounds would be greatly appreciated!
What I’ve tried so far:
Cleaning and rebuilding the project
Looking for any options under "File > Packages" menu
Environment:
Xcode 16
Local Swift Package
Thanks in advance!
Hi,
I work on a iOS application which includes several local swift packages containing modularised code. Each of those local swift packages has a test target defined in their respective Package.swift, and when opening a local package folder standalone in Xcode, then the tests run without issues.
However I would like in the main app's test plan to add the local package test targets and have them all run together when the main app's default test plan is run. Xcode allows me to select local package test targets within the main app's test plan (also within Test portion of the main app's scheme), however attempting to build for testing throws a "Module '…' was not compiled for testing".
Any ideas on how to achieve this goal (run local package tests in conjunction with main app's tests) and avoid that error?
Thanks
Peter
We are using a workspace file and have noticed that when we run fastlane commands that utilize xcodebuild command line arguments to run the export localization command from commandline, and it seems that it uses the xcodeproj package.resolved instead of the workspace package.resolved. This is causing issues as the xcodeproj package resolved will not update at all so is on old version of dependencies that cause xcodebuild commands to fail.
Why is there multiple package.resolved files and why does the xcodeproj not stay updated with what is in the workspace resolved file? Why won't the xcodeproj resolved file update when I'm opening the xcodeproj file and selecting specific dependencies and telling it to update the package.
In SPM package test running on visionOS 2, when creating a UISwitch we get a crash / error:
Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException)
This issue only occurs on visionOS 2 in Xcode 16 with Swift Package Manager. It works fine when running on visionOS 1.2 in Xcode 16 with SPM, as well as on iOS 18 in Xcode 16 with SPM. Additionally, running the test on visionOS inside of a non-SPM package (Project test) is also fine.
What results you expected - The test should pass for UISwitch initialization on SPM for visionOS 2 on Xcode 16.
What results you actually saw - Test failure with error - Nil UISwitch visual element provided by <UISwitch: 0x102b15590; frame = (0 0; 0 0); layer = <CALayer: 0x6000004c1780>> (NSInternalInconsistencyException)
The version of Xcode you are using - Xcode 16
Feedback id - FB15254532
Hello!
Previously, using content from one Swift Package in the UI of another would cause preview failures. Now, with Xcode 16, this issue has been improved, and the preview feature is working, though occasional crashes still occur. I have submitted a report regarding this issue.
I’ve encountered some issues while developing a SwiftUI-based application, particularly when using Xcode’s SwiftUI preview feature, which frequently crashes.
My app supports both macOS and iOS. Due to the differences between the platforms, I’ve had to implement some pages using UIKit and reference a few UIKit-based open-source frameworks. For instance, I’m using the LazyPager library, which only supports iOS. During runtime, I ensure LazyPager is only compiled for iOS by using .product(name: "LazyPager", package: "LazyPager", condition: .when(platforms: [.iOS])), which works as expected.
However, when I use Xcode’s SwiftUI preview mode and select macOS as the target, UIKit-related code still gets compiled, leading to a crash, with the error message indicating an issue related to LazyPager's UIKit dependencies.
Since it’s not feasible to ask the maintainers of these open-source libraries to add #if canImport(UIKit) conditionals to their code, I would like to ask if there’s a better way to resolve this issue, ensuring that SwiftUI preview works properly on macOS.
If you have any suggestions or solutions, I would greatly appreciate your assistance. Thank you so much for your help!
import PackageDescription
let package = Package(
name: "ImportLibrary",
platforms: [
.iOS(.v16),
.macOS(.v13)
],
products: [
.library(
name: "ImportLibrary",
targets: ["ImportLibrary"]),
],
dependencies: [
.package(url: "https://github.com/gh123man/LazyPager", from: "1.1.0"),
],
targets: [
.target(
name: "ImportLibrary",
dependencies: [
"SwiftSoup",
"Kingfisher",
"WaterfallGrid",
.product(name: "LazyPager", package: "LazyPager", condition: .when(platforms: [.iOS])),
"QuickModule"
]
),
.testTarget(
name: "ImportLibraryTests",
dependencies: ["ImportLibrary"]),
]
)
Sincerely,
Best regards
We have a problem with undesirable rebuild with Debug configuration for watchOS target dependencies.
There is a iOS project with watch extension target. Both have some SPM package dependency.
Build Active Architecture Only for Debug is Yes for both app/extension targets.
When build app, watch target is building not only for active arch(arm64) but also i386/x86_64.
It can be fixed by adding Excluded Architectures = i386 x86_64 for watch target.
But it don't help to avoid rebuild SPM package dependency for this architectures.
I want to add SwiftUI to an existing package. Super simple to get started. It previews with Xcode 15.4, but gives an error on Xcode 16.0: JITError: Runtime linking failure
Anyone have an idea on what may be failing?
Full SwiftUI code:
import SwiftUI
struct Dashboard: View {
var body: some View {
Text("hello")
}
}
#Preview {
Dashboard()
}
We’ve been encountering build failures when switching Git branches in Xcode (15 & 16), where the project fails to build due to missing symbols. Typically, running an Xcode clean resolves the issue, but this is disruptive—especially on large projects where a full rebuild after cleaning can be time-consuming.
We’ve managed to reproduce this issue in a minimal setup:
Create a new Xcode project.
Include a local Swift Package in the project. The main project depends on the package.
Add a new Objective-C class to the package.
Use that new class in the main project.
Build (FAILS).
Clean the project.
Build (SUCCEEDS).
This issue tends to arise when switching Git branches that introduce new files, such as Objective-C files that don’t exist on the main branch. If a new file is introduced in a feature branch, switching between main and feature requires a clean before the project will build successfully again.
We plan to file a feedback report, but in the meantime, we’re wondering if anyone has found effective workarounds for this problem when switching branches.
The only reasonable work-around we have found is to create an umbrella header manually and include the new header. It would be nice to not have to resort to maintaining umbrella headers in packages but this is ok.
I have installed Sequoia and Xcode 16 and now I can't add packages to my (or any project). I just get a message saying the package can't be resolved. Basically I can't carry on developing.
SORT THIS OUT APPLE
Hello Apple community !
I'm facing an issue regarding xcstrings in a local package in my project.
It's an iOS application with a local package containing multiple targets.
The Localizable.xcstrings is located in the app target and contains keys for the app and targets of the local package (Views in the targets look for keys in the main bundle)
My issue is that auto detection/extraction seems to work only for keys used inside the app bundle. It doesn't look in the package. However, if I add a Localizable.xcstrings inside a package target, it gets populated.
Is this normal behaviour & is there any way to make extraction put the keys in the main bundle xcstrings instead ? I feel like it should be normal behaviour if no xcstrings is found in the package
My fallback would be to set all keys in manual extraction state but it's not ideal ;)
Thanks in advance for the great work
Eric
I’m facing an issue while compiling a project with a CustomSDK on Xcode 16.0 Beta 6. The following error is displayed during the build process:
Failed to build module 'CustomSDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)', while this compiler is 'Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)'). Please select a toolchain which matches the SDK.
Steps I have taken so far:
Set the BUILD_LIBRARY_FOR_DISTRIBUTION build setting to YES in the post_install script to ensure forward compatibility.
Cleaned the project and deleted Derived Data.
Verified that the latest SDK version was compiled using Swift 5 in Xcode 15.2, which should ensure compatibility with future versions.
Tried re-adding the SDK pod and rebuilt the project.
Despite these steps, the issue persists on Xcode 16 Beta 6. I suspect the problem could be related to a beta version of Xcode and compatibility issues, but I need guidance on how to ensure the SDK works with Xcode 16.
Is this a known issue with Swift versioning in the beta release? Are there any workarounds or specific changes I should apply to make the SDK work with Xcode 16 Beta 6?
Any help or suggestions would be appreciated!