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

Geometry recognition and measurement from MeshAnchor
FYI. The source code of the FindSurface demo app for Apple Vision Pro (visionOS) is available now. The Swift package of FindSurface™ library is required to build the source code into the demo app. https://github.com/CurvSurf/FindSurface-visionOS After starting the app, the floating panels (below) will appear on your right side, and you will see wireframe meshes that approximately describe your environments. Performing a spatial tap (pinching with your thumb and index finger) with staring at a location on the meshes will invoke FindSurface, with an indicator (blue disk) appearing on the surface you've gazed. Voice commands: “Tap” – Spatial tap (gazing & pinching). Invoke FindSurface. “Tap plane” – Plane selection. “Tap sphere” or “Tap ball” – Sphere selection. “Tap cylinder” – Cylinder selection. “Tap cone” – Cone selection. “Tap torus” or “Tap donut” – Torus selection. “Tap accuracy” or “Tap measurement accuracy” – Accuracy selection. “Tap mean distance”, “Tap average distance”, or “Tap distance” – Avg. Distance selection. “Tap touch radius” or “Tap seed radius” – Touch Radius selection. “Tap Inlier” – “Show inlier points” toggle. “Tap outline” – “Show geometry outline” toggle. “Tap clear” – “Clear Scene” click.
2
0
133
13h
Swift Syntax Comment Trivia - Expected prefixes
Hello! I am working on a project that does some automatic code generation using SwiftSyntax and SwiftSyntaxBuilder. As part of this project, I want to put in a comment at the top of the file warning users to not modify the file and make it obvious that the code was automatically generated. I was trying to use the .lineComment(String) static member of the Trivia (or TriviaPiece) types and I expected that the comment would automatically be prefixed with the expected // and space for use in code. (For example, Trivia.lineComment("No comment") would be written as // No Comment when sent through a BasicFormat Object or similar SyntaxRewriter). I was surprised to find that this is not the case and was wondering before I write an issue on GitHub whether this behavior is intentional or a bug. If it is intentional, I'm not entirely sure if I'm missing something regarding this to more easily generate these comments. At the moment my comment generation consists of constructing the comment in the leadingTrivia of the syntax node that appears after the comment. For example: VariableDeclSyntax(leadingTrivia: [.newlines(2), .lineComment("// These members are always generated irrespective of the contents of the generated files. They are intended to exclusively centralize code symbols that would otherwise be repeated frequently."), .newlines(1)], modifiers: [DeclModifierSyntax(name: .keyword(.private)), DeclModifierSyntax(name: .keyword(.static))], .let, name: PatternSyntax(IdentifierPatternSyntax(identifier: "decoder")), initializer: InitializerClauseSyntax(value: ExprSyntax(stringLiteral: "\(configuration.decoderExpression)"))) outputs // These members are always generated irrespective of the contents of the generated files. They are intended to exclusively centralize code symbols that would otherwise be repeated frequently. private static let decoder = JSONDecoder() in this project (with example data having been added).
0
0
108
4d
Swift Package with Demo project with Xcode 16
My current workflow to have a Swift Package with a Demo is like this: PackageFolder > DemoFolder I have a package, with a Demo folder inside. I can open the Demo project and Drag&Drop the local PackageFolder to override the remote dependency with the local one. This allows to edit the package while inside the demo project. With Xcode 16 this does no longer work because Xcode does not allow to drop an ancestor of the file path where the project is located. Xcode does not tell this while you drop, it just does not allow it. But it tells you thats the reason, when you try to add the local package as a dependency to the project: "The selected package cannot be a direct ancestor of the project.". (Dropping other local packages still works, see: https://forums.developer.apple.com/forums/thread/756824) What is the expected way to handle a package with a demo project with Xcode 16?
1
1
145
2d
Distributing Binary via Cocoapods & Swift Packages
I maintain a library that has thus far used Cocoapods to manage dependencies and also distribute an xcframework of the library. I'd now like to also distribute the same library through Swift Packages but am running into issues. I'm using the same xcframework in a local Swift Package and have added all the necessary dependencies to Package.swift, but when I attempt to add this Swift Package to a test app, the app will build correctly but fail at runtime due to a missing .framework file for a dependency I'll just call THE_DEPENDENCY: dyld[61483]: Library not loaded: @rpath/THE_DEPENDENCY.framework/THE_DEPENDENCY Referenced from: <75074516-C1CD-3251-8807-94A7502176A7> /Users/ME/Library/Developer/Xcode/DerivedData/MY_TEST_APP-bwfsfwjjnagdurdnjrhhdppgitvr/Build/Products/Debug-appletvsimulator/MY_LIBRARY.framework/MY_LIBRARY Reason: tried: '/Users/ME/Library/Developer/Xcode/DerivedData/MY_TEST_APP-bwfsfwjjnagdurdnjrhhdppgitvr/Build/Products/Debug-appletvsimulator/THE_DEPENDENCY.framework/THE_DEPENDENCY' (no such file) Indeed, there is no THE_DEPENDENCY.framework file anywhere, it is only present in a version of the test app that uses Cocoapods. As you can see, the reference to this file arises from MY_LIBRARY, and in MY_LIBRARY.xcodeproj I can see there is a reference to THE_DEPENDENCY.framework, which appears as a consequence of running pod install. Thus, it looks to me like the .framework file appears either as part of Cocoapods dependency injection, or perhaps as a consequence of how that dependency is distributed through Cocoapods. I'm forced to install pods during my build process because, as I understand it, all dependencies must be available during the archiving process to avoid compilation errors. If the dependencies must be available during archiving, but adding the dependencies via Cocoapods creates a reference to .framework files that will not be present in a Swift Package project, what is the best practice for distributing xcframework binaries to both Cocoapods and Swift Package Manager? It looks as though I'll have to build two different xcframeworks: one built with dependencies provided via pods, and the other via swift packages. Is this correct?
0
0
67
5d
XcodeCloud fails while Resolving Dependencies
After trying to build with macOS 15 and XCode 16 (beta and beta2), XcodeCloud started to crash at the Resolve package dependencies step. Everything works perfect on my local system running same OS same XC. Details: [<IDESwiftPackageCore.IDESwiftPackageDependencyPlaceholderFileReference, 0x7fb23a2082a0: name:swift path:(No Path)>] Function: unregisterDependencyFileReferences(_:) Thread: <_NSMainThread: 0x600002094200>{number = 1, name = main} Hints: Backtrace: 0 -[DVTAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation) 1 _DVTAssertionHandler (in DVTFoundation) 2 _DVTAssertFromSwift (in DVTFoundation) 3 _DVTAssert(_:file:line:function:varargs:) (in DVTFoundation) 4 DVTAssert(_:_:file:line:function:) (in DVTFoundation) 5 closure #1 in closure #1 in IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 6 closure #1 in IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 7 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 8 thunk for @callee_guaranteed () -> () (in DVTFoundation) 9 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 10 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 11 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 12 IDESPMWorkspaceDelegate.unregisterDependencyFileReferences(_:) (in IDESwiftPackageCore) 13 closure #1 in closure #1 in IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 14 closure #1 in IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 15 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 16 thunk for @callee_guaranteed () -> () (in DVTFoundation) 17 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 18 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 19 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 20 IDESPMWorkspaceDelegate.registerDependencyFileReferences(_:) (in IDESwiftPackageCore) 21 closure #1 in IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(packages:graphHasErrors:) (in IDESwiftPackageCore) 22 closure #1 in OS_dispatch_queue.dvt_sync<A>(execute:) (in DVTFoundation) 23 thunk for @callee_guaranteed () -> () (in DVTFoundation) 24 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation) 25 __58-[DVTModelObjectGraph performBlockCoalescingModelChanges:]_block_invoke (in DVTFoundation) 26 -[DVTModelGraphTransactionScope performTransaction:] (in DVTFoundation) 27 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation) 28 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation) 29 IDESPMWorkspaceDelegate.dependencyPackagesDidUpdate(packages:graphHasErrors:) (in IDESwiftPackageCore) 30 SPMWorkspace.packageGraphActionFinished(_:) (in SwiftPM) 31 closure #3 in SPMWorkspace.processPackageGraphActionsInBackgroundIfNeeded() (in SwiftPM) 32 swift::runJobInEstablishedExecutorContext(swift::Job*) (in libswift_Concurrency.dylib) 33 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) (in libswift_Concurrency.dylib) 34 _dispatch_main_queue_drain (in libdispatch.dylib) 35 _dispatch_main_queue_callback_4CF (in libdispatch.dylib) 36 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation) 37 __CFRunLoopRun (in CoreFoundation) 38 CFRunLoopRunSpecific (in CoreFoundation) 39 +[DVTKVOConditionValidator waitForCondition:sourceObject:keyPathAffectingConditionBlock:timeout:] (in DVTFoundation) 40 -[Xcode3CommandLineBuildTool waitForRemoteSourcePackagesToFinishLoading] (in Xcode3Core) 41 -[Xcode3CommandLineBuildTool _resolveInputOptionsWithTimingSection:] (in Xcode3Core) 42 -[Xcode3CommandLineBuildTool run] (in Xcode3Core) 43 XcodeBuildMain (in libxcodebuildLoader.dylib) 44 -[XcodebuildPreIDEHandler loadXcode3ProjectSupportAndRunXcode3CommandLineBuildToolWithArguments:] (in xcodebuild) 45 -[XcodebuildPreIDEHandler runWithArguments:] (in xcodebuild) 46 main (in xcodebuild) 47 start (in dyld) bash: line 1: 4274 Abort trap: 6 xcodebuild -resolvePackageDependencies -project /Volumes/workspace/repository/***.xcodeproj -scheme '***' -derivedDataPath /Volumes/workspace/DerivedData -hideShellScriptEnvironment Error Command exited with non-zero exit-code: 134
2
1
143
4d
Linker command failed due to Undefined Symbol errors.
Xcode will build and analyze fine using the Debug build configuration but trying to use Analyze or Archive with Release configuration generates 3 errors: Undefined symbol: protocol conformance descriptor, Undefined symbol: type metadata accessor, and Undefined symbol: nominal type descriptor causing the linker to command to fail. The library is included and already linked and a previous version did not have the error so I think it's a code issue but not quite sure what it is or how to fix! The project/package can be found here: https://github.com/kudit/Device/tree/v2.1.17 (to reproduce, checkout this version and rename appending ".swiftpm" to the folder, then right-click to show package contents, open the Development folder and open the Xcode project there. It's done this way so the package can be imported and edited on iPad Swift Playgrounds)
0
0
107
6d
Test Swift Package that vends XCFramework and has dependencies in example app before distribution
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"
0
0
98
6d
VISIONOS: how to detect if the user closes a window vs a window going into the background
For context, we have a fully immersive application running on visions. The application starts with a standard View/menu, and when the user clicks an option, it takes you to fully immersive mode with a small floating toolbar window that you can move and interact with as you move around the virtual space. When the user clicks the small x button below the window, we intercept the scenePhase .background event and handle exiting immersive mode and displaying the main menu. This all works fine. The problem happens if the user turns around and doesn't look at the floating window for a couple of minutes. The system decides that the window should go into the background, and the same scenePhase background event is called - causing the system to exit immersive mode without warning. There seems to be no way of preventing this, and no distinction between this and the user clicking the close button. Is there a reliable way to detect if the user intentionally clicks the close button vs the window from going into the background through lack of use? onDisappear doesn't trigger. thanks in advance
1
0
178
1w
Distribute XCFramework that has dependencies on Swift Packages with Example project
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"] ) ] )
1
0
119
6d
Switch between distributing code as source / as a binary
I'm getting confused reading conflicting information about Swift Packages (for example, many sources say its for distributing source code only, but Apple's documentation says a binary framework can be included in them). What I would like to be able to do is to distribute a project as a binary to external customers (so they cannot see the source code) but distribute it as source code for internal consumption (so when developing a test app that uses the project, source code can be stepped through in the debugger etc.) Is the feasible/easy? Could a package manifest be created that can easily be flipped between creating a package containing source only, and a binary only. Or would it be better to have two separate manifests?
1
0
100
1w
Options for switching between incorporating binary and/or source code within an app
Our company is going to develop an iOS library of functionality for inclusion in several apps, some of the apps will be developed in-house and some externally. When the library is included in external apps the source code shouldn't be visible. When the library is included in internal apps, having the option to view and step through the code within the library will be invaluable for debugging. How could I set things up so that two forms of the library can be easily generated - one exposing source code and the other not. Ideally they should be capable of being incorporated within the apps in the same manner regardless of if the source code is expose or not Is that possible? I looked at Swift Packages, but it seems its for distribution of source code only, and its not possible to hide the source code. However, conversely, a framework only contains binary and no source code. Is there any other option?
0
0
89
1w
Build XCFramework from source that has dependencies on Swift Packages
I’m looking into building a closed source XCFramework from a local Swift package that has dependencies on other packages, which can later be distributed via Swift Package Manager. In initial discussions, we thought xcodebuild does not support linking the dependencies externally, it always includes them statically in the built framework. It's my understanding this is because we're asking xcodebuild to build a framework from a local Swift Package. Is there another way this can be achieved? To explain in more detail: I have built a closed source SDK for other developers to integrate in their apps, currently distributed as an XCFramework. The interesting thing about the SDK is it has dependencies on other libraries, which need to be resolved when adding this SDK as a dependency to an app. The SDK’s dependencies should not be baked into our XCFramework. CocoaPods has worked well for that but we want to instead use SPM. The current project setup is an iOS framework Xcode project and an app Xcode workspace. The framework project is included in the app workspace and is in the same repo as the app, which allows me to modify the framework source code then run the app to test it. The framework project can also be opened independently and built to verify it doesn’t have any errors, but to verify it’s working I run it with the app. To distribute a new release I use xcodebuild to create an XCFramework and then deploy that. For this to work with CocoaPods I had to add a Podfile to the app directly as well as the framework directory so both have the dependencies available. This means I have an xcworkspace for the framework and not just a xcodeproj. I specify the framework workspace file in the xcodebuild command. To switch to a setup that utilizes Swift Package Manager, I created a Package.swift in the iOS framework project’s directory that specifies its dependencies, removed CocoaPods integration including deleting the workspace file, removed the framework project from the app’s workspace, added the Package as a local package to the app project, and added the framework directory via + > Add Files to “App” which adds the package to the top of the sidebar, making its source code available to edit within the app workspace. Everything is working when I run the app. Xcode properly resolves the dependencies for the local package and I can run the app to develop it. Now to create an XCFramework I run the following command in the framework directory (which contains the Package.swift): xcodebuild archive -workspace . -scheme FrameworkName -configuration Release -destination 'generic/platform=iOS' -archivePath './build/FrameworkName.framework-iphoneos.xcarchive' SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES ENABLE_USER_SCRIPT_SANDBOXING=NO This succeeds however the dependencies have been linked statically thus included in our SDK. We need to only include the code from our framework and link to external dependencies, like it does with our current CocoaPods setup. I'm wondering what options there are to achieve this. Even if I need to change the project setup locally, for example to continue using a framework project/workspace instead of a local Swift package. It seems I just need xcodebuild to be able to create an XCFramework which can then be distributed with its own Package.swift file that specifies its dependencies. If it's not possible to link the dependencies externally, could you help me to understand the implications of including them statically? I don't know what problems could arise as a result of that or other concerns this would bring. Thanks!
1
1
196
1w
Compiling the JPEG-XL reference for iOS, or, "Is compiling C++ for iOS really this difficult!?"
I'm trying to add JPEG-XL encoding/decoding capabilities to my app and haven't been able to find a trustworthy pre-compiled version. The only one I've found is in https://github.com/awxkee/jxl-coder-swift. As a result I've been trying to compile my own iOS version from the reference implementation (https://github.com/libjxl/libjxl), having done virtually no compiling before. When I started out, my gut said, "Compiling for a different platform should be easy since it's not like I'm actually writing or modifying the implementation", but the more I research and try, the more doubtful I've become. So far I've figured out it means compiling all the dependencies (brotli, highway, libpng, skcms, etc.) too, but I've also gotten nowhere with them, having tried my hand at modifying cmake toolchains and CMakeList.txt files. As a novice, am I biting off more than I can chew with this? Is the seemingly simple task, "Compile this C++ library for iOS" actually something that freelancers charge huge amounts for? (If so, this makes the free compiled version mentioned above even more questionable) Any help or pointers would be greatly appreciated.
5
0
189
1w
SwiftUI Previews broken on local Swift Package with dependencies
I have a project with two local packages One client package with an interface and some models with dynamic type in the Package.Swift One feature package with the UI and a dependency to the client package When I try to preview a view that is not using any models or code from the client package, it loads just fine e.g. a view that is just a container to display things like a card But when I tried to preview any other view that actually uses models from the client package, it just fails the first few lines of the preview error display LinkDylibError: Failed to build <filename>.swift Linking failed: linker command failed with exit code 1 (use -v to see invocation) ld: warning: search path '/Applications/Xcode-15.4.0.app/Contents/SharedFrameworks-iphonesimulator' not found Undefined symbols for architecture arm64: Also, I'm using Xcode 15.4 and iOS 17 as the min version
1
1
137
2w
How to set up multi platform efficiently
Hello, so I have a SwiftUI app that is relatively large, and it has multiple targets, one for each platform. but as I near App Store release I'm feeling very confused as to how to configure it. One app was rejected because the Mac target's name becomes the app which is different from App Store (Texty+ [App Store] vs Texty+ Mac [on target]). So I then just combined all the files into one target with a #if os(Mac... iOS) etc, but is that the proper way for multi platform app. I know there is like a Multiplatform target but that would require I restructure all the files and that always leads to issues in this near release app.
1
0
151
2w
SwiftData Document-based app produces strange write errors
I have a document app built using SwiftData because frankly I'm too lazy to learn how to use FileDocument. The app's title is "Artsheets," and I'm using a document type that my app owns: com.wannafedor4.ArtsheetsDoc. The exported type identifier has these values: Description: Artsheets Document Identifier: com.wannafedor4.ArtsheetsDoc Conforms to: com.apple.package Reference URL: (none) Extensions: artsheets MIME Types: (none) And the code: ArtsheetsApp.swift import SwiftUI import SwiftData @main struct ArtsheetsApp: App { var body: some Scene { DocumentGroup(editing: Sheet.self, contentType: .package) { EditorView() } } } Document.swift import SwiftUI import SwiftData import UniformTypeIdentifiers @Model final class Sheet { var titleKey: String @Relationship(deleteRule: .cascade) var columns: [Column] init(titleKey: String, columns: [Column]) { self.titleKey = titleKey self.columns = columns } } @Model final class Column: Identifiable { var titlekey: String var text: [String] init(titlekey: String, text: [String]) { self.titlekey = titlekey self.text = text } } extension UTType { static var artsheetsDoc = UTType(exportedAs: "com.wannafedor4.artsheetsDoc") } I compiling for my iPhone 13 works, but then when creating a document I get this error: Failed to create document. Error: Error Domain=com.apple.DocumentManager Code=2 "No location available to save “Untitled”." UserInfo={NSLocalizedDescription=No location available to save “Untitled”., NSLocalizedRecoverySuggestion=Enable at least one location to be able to save documents.}
0
0
146
2w
Export localization not working when using packages due to unnecessary macOS compile
Hi This issue is present both in previous, current, and beta versions of Xcode When a project has localization in packages, Xcode FAILS to export localization The reason is that when trying to export in this configuration, the compiler will try to export using macOS sdk, but if the package support only iOS of course will not find symbols for frameworks and functions that are scoped only for iOS This behaviour is not changed when the platforms for the package includes ".macOS("99") has I've found as a suggestion online The only way to perform this operation is to run, from CLI the following command xcodebuild -exportLocalizations -localizationPath . -sdk iphoneos -project TranslateTest.xcodeproj -exportLanguage en The problem is that this command will not work when one of the packages contains a macro. The following error will return in CLI if the macro is used (if the package is only imported no error appears) error: external macro implementation type 'MyMacroMacros.StringifyMacro' could not be found for macro 'stringify' I've found online some suggestions from apple folks that says to replace -sdk iphoneos with -destination 'platform=iOS,name=Any iOS Device’ in case your project contains a macro, but this changes nothing in the final result, the export will fail I'm providing a zip for apple in the radar (cannot upload zip here) that contains 3 example project for the 3 cases: A project without any packages that can extract its strings with any mode A project with a package that can only extract its strings only by CLI A project with multiple packages, one of which has a macro, and it can never extract its string This problem affects any possibility to have a modularised application with localisations, macros, and packages. Feedback FB13902424
1
0
165
2w
Xcode 16 crash trying to remove a package dependency
Feedback Submitted FB13898610 Xcode crashes with below. Pressing the "-" to remove a package dependancy. Solutions most welcome Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: Namespace SIGNAL, Code 6 Abort trap: 6 Terminating Process: Xcode [27376] Application Specific Information: abort() called Application Specific Signatures: NSInvalidArgumentException Application Specific Backtrace 0: 0 CoreFoundation 0x00007ff815134dc6 __exceptionPreprocess + 242 1 DVTFoundation 0x000000011257fd3e DVTFailureHintExceptionPreprocessor + 448 2 libobjc.A.dylib 0x00007ff814c24e9d objc_exception_throw + 48 3 CoreFoundation 0x00007ff81504f400 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 604 4 CoreFoundation 0x00007ff81504f18a +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49 5 DevToolsCore 0x000000012118ca09 -[PBXTarget removePackageProductDependencies:] + 1053 6 DevToolsCore 0x00000001211b1c65 -[PBXTarget packageReferenceWillBeRemoved:] + 273 7 CoreFoundation 0x00007ff8150b742a -[NSArray makeObjectsPerformSelector:withObject:] + 252 8 DevToolsCore 0x000000012116200c -[PBXProject(PBXTargetedNotifications) packageReferenceWillBeRemoved:] + 267 9 DevToolsCore 0x0000000121157026 -[PBXProject removePackageReference:] + 219 10 Xcode3UI 0x0000000128db10c8 __56-[Xcode3PackageReferenceListViewController removeItems:]_block_invoke + 319 11 Xcode3UI 0x0000000128db0c7b -[Xcode3PackageReferenceListViewController removeItems:] + 1925 12 AppKit 0x00007ff81891e34d -[NSApplication(NSResponder) sendAction:to:from:] + 337 13 IDEKit 0x00000001162a8e5f __37-[IDEApplication sendAction:to:from:]_block_invoke + 315 14 DVTFoundation 0x000000011257f51d DVTInvokeWithFailureHint + 78 15 IDEKit 0x0000000116202bc0 -[IDEApplicationController application:setFailureHintMessage:duringBlock:] + 118 16 IDEKit 0x00000001162a8f2b -[IDEApplication _invokeWithFailureHint:block:] + 105 17 IDEKit 0x00000001162a8cb8 -[IDEApplication sendAction:to:from:] + 333 18 AppKit 0x00007ff81891e1c3 -[NSControl sendAction:to:] + 86 19 AppKit 0x00007ff81891e0f5 __26-[NSCell _sendActionFrom:]_block_invoke + 131 20 AppKit 0x00007ff81891dffe -[NSCell _sendActionFrom:] + 171 21 AppKit 0x00007ff81891df46 -[NSButtonCell _sendActionFrom:] + 96 22 AppKit 0x00007ff81891ae32 NSControlTrackMouse + 1823 23 AppKit 0x00007ff81891a6ef -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 125 24 AppKit 0x00007ff81891a5b6 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 666 25 AppKit 0x00007ff8189199ab -[NSControl mouseDown:] + 666 26 AppKit 0x00007ff818918353 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4582 27 AppKit 0x00007ff818891177 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 313 28 AppKit 0x00007ff818890e23 -[NSWindow(NSEventRouting) sendEvent:] + 345 29 IDEKit 0x0000000116269d6a -[IDEWorkspaceWindow sendEvent:] + 158 30 AppKit 0x00007ff819043470 -[NSApplication(NSEventRouting) sendEvent:] + 1456 31 IDEKit 0x00000001162a8a7f -[IDEApplication sendEvent:] + 308 32 AppKit 0x00007ff818bfe8de -[NSApplication _handleEvent:] + 65 33 AppKit 0x00007ff81872209a -[NSApplication run] + 640 34 IDEKit 0x00000001162a888a -[IDEApplication run] + 54 35 AppKit 0x00007ff8186f5ff3 NSApplicationMain + 816 36 dyld 0x00007ff814c59366 start + 1942 Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x7ff814fac14a __pthread_kill + 10 1 libsystem_pthread.dylib 0x7ff814fe4ebd pthread_kill + 262 2 libsystem_c.dylib 0x7ff814f0aa79 abort + 126 3 IDEKit 0x116226509 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 1178 4 IDEKit 0x1162278c3 -[IDEAssertionHandler handleUncaughtException:] + 749 5 IDEKit 0x116227c00 IDEHandleUncaughtException + 94 6 IDEKit 0x1162a9370 -[IDEApplication reportException:] + 79 7 AppKit 0x7ff818722129 -[NSApplication run] + 783 8 IDEKit 0x1162a888a -[IDEApplication run] + 54 9 AppKit 0x7ff8186f5ff3 NSApplicationMain + 816 10 dyld 0x7ff814c59366 start + 1942
1
2
181
2w