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

262 Posts
Sort by:
Post not yet marked as solved
1 Replies
209 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 kudit.
Last updated
.
Post not yet marked as solved
2 Replies
833 Views
We have separated much of our UI into different packages to reduce complexity and compile time. When we recently tested using new .xcstrings string catalogs, we hit an unexpected problem. Strings extracted from SwiftUI components like Text or Button are extracted into the Localizable.xcstrings in the same package, but the default behaviour of Text(_ key:tableName:bundle:comment:) is to use Bundle.main. When the default behaviour of the string extraction isn't to extract to the main app target, this introduces a very fragile system where it's easy to add code that looks localised, but ends up failing lookup at runtime. I don't feel comfortable that we will always remember to define the correct module every time we create a Text. Also, other components like Button doesn't have an init that takes a Bundle, so we would also have to remember that Button(_ titleKey:action:) can now only be used in a package if we make sure that the main bundle contains a matching key. Is there a way for us to make sure that strings are always extracted to the same place as they are resolved against by default? Either by having strings in packages extracted to an xcstrings file in the main app or having Text default to resolving against the module bundle by default?
Posted Last updated
.
Post not yet marked as solved
0 Replies
226 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 Curiosity.
Last updated
.
Post not yet marked as solved
1 Replies
306 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 Last updated
.
Post not yet marked as solved
0 Replies
182 Views
大家好,我正在尝试制作一个关于如何检测手机屏幕前是否有物体的演示。如果有物体,屏幕将显示红色,如果没有物体,则显示绿色。这可能需要调用距离传感器,但我不知道如何调用它。希望大家能给我一个回应。谢谢。
Posted
by Esoting.
Last updated
.
Post not yet marked as solved
15 Replies
2.5k Views
Since Xcode 15.3 it has become impossible to build our project more twice in a row without encountering a batch of "internal inconsistency error: never received target ended message for target ID …". This issues appeared a few months ago (15.0 i think, but i'm not sure), but xcode 15.3 makes it almost unusable. We're a team of 3 iOS devs, and we're all having the problem. Our project involves a lot of SPM packages, a few cocoa pods, a few iOS Frameworks, and a bit of swiftgen. Nothing particularly special for a large project, and no custom build steps that does anything fancy. It is now to the point where we're looking for alternative to xcode, because we can't decently kill xcode and restart every time we have to build our code...
Posted Last updated
.
Post not yet marked as solved
0 Replies
496 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 DSdevPH.
Last updated
.
Post marked as solved
1 Replies
186 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 Farrriiaa.
Last updated
.
Post not yet marked as solved
3 Replies
261 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 Last updated
.
Post not yet marked as solved
2 Replies
288 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 Playrom.
Last updated
.
Post not yet marked as solved
0 Replies
514 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 moshekr.
Last updated
.
Post not yet marked as solved
2 Replies
339 Views
objc[27000]: Class XROS1_1SimRuntime is implemented in both /Library/Developer/CoreSimulator/Volumes/xrOS_21O209/Library/Developer/CoreSimulator/Profiles/Runtimes/xrOS 1.1.simruntime/Contents/MacOS/xrOS 1.1 (0x1025f80e0) and /Library/Developer/CoreSimulator/Volumes/xrOS_21O5181e/Library/Developer/CoreSimulator/Profiles/Runtimes/xrOS 1.1.simruntime/Contents/MacOS/xrOS 1.1 (0x1027c00e0). One of the two will be used. Which one is undefined. error: Tool terminated by signal 'Segmentation fault: 11' This build failed issue occur every time when I play build
Posted
by B2D.
Last updated
.
Post not yet marked as solved
0 Replies
164 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 SergioDCQ.
Last updated
.
Post not yet marked as solved
0 Replies
158 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 akksupper.
Last updated
.
Post not yet marked as solved
1 Replies
329 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 yun22.
Last updated
.
Post not yet marked as solved
0 Replies
198 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 Last updated
.
Post not yet marked as solved
0 Replies
251 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 alok10.
Last updated
.
Post not yet marked as solved
4 Replies
2.0k 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 Last updated
.