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.

Swift Packages Documentation

Posts under Swift Packages tag

260 Posts
Sort by:
Post not yet marked as solved
1 Replies
236 Views
I am trying to include custom symbol resources in a swift package for use in other projects. I have read the documentation here: https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package However there is no example code and I have created a very simple project to try and get this working but it does not. .target( name: "TestLibrary", resources: [.process("Resources/Media.xcassets")] ), This is in the Package.swift file and the path relative to the Package.swift file is Sources/TestLibrary/Resources/Media.xcassets. There's a GitHub project with an example custom SF Symbol SVG (but this may not be available in the future): https://github.com/kudit/TestLibrary Including this as a package in a blank Swift Playgrounds App project and just importing the TestLibrary and including TestImageView() in the ContentView technically works (it shows the system full star image, but none of the ways of rendering the test symbol as recommended works. It does work for a few of the options in the #Preview when viewing the project in Xcode. Anyone have any suggestions or know how to get the resources to be accessible from outside the module? I have tried both the .copy( option as well as the .process( option and neither seem to work.
Posted
by
Post not yet marked as solved
0 Replies
244 Views
In a new document-based UIKit app, specifying in the Info.plist an import type identifier of public.log that conforms to public.content, public.data, public.item accomplishes this. In a new document-based SwiftUI multi-platform app, doing the same crashed at the DocumentGroup initializer with the error _SwiftData_SwiftUI/Documents.swift:91: Fatal error: The document type is public.log which does not conform to com.apple.package. This initializer expects the document type to be a package.
Posted
by
Post not yet marked as solved
1 Replies
340 Views
We use a local swift package in 6 of our app extensions. The product from the local package that we link to each app extension is a dynamic framework. And while the dynamic framework is copied into the final app bundle once, the resource bundles of each target that comprise the dynamic framework is copied into each app extension. I'd much rather have the bundles be copied into the dynamic framework once to prevent app bloat. Here is a visualization of the issue: . └── MyApp.ipa/ ├── MyApp (executable) ├── MyDynamicFramework_TargetA.bundle ├── MyDynamicFramework_TargetB.bundle ├── MyDynamicFramework_TargetC.bundle ├── Frameworks/ │ └── MyDynamicFramework.framework/ │ ├── TargetA │ ├── TargetB │ └── TargetC └── PlugIns/ ├── Widgets.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── Intents.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── IntentsUI.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── NotificationContent.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle ├── RichPushContent.appex/ │ ├── MyDynamicFramework_TargetA.bundle │ ├── MyDynamicFramework_TargetB.bundle │ └── MyDynamicFramework_TargetC.bundle └── NotificationService.appex/ ├── MyDynamicFramework_TargetA.bundle ├── MyDynamicFramework_TargetB.bundle └── MyDynamicFramework_TargetC.bundle Notice that the resource bundles of Target A, B, and C are copied multiple times causing an unhealthy app size. I'd either like the resource bundles to be copied into MyDynamicFramework or copied once into the app bundle and let the app extensions reference them. Given the SPM + Xcode linking is a black box for the most part, how would I accomplish this?
Posted
by
Post not yet marked as solved
0 Replies
203 Views
大家好,我正在尝试制作一个关于如何检测手机屏幕前是否有物体的演示。如果有物体,屏幕将显示红色,如果没有物体,则显示绿色。这可能需要调用距离传感器,但我不知道如何调用它。希望大家能给我一个回应。谢谢。
Posted
by
Post not yet marked as solved
0 Replies
575 Views
I've complied with the reason declaration following the links sent by the autogenerated emails for the surface level Runner declaration, however libswift has the incorrect values for the reason codes for UserDefaults. I've checked their github and there is no way to add issues since it is "read-only". I'm also in the dark for who to contact regarding this. Does anyone have any idea how to resolve this aside from manually changing the privacy files? I don't want to have to do this each time I do pod install. ITMS-91055: Invalid API reason declaration - The PrivacyInfo.xcprivacy for the “Frameworks/libswiftObjectiveC.dylib” file contains “DDA9.1” as the value for a NSPrivacyAccessedAPITypeReasons key instead of a valid reason code for using an API in the NSPrivacyAccessedAPICategoryUserDefaults category.
Posted
by
Post marked as solved
1 Replies
195 Views
Hello everyone! I am kind a new here and trying to learn Swift. I am getting this error "Expressions are not allowed at the top level" I´ve tried both with an function and without function! func text(){ let number = 120 print(number.isMultiple(of: 3)) } text() Without function let number = 120 print(number.isMultiple(of: 3)) I really appreaciate if you can help me out! My playground app is crashing every time I open it so I´ve got no other choice but to use Xcode Kind regarding Your noob friend!
Posted
by
Post not yet marked as solved
3 Replies
297 Views
I have encountered an issue related to the usage of string catalogs in a Swift package. I created a repository for reproduction. https://github.com/atacan/DiscussionStringCatalogPackage The Readme.md file has all the details. Here is a short summary: The Package.swift file's target has resources: [.process("Resources")], and this Resources folder contains a string catalog. The catalog is correctly populated by the compiler, and German translations are added. Text view is using bundle: .module argument. However, when the scheme run options are changed to German, the UI still displays English text. Xcode throws a warning indicating that the German translation for the text is not found in the Localizable table of the bundle and it says (not loaded). Although the bundle contains translations in the Localizable.strings file. Screenshots of the issue are available in the original README file. I am looking for any insights or solutions to this problem.
Posted
by
Post not yet marked as solved
0 Replies
539 Views
When distributing a 3rd party SDK as an XCFramework in order to include the privacy manifest to the bundle you need to include the resources key in the target configuration to point to the correct file, for example: resources: [.process("Resources/PrivacyInfo.xcprivacy")] However, when distributing the xcframework as a binaryTarget resources is not available. How can I include my privacy manifest when configuring Package.swift ?
Posted
by
Post not yet marked as solved
0 Replies
178 Views
Would like to be able to bring up the iOS keyboard in a SwiftUI view without having to use a TextField? The goal would be to capture each keyup, or keydown, using .onKeyPress While I thought I could create a TextField not visible to the user, was hoping there was a cleaner way.
Posted
by
Post not yet marked as solved
0 Replies
169 Views
Hi, I'm facing an issue with triggering sign in. The button only triggers after a long press, not just simple tap. There's no scrollView, just ZStack. I've already tried deleting all the layers and components except this button, still nothing.
Posted
by
Post not yet marked as solved
2 Replies
365 Views
I am getting the following error after xcode was updated, it is saying that i cant find the googlemobileads framwork, however i have since, restarted my mac, restart xcode, reset simulator, erare all content and settings, delete derivadata, delete the devices and create new one. also check that the framework is being link. see below Apple i need help here
Posted
by
Post not yet marked as solved
0 Replies
215 Views
[!] The Runner [Debug] target overrides the ENABLE_BITCODE build setting defined in `Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig'. This can lead to problems with the CocoaPods installation How to fix this error ?
Posted
by
Post not yet marked as solved
6 Replies
529 Views
So I am running into a very strange issue. Xcode is deleting the Package.resolved file after every build, resulting in having to manually Reset Package caches after every build/run/test. Extremely annoying, any idea why this is happening?
Posted
by
Post not yet marked as solved
0 Replies
274 Views
Hi, im new to swift development and i'm building ios version for my website chatpdf.so and i'm having trouble parsing server sent event from my server to the mobile app. Is there good library for swift to parse sse easily? I'm trying to implement it natively but im getting parsing error in EventSource.
Posted
by
Post not yet marked as solved
2 Replies
309 Views
I've a workspace with multiple packages, and due to the a bug in Xcode I cannot export the app localizations using the Xcode GUI tool, but I need to resort on using a command from terminal xcodebuild -exportLocalizations -localizationPath . -workspace <path_workspace> -sdk iphoneos -exportLanguage en One of my packages contains some macros, and I use them from my code without any problem, the code compile But when I try to export localizations using that command, the build fails due to "compiler plugin not loaded" So I cannot use Xcode normal exporting because Xcode bug, and cannot export by running a command due to the macro problem What should I do? It is very discouraging this situation, do you have any suggestion? I've found a similar problem
Posted
by
Post not yet marked as solved
7 Replies
764 Views
I have a Swift Package Manager module with some SwiftUI files that I was using Previews without issues in Xcode 15.2. When I upgraded to Xcode 15.3, it fails with “Cannot preview in this file. Unexpected error occurred”. When I click to get more info, this is the error: == PREVIEW UPDATE ERROR: HumanReadableSwiftError BuildError: failedToGenerateThunkInfo(could not generate preview info: noTargetBuildGraph) Is anyone experiencing the same problems? My preview, which lives in a SPM package, works totally fine in Xcode 15.2, but fails in Xcode 15.3. Any ideas for how to fix it? I've tried deleting DerivedData, resetting package caches, clean building. So frustrating seeing these regression issues popping up still. I filed FB13678356 but it was quickly marked as "Investigation Complete - Unable to diagnose with current information" but there was no request for what further information I could provide! I attached a full sysdiagnose and error log! Would also note, that when I revert back to Xcode 15.2, the previews go back to working...
Posted
by
Post not yet marked as solved
4 Replies
1.6k Views
Hey! I noticed a difference between Xcode 15.2 and 15.3 which causes our production build to fail verification with Apple. This happens with one Swift Package which has xcframeworks as binary targets. There is no issue when exporting the app using Xcode 15.2, as the frameworks are not exported into the Frameworks folder within the app package when inspecting the exported archive. With Xcode 15.3 it is exported which then causes the following error: 2024-03-11 13:53:03.520 *** Error: ERROR: [ContentDelivery.Uploader] Asset validation failed (90208) Invalid Bundle. The bundle App.app/Frameworks/AppCenter.framework does not support the minimum OS Version specified in the Info.plist. (ID: 9e47cf5c-dc23-4cdf-8490-f9befc9e2aa1) 2024-03-11 13:53:03.521 *** Error: ERROR: [ContentDelivery.Uploader] Asset validation failed (90208) Invalid Bundle. The bundle App.app/Frameworks/AppCenterAnalytics.framework does not support the minimum OS Version specified in the Info.plist. (ID: 619289b3-c102-4161-8b63-73d42292a3cf) 2024-03-11 13:53:03.522 *** Error: ERROR: [ContentDelivery.Uploader] Asset validation failed (90208) Invalid Bundle. The bundle App.app/Frameworks/AppCenterCrashes.framework does not support the minimum OS Version specified in the Info.plist. (ID: ac590192-a99b-4aec-ad08-b21afadd10d0) 2024-03-11 13:53:03.522 *** Error: ERROR: [ContentDelivery.Uploader] Asset validation failed (90208) Invalid Bundle. The bundle App.app/Frameworks/AppCenterDistribute.framework does not support the minimum OS Version specified in the Info.plist. (ID: 69e0e8a6-11a7-46e5-9e5a-cf85c8fc15be) 2024-03-11 13:53:21.546 INFO: [ContentDelivery.Uploader] ============= VERIFY FAILED with 4 errors. ============= 2024-03-11 13:53:21.548 *** Error: Validation failed for 'OEBB.ipa'. 2024-03-11 13:53:21.548 *** Error: Asset validation failed Invalid Bundle. The bundle App.app/Frameworks/AppCenter.framework does not support the minimum OS Version specified in the Info.plist. (ID: 9e47cf5c-dc23-4cdf-8490-f9befc9e2aa1) (90208) { NSLocalizedDescription = "Asset validation failed"; NSLocalizedFailureReason = "Invalid Bundle. The bundle App.app/Frameworks/AppCenter.framework does not support the minimum OS Version specified in the Info.plist. (ID: 9e47cf5c-dc23-4cdf-8490-f9befc9e2aa1)"; NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 \"Asset validation failed\" UserInfo={status=409, detail=Invalid Bundle. The bundle App.app/Frameworks/AppCenter.framework does not support the minimum OS Version specified in the Info.plist., id=9e47cf5c-dc23-4cdf-8490-f9befc9e2aa1, code=STATE_ERROR.VALIDATION_ERROR.90208, title=Asset validation failed, NSLocalizedFailureReason=Invalid Bundle. The bundle App.app/Frameworks/AppCenter.framework does not support the minimum OS Version specified in the Info.plist., NSLocalizedDescription=Asset validation failed}"; "iris-code" = "STATE_ERROR.VALIDATION_ERROR.90208"; } 2024-03-11 13:53:21.548 *** Error: Asset validation failed Invalid Bundle. The bundle App.app/Frameworks/AppCenterAnalytics.framework does not support the minimum OS Version specified in the Info.plist. (ID: 619289b3-c102-4161-8b63-73d42292a3cf) (90208) { NSLocalizedDescription = "Asset validation failed"; NSLocalizedFailureReason = "Invalid Bundle. The bundle App.app/Frameworks/AppCenterAnalytics.framework does not support the minimum OS Version specified in the Info.plist. (ID: 619289b3-c102-4161-8b63-73d42292a3cf)"; NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 \"Asset validation failed\" UserInfo={status=409, detail=Invalid Bundle. The bundle App.app/Frameworks/AppCenterAnalytics.framework does not support the minimum OS Version specified in the Info.plist., id=619289b3-c102-4161-8b63-73d42292a3cf, code=STATE_ERROR.VALIDATION_ERROR.90208, title=Asset validation failed, NSLocalizedFailureReason=Invalid Bundle. The bundle App.app/Frameworks/AppCenterAnalytics.framework does not support the minimum OS Version specified in the Info.plist., NSLocalizedDescription=Asset validation failed}"; "iris-code" = "STATE_ERROR.VALIDATION_ERROR.90208"; } 2024-03-11 13:53:21.548 *** Error: Asset validation failed Invalid Bundle. The bundle App.app/Frameworks/AppCenterCrashes.framework does not support the minimum OS Version specified in the Info.plist. (ID: ac590192-a99b-4aec-ad08-b21afadd10d0) (90208) { NSLocalizedDescription = "Asset validation failed"; NSLocalizedFailureReason = "Invalid Bundle. The bundle App.app/Frameworks/AppCenterCrashes.framework does not support the minimum OS Version specified in the Info.plist. (ID: ac590192-a99b-4aec-ad08-b21afadd10d0)"; NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 \"Asset validation failed\" UserInfo={status=409, detail=Invalid Bundle. The bundle App.app/Frameworks/AppCenterCrashes.framework does not support the minimum OS Version specified in the Info.plist., id=ac590192-a99b-4aec-ad08-b21afadd10d0, code=STATE_ERROR.VALIDATION_ERROR.90208, title=Asset validation failed, NSLocalizedFailureReason=Invalid Bundle. The bundle App.app/Frameworks/AppCenterCrashes.framework does not support the minimum OS Version specified in the Info.plist., NSLocalizedDescription=Asset validation failed}"; "iris-code" = "STATE_ERROR.VALIDATION_ERROR.90208"; } 2024-03-11 13:53:21.548 *** Error: Asset validation failed Invalid Bundle. The bundle App.app/Frameworks/AppCenterDistribute.framework does not support the minimum OS Version specified in the Info.plist. (ID: 69e0e8a6-11a7-46e5-9e5a-cf85c8fc15be) (90208) { NSLocalizedDescription = "Asset validation failed"; NSLocalizedFailureReason = "Invalid Bundle. The bundle App.app/Frameworks/AppCenterDistribute.framework does not support the minimum OS Version specified in the Info.plist. (ID: 69e0e8a6-11a7-46e5-9e5a-cf85c8fc15be)"; NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 \"Asset validation failed\" UserInfo={status=409, detail=Invalid Bundle. The bundle App.app/Frameworks/AppCenterDistribute.framework does not support the minimum OS Version specified in the Info.plist., id=69e0e8a6-11a7-46e5-9e5a-cf85c8fc15be, code=STATE_ERROR.VALIDATION_ERROR.90208, title=Asset validation failed, NSLocalizedFailureReason=Invalid Bundle. The bundle App.app/Frameworks/AppCenterDistribute.framework does not support the minimum OS Version specified in the Info.plist., NSLocalizedDescription=Asset validation failed}"; "iris-code" = "STATE_ERROR.VALIDATION_ERROR.90208"; } The package used is the following: https://github.com/ilendemli/appcenter-sdk-apple-spm (package by me, using binary packages to avoid building AppCenter every time) Comparison image: Left exported using Xcode 15.2 (works), right exported using 15.3 (fails)
Posted
by
Post not yet marked as solved
4 Replies
2.1k Views
Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/abseil.framework' is ''. (ID: 976fe056-e7a1-4d39-bacb-df90b8efea9b) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/BoringSSL-GRPC.framework' is ''. (ID: c68c6576-9c7d-4b4f-8562-348578079194) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/FirebaseAnalytics.framework' is ''. (ID: 098dcfe7-c07f-47e8-b9fa-ad081a0f45a6) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/FirebaseFirestore.framework' is ''. (ID: 814fbcf1-cb95-4775-b394-f9d150f577cb) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/GoogleAppMeasurement.framework' is ''. (ID: 288331b7-ad05-45e9-8989-4668645f9723) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/GoogleAppMeasurementIdentitySupport.framework' is ''. (ID: 83aba61f-862e-400d-a67f-6afd021bd1d2) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/gRPC-C++.framework' is ''. (ID: e8494bc6-78bf-496c-bc26-c71e9cb771b2) Asset validation failed Invalid MinimumOSVersion. Apps that only support 64-bit devices must specify a deployment target of 8.0 or later. MinimumOSVersion in 'MyApp.app/Frameworks/gRPC-Core.framework' is ''. (ID: c91250c0-c445-483a-a0e3-6e5b4b01197f) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/abseil.framework is required. (ID: f5adb088-e079-4df9-95ed-107fe244ee33) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/BoringSSL-GRPC.framework is required. (ID: 7e8def5b-283f-4ef7-9d17-562cf4fa0e54) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/FirebaseAnalytics.framework is required. (ID: 39ebde66-fbfc-496c-83f5-92e81b057930) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/FirebaseFirestore.framework is required. (ID: 4f34e998-9151-40d4-9b85-7942076f01ff) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/GoogleAppMeasurement.framework is required. (ID: 6ca3ba96-85df-4cd6-bcb9-4ca0d1faffe5) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/GoogleAppMeasurementIdentitySupport.framework is required. (ID: 6cb9b76b-653a-494b-97b8-88702c6fbee8) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/gRPC-C++.framework is required. (ID: 7a37ef2b-55a9-446a-9eaa-3ffccee0e99b) Asset validation failed Missing Info.plist value. A value for the key 'MinimumOSVersion' in bundle MyApp.app/Frameworks/gRPC-Core.framework is required. (ID: a9b0eb06-2cf3-4265-87f4-997b7926e8a8) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/abseil.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: f7116884-2736-47e3-8c1a-942572fa6a97) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/BoringSSL-GRPC.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: 2faae9e4-78af-4437-8830-b778d4059489) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/FirebaseAnalytics.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: 4b53026c-c01c-43a3-ada0-a23340b40844) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/FirebaseFirestore.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: 995291aa-028e-432d-b9f9-422398739388) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/GoogleAppMeasurement.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: a5e7337e-4504-4119-be9a-b372efa0a95d) Asset validation failed The bundle 'Payload/MyApp.app/Frameworks/GoogleAppMeasurementIdentitySupport.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring (ID: 1ce00379-9d3c-442d-8959-8d400ae22137)
Posted
by