My organization delivers an xcframework, let's call it MyFramework.xcframework. This framework also depends on another local framework, SecondFramework.xcframework.
We want to deliver the MyFramework using Swift Package Manager to our customers. The SecondFramework is embedded within MyFramework. Then the customer only needs to care about MyFramework.
Our issue is that apps using our Swift Package fail to recognize the SecondFramework, displaying the message "SecondFramework module not found."
Is this not possible or currently supported in SPM? Or do we need to change our approach?
I appreciate any help or pointers.
Thanks!
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'm trying to access Persona avatar and set camera access permission and allowed manually from Settings > Privacy > Persona Virtual camera > MY_APP => allowed
I would like to access Persona image into image view.
Looking forward for solution
Thanks in advance
Whenever I switch branches, Xcode seems to update the originHash field in Package.resolved. I then have to tell Xcode to manually resolve packages again.
That sounds like a bug, and I can just file a bug about that.
But what I want to know is… why is the originHash changing in the first place? What does that represent? Should I be committing the value that it's trying to change to? Or should I be discarding that change?
Xcode NSMetaDataQuery error on device running IOS 17.5 - [ERROR] couldn't fetch remote operation IDs
Xcode 15.4 running on various IOS simulators and hardware devices from IOS 14.5 to 17.5.
Part of my code presents a backup/restore page to the user which uses NSMetaDataQuery to update the GUI for files being uploaded or downloaded in iCloud. On every device I run the code everything works as expected EXCEPT one which is an iPhone 11 running IOS 17.5 (as of yesterday 17.5.1); there I get the following error once I start the query:
[ERROR] couldn't fetch remote operation IDs: NSError: Cocoa 257 "The file couldn’t be opened because you don’t have permission to view it." "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
Due to this error I am getting no query updates and thus unable to display whether the file needs to upload, download or is synchronised.
I am not initiating any upload or download of the backup file since it is placed in the ubiquitous container and I leave the up/download of the file over to IOS; all I do with the query is monitor the status of the file and take appropriate action to show the user the percentage of up/downloaded file.
As said before it is only the one device causing me headaches so I don't know whether it has anything to do with IOS 17.5 that Apple have made changes that I am unaware of. I have access to an iPhone and an iPad running some version of IOS 16 and it's performing flawlessly. I have no other IOS17+ device to test on.
The code runs very well on any 17.5 simulator, but we all know there are always some differences running code on a Device vs Simulator.
Running 'startAccessingSecurityScopedResource()' which has been suggested by some returns 'true' on the simulator and 'false' on a device, but even then all devices work except one; so that does not seem to be the solution. Changing the query predicate has not helped either.
How do I drill down to find the culprit - I'm at my wits' end.
My very simple query initializer, startup & observers:
(Please note, the code shown here is what's left after commenting out everything else. This was done to show that the problem really DOES lie with the Query)
query = NSMetadataQuery.init()
query.operationQueue = .main
query.searchScopes = [NSMetadataQueryUbiquitousDocumentsScope]
query.predicate = NSPredicate(format: "%K LIKE %@", NSMetadataItemFSNameKey, fileUrl.lastPathComponent)
query.operationQueue?.addOperation({ [weak self] in
self?.query.start()
self?.query.enableUpdates()
})
}
func addNotificationObservers() {
NotificationCenter.default.addObserver(
self,
selector: #selector(queryDidStart(_:)),
name: .NSMetadataQueryDidStartGathering,
object: query)
NotificationCenter.default.addObserver(
self,
selector: #selector(queryGathering(_:)),
name: .NSMetadataQueryGatheringProgress,
object: query)
NotificationCenter.default.addObserver(
self,
selector: #selector(queryDidUpdate(_:)),
name: .NSMetadataQueryDidUpdate,
object: query)
NotificationCenter.default.addObserver(
self,
selector: #selector(queryDidFinishGathering(_:)),
name: .NSMetadataQueryDidFinishGathering,
object: query)
}
I've created an app for visionOS that uses a custom package that includes RealityKitContent as well (as a sub-package). I now want to turn this app into a multi-platform app that also supports iOS.
When I try to compile the app for this platform, I get this error message:
Building for 'iphoneos', but realitytool only supports [xros, xrsimulator]
Thus, I want to exclude the RealityKitContent from my package for iOS, but I don't really know how. The Apple docs are pretty complicated, and ChatGPT did only give me solutions that did not work at all.
I also tried to post this on the Swift forum, but no-one could help me there either - so I am trying my luck here.
Here is my Package.swift file:
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "Overlays",
platforms: [
.iOS(.v17), .visionOS(.v1)
],
products: [
.library(
name: "Overlays",
targets: ["Overlays"]),
],
dependencies: [
.package(
path: "../BackendServices"
),
.package(
path: "../MeteorDDP"
),
.package(
path: "Packages/OverlaysRealityKitContent"
),
],
targets: [
.target(
name: "Overlays",
dependencies: ["BackendServices", "MeteorDDP", "OverlaysRealityKitContent"]
),
.testTarget(
name: "OverlaysTests",
dependencies: ["Overlays"]),
]
)
Based on a recommendation in the Swift forum, I also tried this:
dependencies: [
...
.package(
name: "OverlaysRealityKitContent",
path: "Packages/OverlaysRealityKitContent"
),
],
targets: [
.target(
name: "Overlays",
dependencies: [
"BackendServices", "MeteorDDP",
.product(name: "OverlaysRealityKitContent", package: "OverlaysRealityKitContent", condition: .when(platforms: [.visionOS]))
]
),
...
]
but this won't work either.
The problem seems to be that the package is listed under dependencies, which makes the realitytool kick in. Is there a way to avoid this? I definitely need the RealityKitContent package being part of the Overlay package, since the latter depends on the content (on visionOS). And I would not want to split the package up in two parts (one for iOS and one for visionOS), if possible.
I don't even use Swift. I use Flutter. I am getting this odd always_embed_swift library warning that seems to be overriding my runner target on xcode. I'll just attach the image down below of what I'm dealing with. Please an apple engineer or someone just help me because this has been a struggle lol. I need to change this but can't find the setting to do so.
I've defined a value stored in UserDefaults.
In a view struct I have code that can successfully update the stored value.
I've also added an @AppStorage var in an instance of a class, that can read this value and run business logic that depends on the current stored value.
But what I really want to do, is have code in my class that gets automatically called when the value stored in UserDefaults gets updated.
Basically I want to do this:
@AppStorage("languageChoice") var languageChoice: LanguageChoice = .all {
didSet {
print("hello")
}
}
Unfortunately didSet closures in @AppStorage vars do not appear to get called :-(
My clumsy attempts to use combine have all ended in tears from the compiler.
Any/all suggestions are greatly appreciated.
thanks,
Mike
My config is as follow
MacBook Pro with M3 Pro and Sonoma 14.5 OS
XCode 15.2
Build version 15C500b
swift-driver version: 1.87.3
Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
Darwin lonwx2049951 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:13:18 PDT 2024;
root:xnu-10063.121.3~5/RELEASE_ARM64_T6030 arm64
I am behind corp proxy and have quite limited privileges to install or use any tools/commands requiring admin privileges.
The App itself plus a few company submodules are hosted on Azure Devops and this side works as usual.
The App also uses a few dependencies hosted on GitHub and that need to be resolve every time I'm switching/creating new branches
Until Monday I was using following terminal command to do so
xcodebuild -resolvePackageDependencies -scmProvider system
However, on Monday when I tried the above I was presented with error on each of the dependencies, see attached depenedencies_error.txt
The only change that happen was the Mac OS update on Monday morning when I turn on my Mac from 14.4 to 14.5
Is it possible that this update removed some of the settings?
I have tried the following:
deleting DerivedData folder, cleaning and rebuilding project
cloning the dependencies manually
adding PAT token
using SSH for fetching
deleting Package.resolved file
cloning project from Azure repo into different location
Any suggestions will be appreciated.
Hello,
I'm having this issue that Xcode tells me it cannot find the Swift Packages I'm using within my App. When I first open Xcode, all the Package Dependencies are listed correctly in my project navigator. Also, building the app for the first time runs without any issues.
But right after the first build is finished, the Package Dependencies are not listed any more and the build fails, telling me that all the packages are missing.
I have to manually click on File -> Packages -> Reset Package Caches, after that it works again. But only for exactly one build. I basically have to do this step for every single build.
I found out that there is this Package.resolved file which lists all the used packages with their respective version and some kind of hash. This file is located inside the .xcodeproj file, in my case it's this location:
MyApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file is deleted after the successful build. And I think that's the reason why all of a sudden Xcode screams that the packages are missing. After resetting the package caches this file re-appears. But it seems it has to be regenerated every single time.
This bug is VERY annoying and exists already since the last view versions of Xcode, not just the latest one. I was hoping this bug is fixed at some point.
Current Xcode version: 15.4 (15F31d)
MacBook Air 13", M3, 2024 running macOS Sonoma 14.5
Just in case, my Package.resolved file is attached below.
Package.resolved
#Preview, @available(iOS 17, *), PreviewProvider
Preview is not working.
I've tried this and that, but I can't.
Please help me.
Hi,
I am using macOS Sonoma 14.5 and the latest version of Xcode (15.4). Every time I open Xcode, it asks me to install additional components. I accept, but when it finishes, the same dialog appears again. I've done this multiple times. I also uninstalled and reinstalled Xcode, but no luck.
Can you please help me?
I’m on an M2 Mini, latest XCode etc. trying to update a package from previous, and I can’t update or repair packages because all options are greyed out.
how do I turn them on again?
Starting on Xcode 15.3 and 15.4 my SwiftUI Previews stopped working with the following error:
== PREVIEW UPDATE ERROR:
LinkDylibError: Failed to build ContentView.swift
Linking failed: linker command failed with exit code 1 (use -v to see invocation)
ld: warning: search path '/Applications/Xcode.app/Contents/SharedFrameworks-iphonesimulator' not found
Undefined symbols for architecture arm64:
"static MyLibrary.DisplayUtil.getText() -> Swift.String", referenced from:
closure #1 () -> SwiftUI.Text in (extension in Demo_Broken_Preview_PreviewReplacement_ContentView_1):Demo_Broken_Preview.ContentView.(__preview__body in _1BA320C8FB5388C953E1E463345C3D72).getter : some in ContentView.1.preview-thunk.o
"type metadata accessor for MyLibrary.DisplayUtil", referenced from:
closure #1 () -> SwiftUI.Text in (extension in Demo_Broken_Preview_PreviewReplacement_ContentView_1):Demo_Broken_Preview.ContentView.(__preview__body in _1BA320C8FB5388C953E1E463345C3D72).getter : some in ContentView.1.preview-thunk.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After much trial and error, I narrowed it down to my SwiftUI views using properties or functions inside components in Swift Packages.
This is a simple example of my Swift Package:
public class DisplayUtil {
public func getText() -> String {
return "Text"
}
public static func getText() -> String {
return "Text"
}
}
And my SwiftUI View
import SwiftUI
import MyLibrary
struct ContentView: View {
var body: some View {
VStack {
Text(DisplayUtil.getText())
}
.padding()
}
}
#Preview {
ContentView()
}
The same code works fine on Xcode 15.2
Link to the sample project:
https://www.icloud.com/iclouddrive/0c00AD0esi2PwqqiRggokfwGw#Demo%5FBroken%5FPreview
Is anybody else having a similar issue?
Hi There,
I have a strange problem: the Swift package cannot be added to my iOS project. The problem might be due to the project settings, but despite trying for a long time, I still haven't been able to figure it out.
My project is a React Native project and uses CocoaPods.
When I drop the Swift package into my React Native project, the package becomes a folder.
When I drop the Swift package into other iOS projects, it works without any problems.
If I try to use "Package Dependencies" to add the Swift package, it gets stuck on "Preparing to validate..."
My project seems unable to add any Swift packages; it cannot add other Swift packages either.
The Swift package is local. However, it works fine in other projects, even in newly created React Native projects.
The problem might be with my project itself, but I have no idea where to check now. please guide me with any advice, I will appreciate it!
Problem Statement:
Unable to import .h file from an ObjC SPM to a .h file in an ObjC file in a framework with mix of ObjC and Swift code
The issue is: in order to support access of ObjC file in Swift code in a framework we need to use umbrella header (in place of bridging header). Once the file is imported in Umbrella header and made public it will no longer allow import of .h file from package in its interface
Project Structure:
a. Package: ObjCPackage
ObjCPackage
|- Package.swift
|- ObjCPackage
MathsUtilities.h (class interface)
MathsUtilities.m (class implementation)
NiceLogs.h (protocol)
b. Project: ObjCSwiftFramework
ObjCSwiftFramework
|- ObjCSwiftFramework.h (umbrella header)
|- Calculation.h (objc class interface)
|- Calculation.m (objc class implementation)
|- SwiftCalci.swift (swift class)
Details:
#import <ObjCSwiftFramework/Calculation.h> added in ObjCSwiftFramework.h as Calculation has to be used in SwiftCalci
Calculation.h marked as public in target membership in Xcode so that it can be added in umbrella header ObjCSwiftFramework.h
#import "NiceLogs.h" in Calculation.h gives error
Here is a small sample which I created to demonstrate the problem:
ObjCSwiftFramework
I am trying to develop website that can upload instagram story from web.
I opened the Instagram app and even opened the story upload pop-up.
but, I can't send Image Data.
I need your Help....
source_application is detected at instagram,
but backgroundImage is not sent at instagram.
How can I send.......
because
Hello. My game, which I have been preparing for a long time on Unity, has been completed. But I have a big problem. My game is a game focused on constantly drawing lines. For this reason, I need to draw lines in the safe area at the bottom of the iPhone. However, due to the shortcuts on the iPhone, my game is constantly put in the background or switched to another application. Since there are so many levels in my game, it is almost impossible to redesign the levels and since I am a game with lines drawn, I will always have this problem again. What I want is to cancel the shortcut to switch to another application and put it in the background when I swipe from left to right or right to left when my game opens. When my game opens, the priority is on the lines in my game. I also marked the defer system gestures on edges section on Unity for postponement, but it did not help. Also, postponing it will not solve the problem. For example, they disabled these shortcuts in the (mini metro) game and you can never use these shortcuts in the game. I did a lot of research on forum sites and chatgpt and tried different codes, but I couldn't find a solution. Can you help me with this? When my game is opened, I want to prevent and cancel the transition to another application by drawing a line left and right in the safe area section at the bottom and the game from being placed in the background. I would be very happy if you could help me with a hint or a code on what to do.
It gives me error for "import SplineRuntime". It says no such module even if I add the packagies dependencies from github. I tried to rebuild and clean everything but it still gives me this error.
On versions iOS 14+, my app which is connected by bluetooth to another device will become slow to write information. This isn't a couple hundred ms or a second or two, but upwards of 10 minutes for it to be sent and then 400 ms to be processed by the device and send its response back. I've confirmed with PacketLogger and with system logs that what commands we are sending with .writeValue are taking over 10 minutes.
This is the timestamp of when we are writing to the device
This is the PacketLogger timestamp of when the phone actually wrote to our device
This doesn't occur immediately, but is intermittent and once it does begin to occur, there's nothing to do to get out of it except for connecting once again to the device. Which, overtime, the issue begins to spring up again. So why is it taking 13 minutes for it to go through the phone and finally being sent?
I just purchased a new M3 chip MacBook Air a little after it came out. I was able to create and deploy an iOS application. However, now that I am trying to create a new project Xcode throws an error upon launch.
Steps to recreate the error (if possible)
Open Xcode
Select create new app
An error is where the preview should be.
At this point I have added no code. It is all boiler plate from Apple.