We've recently increased our use of SPM in our iOS app's Xcode project. However, we've noticed that if the Xcode project is open when we switch to a different git branch using another tool (e.g. git on the command line or in a 3rd-party GUI), the Package.resolved file is modified unexpectedly.
We've received some conflicting advice about the purpose and appropriate treatment of the Package.resolved file. Some say to add it to .gitignore. On the other hand, the docs say:
…be sure to commit your project’s Package.resolved file to your Git repository. This ensures a reliable CI workflow that always uses the expected version of a package dependency.
For now, our workaround is to use Xcode to switch git branches, but this seems like an unusual limitation.
We're on Xcode 15.3/15.4.
There is discussion on the Swift Forums of potentially related problems: https://forums.swift.org/t/xcode-automatically-updating-package-resolved/41900
Xcode
RSS for tagBuild, test, and submit your app using Xcode, Apple's integrated development environment.
Post
Replies
Boosts
Views
Activity
Hi,
I am creating a custom NSSecureUnarchiveFromDataTransformer in order to handle attributes of entities of type NSDateComponents.
It all works and I did not see any warnings in the "Issue navigator" inside Xcode but with Xcode 15 I started seeing this warning:
/Users/.../CustomNSSecureUnarchiveFromDataTransformer/CoreData:1:1 no NSValueTransformer with class name 'CustomSecureUnarchiveFromDataTransformer' was found for attribute 'testDate' on entity 'Item'
My use case is very simple, I have this custom transformer:
@objc(CustomSecureUnarchiveFromDataTransformer)
final class CustomSecureUnarchiveFromDataTransformer: NSSecureUnarchiveFromDataTransformer {
override class var allowedTopLevelClasses: [AnyClass] {
return [NSDateComponents.self]
}
static let name = NSValueTransformerName(rawValue: String(describing: CustomSecureUnarchiveFromDataTransformer.self))
public static func register() {
let transformer = CustomSecureUnarchiveFromDataTransformer()
ValueTransformer.setValueTransformer(transformer, forName: name)
}
}
which is set to the Core data entity's "Transformer":
which leads to the warning in Xcode 15.
App works just fine and there are no problems during run time, but this warning is shown and I want to fix it.
Here is a simple test project https://github.com/VladimirAmiorkov/CustomNSSecureUnarchiveFromDataTransformer
Does anybody know how to re-pair a watch with Xcode if you’ve anciently unpaired it?
Thanks
Hello everyone,
I'm currently developing an application that involves network communication on an Apple Watch.
I'm using Apple's network framework for communication and for validation purpose I need to establish communication between an Apple Watch simulator and an external command-line tool (nc). To send the connection requests, I require the IP address of the Apple Watch simulator.
I've been unable to locate the IP address of the Apple Watch simulator after searching is settings everywhere. This IP address is required for setting up network requests and ensuring effective testing and integration of Apple's network framework.
Could someone please provide guidance on how to obtain the IP address of the Apple Watch simulator? Specifically, I need to know how to retrieve this IP address so that I can configure my external command-line application (nc) to send connection requests to the simulator.
Thank you for your assistance and insights!
Regards,
Harshal.
I created package.swift for my framework. And was work correctly in iOS. Now we need to support tvOS. I don't understood how can we do it. Because source code is different but networking layer is same.
When I create dynamic targets:
extension Target{
static func allTargets() -> [Target]{
return ([
Target.SDKTarget(),
] as [[Target]]).flatMap{$0}
}
static func SDKTarget() -> [Target] {
#if os(tvOS)
return [
.target(name: frameworkName,
dependencies: [
.product(name: "GRPC", package: "grpc-swift"),
],
path: "Sources/tvOS",
)
]
#else
and when I select tvOS build this code in preprocessor block still gray and won't compile.
How to make single package.swift for my framework for support tvOS and iOS with different code base and shared networking source code?
I got a new MacBook and set it up as a new one, not transferring any data from the old one.
But now the Apple Watch (Series 6) paired with my iPhone (14 Pro Max) ist not shown in Xcode.
iPhone and Watch are using the latest RC and also Xcode is the latest RC.
But in Xcode I ca only see my iPhone, not the paired Watch.
See Screenshots. The first shows the new MacBook and the second the old one.
I already tried a lot, but nothing helps:
Unpair Watch from Phone and then pair it again
Plug the iPhone to different USB ports
Restart Watch, iPhone and Mac
Delete the iPhone from Xcode
Enable and disable Developer Mode on iPhone and Watch
What else can I try to get the Watch back?
I am trying to install the command line tools for Xcode. When I open the installer, it says
Command line tools can't be installed on this disk.
macOS version 14 or later is required
However, About This Mac says that I am running Catalina 1015.7. If I try to install Xcode from the App Store I get the same message.
import AVFoundation
Button {
let utterance = AVSpeechUtterance(string: "Hello world")
utterance.voice = AVSpeechSynthesisVoice(language: "en-GB")
utterance.rate = 1
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)
} label: {
Text("hello")
}
i omitted some code but this is the core part. When i run this on apple watch se 2 simulator (watch os 10.5) nothing happens and gives the error
Query for com.apple.MobileAsset.VoiceServicesVocalizerVoice failed: 2
Unable to list voice folder
Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2
Unable to list voice folder
Query for com.apple.MobileAsset.VoiceServices.CustomVoice failed: 2
Unable to list voice folder
Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2
Unable to list voice folder
I've created a closed source iOS SDK from a local Swift package, which has dependencies on other Swift packages, and successfully created a binary XCFramework following the solution from my previous post.
Now I'm proceeding with the process to distribute this SDK. I believe I want to upload the XCFramework to a public repo alongside a Package.swift file and an Example app project that uses the XCFramework. So each time I go to create a new release I’ll create a new XCFramework replacing the current one, verify it's working properly in the example app, then commit, tag, and push to the repo.
My question is how do I set this up as a Swift package that includes an example app that uses the local XCFramework (not a remote url to a zip of the framework) and properly resolves dependencies?
So far I created a directory containing MyFramework.xcframework and Package.swift containing:
// 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: "MyFramework",
platforms: [
.iOS(.v14)
],
products: [
.library(
name: "MyFramework",
targets: ["MyFramework"]
)
],
dependencies: [
.package(url: "https://github.com/example/example.git", from: "1.0.0")
],
targets: [
.binaryTarget(
name: "MyFramework",
path: "MyFramework.xcframework"
)
]
)
I then created an Example iOS app project in that directory and now need to integrate the local XCFramework. I wondered if I could do that via File > Add Package Dependencies > Add Local, but when I navigate to that Package.swift and click Add Package it says
The selected package cannot be a direct ancestor of the project.
Do I need a different Package.swift for the Example app, and if so, how do I get that set up? I created a separate Package.swift (contents below) alongside the xcodeproj but when I try to add that in Xcode I get the same error, despite the fact this package is a sibling of the project not an ancestor.
// 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: "MyFramework-Example",
platforms: [
.iOS(.v14)
],
dependencies: [
.package(name: "MyFramework", path: "../")
],
targets: [
.target(
name: "MyFramework-Example",
dependencies: ["MyFramework"]
)
]
)
I've created a closed source iOS SDK from a local Swift package, which has dependencies on other Swift packages, and successfully created a binary XCFramework following the solution from my previous post. I would now like to create a Package.swift to vend this XCFramework and test it in an example app to verify it works as expected before I upload it to a public repo for distribution.
I understand that binaryTarget does not support dependencies so we need to use a wrapper. I created a directory containing the following:
Package.swift
MyFramework.xcframework/
MyFrameworkWrapper/
├─ dummy.swift
Package.swift contains:
// 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: "MyFramework",
platforms: [
.iOS(.v14)
],
products: [
.library(
name: "MyFramework",
targets: ["MyFramework", "MyFrameworkWrapper"]
)
],
dependencies: [
.package(url: "https://github.com/gordontucker/FittedSheets.git", from: "2.6.1")
],
targets: [
.target(
name: "MyFrameworkWrapper",
dependencies: [
"FittedSheets"
],
path: "MyFrameworkWrapper"
),
.binaryTarget(
name: "MyFramework",
path: "MyFramework.xcframework"
)
]
)
I created a new iOS app, selected the project, Package Dependencies > + > Add Local, and added the directory containing this Package.swift. Xcode resolves the dependencies and lists them in the sidebar. I added code to import and use the framework. It builds successfully but the app crashes when run:
dyld[63959]: Library not loaded: @rpath/FittedSheets.framework/FittedSheets
Referenced from: <7DE247FC-DAFF-3946-AD21-E80F5AF841C9> /Users/Jordan/Library/Developer/Xcode/DerivedData/MyFramework-Example-gaeeymnqzenzrbbmhuebpodqctsz/Build/Products/Debug-iphonesimulator/MyFramework.framework/MyFramework
How do I get this working? I'm wondering is my package set up properly to vend the framework specifying its dependencies, and is my XCFramework created correctly?
The Package.swift for the framework's source code contains:
// 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: "MyFramework",
platforms: [
.iOS(.v14)
],
products: [
.library(
name: "MyFramework",
type: .dynamic,
targets: ["MyFramework"]
)
],
dependencies: [
.package(url: "https://github.com/gordontucker/FittedSheets.git", from: "2.6.1")
],
targets: [
.target(
name: "MyFramework",
dependencies: [
"FittedSheets"
],
path: "Sources"
)
]
)
And I created the XCFramework following the steps in that previous thread:
Create archive from package via xcodebuild archive -workspace "$PACKAGE_PATH" -scheme "$FRAMEWORK_NAME" -destination 'generic/platform=iOS' -archivePath "$ARCHIVE_PATH/iOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES ENABLE_USER_SCRIPT_SANDBOXING=NO ENABLE_MODULE_VERIFIER=NO OTHER_SWIFT_FLAGS=-no-verify-emitted-module-interface
Create the Modules directory in the framework via mkdir -p "$ARCHIVE_PATH/iOS.xcarchive/Products/usr/local/lib/$FRAMEWORK_NAME.framework/Modules"
Copy the Swift interface files into the framework from the build in DerivedData via cp -a "$BUILD_PRODUCTS_PATH/Build/Intermediates.noindex/ArchiveIntermediates/$FRAMEWORK_NAME/BuildProductsPath/Release-iphoneos/$FRAMEWORK_NAME.swiftmodule" "$ARCHIVE_PATH/iOS.xcarchive/Products/usr/local/lib/$FRAMEWORK_NAME.framework/Modules"
Repeat 1-3 for iOS Simulator
Create an XCFramework via xcodebuild -create-xcframework -framework "$ARCHIVE_PATH/iOS.xcarchive/Products/usr/local/lib/$FRAMEWORK_NAME.framework" -framework "$ARCHIVE_PATH/iOS_Simulator.xcarchive/Products/usr/local/lib/$FRAMEWORK_NAME.framework" -output "$ARCHIVE_PATH/$FRAMEWORK_NAME.xcframework"
Prior Xcodes had a very useful function called "sort & unique" that was found under "services" in the contextual menu in the source editor. The new Xcode 16 betas seems to have had this removed, or perhaps it's been moved to a new menu. Does anyone know about this?
Thanks!
Hi
I installed Xcode. I found to anchor plane option which seen in Reality Composer. but in pro version, can't found. where are the options?
thanks
The 2024 WWDC video 'Meet FinanceKit' has a code example to get the latest 7 AccountBalance entries for a given account:
// Get latest 7 available balances for account
func getBalances(account: Account) async throws -> [AccountBalance] {
let sortDescriptor = SortDescriptor(\AccountBalance.asOfDate, order: .reverse)
let predicate = #Predicate<AccountBalance> { balance in
balance.available != nil &&
balance.accountId == account.id
}
let query = AccountBalanceQuery(
sortDescriptors: [sortDescriptor],
predicate: predicate,
limit: 7
)
return try await store.accountBalances(query: query).reversed()
}
This code does not compile, because the AccountBalance struct has no field named asOfDate - you need to inspect the currentBalance enum, switch over the enum type value, and then extract asOfDate from the associated value.
All of this can't be done in a KeyPath (as far as I know 🤷♂️), which I think means it's impossible to get recent balances, without specifying a date, or getting all balances, and then sorting them in memory.
Am I missing something? I'd love to be proven wrong :)
FB14076698
After updating Xcode to beta 2 the predictive code completion disappeared.
Does anyone know if it is possible to re-enable it somehow?
MacOS Version: 15.0 Beta 2 (24A5279h)
Xcode Version: 16.0 beta 2 (16A5171r)
Hi,
I'm using macOS 15 beta 2 on an external SSD with Xcode 16 Beta 2. The Predictive Code Completion model option is grayed out under Xcode Settings > Text Editing > Editing. The information button shows a message saying this feature is not supported in my region.
I am located in the USA and using a 16GB RAM iMac M1 from the Apple Store. Is the Predictive Code Completion feature unavailable to free developer accounts? If not, any ideas on why I can't download the model?
Thanks!
I want to create a Project Template with an icon that matches the default Xcode templates. I created a vector example icon and saved it as TemplateIcon.svg and it gets displayed for my .xcodetemplate. I would like it to blend in with Apple's default icons (which I know are assets contained inside Xcode bundles).
I have tried with fill="currentColor" in my svg xml but it doesn't work. I couldn't find any technical documentation about this. It would be great to know how to design an icon that gets dynamically tinted by Xcode like the default ones.
Thanks 🙂
I have created an archive for both iOS and MacOS versions of my app by doing the the following steps
Destinations select Build Any Mac (Mac Catalyst, arm64, x86_64)
Product > Archive
However when doing the same steps for VisionOS I get an error
Invalid Run Destination
I have selected both destinations, visionOS Simulator and Build any VisionOS simulator device (arm64, x86_64)
I am able to run the app and test, now I would like to upload to AppStoreConnect for TestFlight and App Store submission.
dyld[766]: Library not loaded: @rpath/lib/libswiftCoreGraphics.dylib
Referenced from: /private/var/containers/Bundle/Application/94ECCB38-EB17-4A37-8D38-5D50018D135C/Coloring Book.app/Coloring Book
Reason: tried: '/usr/lib/system/introspection/libswiftCoreGraphics.dylib' (no such file, not in dyld cache), '/usr/lib/swift/lib/libswiftCoreGraphics.dylib' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/lib/libswiftCoreGraphics.dylib' (no such file), '/private/var/containers/Bundle/Application/94ECCB38-EB17-4A37-8D38-5D50018D135C/Coloring Book.app/Frameworks/lib/libswiftCoreGraphics.dylib' (no such file), '/private/var/containers/Bundle/Application/94ECCB38-EB17-4A37-8D38-5D50018D135C/Coloring Book.app/Frameworks/lib/libswiftCoreGraphics.dylib' (no such file), '/usr/lib/swift/lib/libswiftCoreGraphics.dylib' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/lib/libswiftCoreGraphics.dylib' (no such file), '/private/var/containers/Bundle/Application/94ECCB38-EB17-4A37-8D38-5D50018D135C/Coloring Book.app/Frameworks/lib/libswiftCoreGraphics.dylib' (no such file), '/private/var/containers/Bundle/Application/94ECCB38-EB17-4A37-8D38-5D50018D135C/Coloring Book.app/Frameworks/lib/libswiftCoreGraphics.dylib' (no such file)
I had Xcode 16 Beta 1 installed and working.
Installed Xcode 16 beta 2 (16A5171r) and now it is unable to download the simulator for that version.
Downloading iOS 18.0 Simulator (22A5297f): Preparing to download...2024-06-25 14:21:27.456 xcodebuild[88553:5158819] DVTDownloadable: Download Failed. Downloadable: { authentication = none; category = simulator; contentType = cryptexDiskImage; dictionaryVersion = 2; downloadMethod = mobileAsset; fileSize = 8254433558; identifier = "com.apple.dmg.iPhoneSimulatorSDK18_0_b2"; isInternalContent = 0; isUserInitiated = 1; name = "iOS 18.0 Simulator (22A5297f)"; platform = "com.apple.platform.iphoneos"; simulatorVersion = { buildUpdate = 22A5297f; version = "18.0"; }; version = "18.0.0.2"; }. Download failed. Downloading iOS 18.0 Simulator (22A5297f): Error: Error Domain=DVTDownloadableErrorDomain Code=41 "Download failed." UserInfo={NSLocalizedDescription=Download failed., NSUnderlyingError=0x600001f075c0 {Error Domain=DVTDownloadsUtilitiesErrorDomain Code=-1 "Failed fetching catalog for assetType (com.apple.MobileAsset.iOSSimulatorRuntime), serverParameters ({ RequestedBuild = 22A5297f; })" UserInfo={NSLocalizedDescription=Failed fetching catalog for assetType (com.apple.MobileAsset.iOSSimulatorRuntime), serverParameters ({ RequestedBuild = 22A5297f; }), NSUnderlyingError=0x6000031fe3a0 {Error Domain=com.apple.MobileAssetError.Download Code=18 "Download from live asset server could not get an asset matching the requested one. (Catalog download for com.apple.MobileAsset.iOSSimulatorRuntime)" UserInfo={tryAgainLater=true, NSLocalizedDescription=Download from live asset server could not get an asset matching the requested one. (Catalog download for com.apple.MobileAsset.iOSSimulatorRuntime), pallasNoPMVMatchFound=true}}}}}
My first App cannot verified & run on my phone even when I use the same wifi net work and switch on developer mode on the phone.
Also I press verify button without any respond
Always give me unable to verify App notification