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

266 Posts
Sort by:
Post not yet marked as solved
0 Replies
9 Views
ive used pod "ohMySQL" in another projects but now hava an error like this Library not loaded: @rpath/OpenSSL.framework/OpenSSL Try update and deintegrate podfile and comment "use_frameworks" but can't find solution Any ideas? help me please
Posted Last updated
.
Post not yet marked as solved
0 Replies
65 Views
I am trying to create a Swift Package for a custom framework I'm building for a client. The framework has a dependency on a couple of 3rd party frameworks. I've read about how even though binary frameworks don't support dependencies directly, there is way to do this with a 'wrapper' target, so this is what I came up with for Package.swift: let package = Package( name: "SBCardScannerFramework", platforms: [ .iOS(.v16) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SBCardScannerFramework", targets: ["SBCardScannerFramework-Target"]), ], dependencies: [ // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"), .package(url: "https://github.com/marmelroy/PhoneNumberKit.git", from: "3.3.3") ], targets: [ .target(name: "SBCardScannerFramework-Target", dependencies: [ .target(name: "SBCardScannerFramework", condition: .when(platforms: [.iOS])), .product(name: "Algorithms", package: "swift-algorithms"), .product(name: "PhoneNumberKit", package: "PhoneNumberKit") ] ), .binaryTarget(name: "SBCardScannerFramework", path: "SBCardScannerFramework.xcframework") ] ) This works, and I can add the package to my test project and import the framework and it links against the dependancies as well, and works correctly. The problem is that every time I run the app, it also shows these messages in the Xcode console: objc[845]: Class _TtC14PhoneNumberKitP33_0FE53357E470A64027C8F0CAF7B114C812BundleFinder is implemented in both /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/Frameworks/SBCardScannerFramework.framework/SBCardScannerFramework (0x100f4aaf0) and /private/var/containers/Bundle/Application/EEE0C0A6-4FF5-44BC-B81A-F95401219D32/TestSBCardScannerFrameworkImport.app/TestSBCardScannerFrameworkImport (0x10069b778). One of the two will be used. Which one is undefined. There's multiple lines for different classes that show the "Class X is implemented in both [.../MyApp.app/Frameworks/MyFramework.frameworkMyFramework/] and [.../MyApp.app/MyApp]". I'm not sure how to avoid this problem, and whether this could cause a problem down the line. The framework that is the basis for this Swift Package is linked against the two dependencies, because I wouldn't be able to build the framework without them. But they also need to be added to the app target (at least, and if I don't, I get a run-time crash when using the PhoneNumberKit initializer. PhoneNumberKit/resource_bundle_accessor.swift:40: Fatal error: unable to find bundle named PhoneNumberKit_PhoneNumberKit Is there a good way to resolve this issue? I'm worried this will could be a problem for the client when they integrate it into their app, and the app is deployed to 1000s of devices.
Posted
by zulfishah.
Last updated
.
Post not yet marked as solved
2 Replies
441 Views
Hello, I have several extremely annoying Xcode 14 issues that completely destroyed my productivity. They've been hunting me for the last three or so months. I even searched the darkest corners of the Internet to find the cure, but although I found some solutions for people that had similar problems as mine, they unfortunately didn't help me at all. I have a Swift UIKit project that targets iOS 13.0 and newer (only for iPhone), contains 3 schemas (dev, show and prod channels), uses swift packages with remote and local dependencies. No cocoa pods or something like this. Each schema only defines compilation conditions (so I determine in my code which channel I use), nothing more was affected in the settings. I also use a custom build script that only copies Firebase configuration file to the executable folder depending on project's schema. Even though I tried my best by keeping the project structure as clear as I can do and not changing any other settings, leaving them by default as is, I'm still experiencing frustration, rage and sadness at the same time when I'm working with this project. I encountered the first issue when I was using different Swift Packages depending on project's schema (for dev channel I used an autogenerated dev backend api and so on for show and prod - I wrapped them in #if #else blocks). I also updated Xcode at that time. So the problem was, I got a lot of in-editor error messages saying that Xcode could not find in scope, although the required package was already included in the file. And here comes the frustration - the project still successfully builds. I tried to solve this problem by merging these three packages into one and import them without #if #else tricks, but that didn't help. To make things even worse, autocompletion and code suggestion were broken for all imported Swift Packages - it doesn't matter if package was remote or local. I tried to clean, rebuild, close Xcode, remove DerivedData folder, open Xcode in every combination I can imagine, but that didn't work, the problem didn't go away. After a couple of updates I also realized that live issues were completely broken. I didn't get any warnings and errors while coding. Only after building the project, real warnings and errors appeared in the editor and issue navigator, but only for three-four seconds, and then disappeared again. That drove me crazy. Tried to solve this problem with the same methods, it didn't help. Only after disabling live issues, the real warnings and errors did not disappear, but code suggestion and completion were still not working. I enabled Xcode indexing log by typing defaults write com.apple.dt.Xcode IDEIndexShowLog -bool YES in the Terminal app. I found out that Xcode was not able to find one module: /somePath/SomeFile.swift 0.2 seconds no such module 'somePackageName' This error appeared for every file I open and every character I type, but the error was pointing only at that specific file that actually imports that module. So I import this module (also added in the project settings), but still get an error that the module was not found, but again the project successfully compiles and runs. It is an Xcode Framework from a third-party developer that they provided for us. The framework contains binaries only for ios-arm64 and ios-arm64_x86_64-simulator. I use a glorious M1 Mac. I decided yesterday to create a new project and copy there all code and resource files. I thought that I accidentally broke something in the settings and so I made them again from scratch. I did not had my Lightning cable this time, so I built the app for iPhone 14 Pro simulator. And the Xcode heard my prayers - everything was working great. The live issues worked as they should, I did not get any false errors and the autocompletion and code suggestions were fine. I got relief on that cloudy evening... But that's too good to be true, here is the plot twist. I got today my Lightning cable back, connected an iPhone to my Mac. And now I got all these issues again 💀 So now it looks like these issues only happen when I select a physical device as a run destination. I discovered it while writing this post. Any suggestions how to solve this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
83 Views
Hi, I am working on distributing a 'framework' I made to a client. The framework itself has a couple of dependencies on a couple of 3rd-party frameworks. Also, I don't want to disclose my source code to the client. So after doing some research, it seems like the best way to do this would be to use Swift Packages, and make it a binary distribution, which would basically wrap a .xcframework (which I would generate with my source code). But I'm confused about the next steps ... how would I go about sharing the 'package' with the client? Would I just zip up the 'package' folder and email it to them, and they can unzip it on their end, and add it to their project by using "Add local package"? Or is there a more elegant way to do this, which doesn't require publishing a package publicly?
Posted
by zulfishah.
Last updated
.
Post not yet marked as solved
0 Replies
89 Views
Hey! In Xcode I got the error that the module flutter_keyboard_visibility wasn't found. But I have installed it, installed Cocoa Pods but the Podfile got an error too . I don't know what to do, but it would be great if anybody could help me. first error: GeneratedPluginRegistrant.m:12:9 Module flutter_keyboard_visibility not found second: GeneratedPluginRegistrant.h:10:9 Flutter/Flutter.h file not found
Posted Last updated
.
Post not yet marked as solved
0 Replies
127 Views
Though everything works fine locally, while trying to build a project in xcode cloud, i get the error archive of binary target 'libjsoncpp.a' does not contain expected binary artifact named 'libjsoncpp.a' It is referenced in a Package.swift file as so .binaryTarget( name: "libjsoncpp.a", url: "https://github.com/Imajion/libjsoncpp.a/releases/download/r3/libjsoncpp.a.xcframework.zip", checksum: "f29acc8d9e5b983fde90d2f8b8c8091bed8c25d42cc58d487ef0b8f7db303ba6" ), I've also tried checking the .zip into the project and referencing locally as such .binaryTarget(name: "libopen3d.a", path: "./PreBuilt/libopen3d.a.xcframework.zip"), However I get the same error. Can anyone offer any insight? The error is quite vauge. The link above is valid if anyone would like to check the archive.
Posted
by rumbe.
Last updated
.
Post not yet marked as solved
0 Replies
77 Views
I am currently facing a challenge in my iOS app development. I need to programmatically retrieve the status of the Auto Rotate setting in iOS, specifically the lock status of the Portrait Mode. Could you please provide guidance on how to obtain the lock status of the Portrait Mode programmatically in iOS? I want to adapt my app's behavior based on this information to ensure a seamless user experience. I would greatly appreciate any assistance, insights, or code snippets that can help me address this problem effectively. https://i.stack.imgur.com/D9AWh.jpg I expect to obtain the lock status of the Portrait Mode programmatically in iOS. The desired result would provide me with information on whether the Portrait Mode is currently locked or unlocked on the device. I am seeking guidance, suggestions, or sample code snippets that can help me retrieve this lock status effectively using Swift in my iOS app development.
Posted
by Trush.
Last updated
.
Post not yet marked as solved
24 Replies
11k Views
I keep getting a Xcode Previews error in Xcode 12 from a package that imports other packages. As soon as I remove the dependency I'm able to see the SwiftUI preview. I'm only able to use previews in packages that have no dependencies The error I get is: "LoadingError: failed to load library at path...Library not loaded " then it point to the dependency that it could not load in the current package. How can I access Xcode Previews from a package that depends on other packages?
Posted
by iamlogiq.
Last updated
.
Post not yet marked as solved
5 Replies
1.3k Views
Everything has been going well but 2 days ago I was forced to update my Xcode version and now everything is broken. After updating from 14.2 to 14.3 I have been unable to remove an error in "YogaKit.private.swiftinterface" and "YogaKit.swiftinterface". Both of these headers give the same issues as follows: Failed to verify module interface of 'YogaKit' due to the errors above; the textual interface may be broken by project issues or a compiler bug Underlying Objective-C module 'YogaKit' not found no such module 'yoga' SO FAR I HAVE: ++ Deleted DerivedData ++ Added Yoga as an explicit path in Podfile via pod 'Yoga',:path => '../node_modules/react-native/ReactCommon/yoga' ++ Tried each variation again with using lowercase yoga ++ Verified Yoga is in the Pods ++ Verified YogaKit is in the Pods ++ rm -rf pods, podlock, and node_modules and reinstalled numerous times ++ Verified the exact same build works perfectly on 14.2 ++ Googled + ChatGPT couldn't find solution ^-------------------------^---------------------------^ I can read from the provided issues that there is likely a mismatch of some sort with Yoga/YogaKit/React Native. I am confused as to why an xCode version update would have breaking changes like this in it but regardless I could compile and archive just fine before this xCode version update so it's hard to imagine what else could have caused this at the exact same time as an Xcode version update. Do you have the same problem? Were you able to fix it? Please help!
Posted Last updated
.
Post not yet marked as solved
1 Replies
670 Views
We are implementing third party XCFrameworks for our clients. We are planning to use @_implementationOnly import in our SDK due to our framework pluggability requirement. We are skeptical about using this in our SDK due to the following warning. https://github.com/apple/swift/blob/main/docs/ReferenceGuides/UnderscoredAttributes.md Could you please confirm that if we use this @_implementationOnly import in our framework, do we get any problems when our Clients are submitting their apps to AppStore ? Underscored Attributes Reference : WARNING: This information is provided primarily for compiler and standard library developers. Usage of these attributes outside of the Swift monorepo is STRONGLY DISCOURAGED.
Posted Last updated
.
Post not yet marked as solved
0 Replies
86 Views
Hello Dev's around the world. I'm new using the contextMenu, and I create a card when you tap send you to a view that if you see the code it works with navigationView but if I do a long press using contextMenu it supposed that send me to another view, but I'm using the next code and it doesn't works, it's like a took another card and show me the information of other card. I hope that you can help me, I tried with .sheet and it doesn't work either. ForEach($list) { $Category in NavigationLink(destination: CategoryList(list: $Category)){ CategoryCard(list: Category) .frame(height: 100) .contextMenu{ Button { selectedEditCategory = Category isPreseingDetailEditCardView.toggle() print(Category.title) } label: { Text("Edit") } } } .background( NavigationLink( destination: DetailCardView(list: $Category), isActive: $isPreseingDetailEditCardView, label: { EmptyView() } ) ) } Thank you.
Posted Last updated
.
Post not yet marked as solved
0 Replies
82 Views
I have two target in Swift package manager, one is Objective-C target and another one is Swift target. I have few Custom components in Objective-C target and need to access those components in Swift target. I have added Objective-C target as dependency to Swift target in package.swift. Still i am getting error on swift ViewController class showing "Cannot find type 'CustomTextView' in Scope". I need to access Objective-C custom components from Objective-C target to Swift target in local package.
Posted
by iOSDev88.
Last updated
.
Post not yet marked as solved
3 Replies
412 Views
The command plugin do not appear in Xcode 14.3 shown in 14.2 Is there any change in specifications? Or is it just a bug in 14.3? I hope this problem will be resolved in 14.3.1 as soon as possible. Related Issues https://github.com/nicklockwood/SwiftFormat/issues/1404 https://github.com/apollographql/apollo-ios/issues/2919
Posted
by nekodoko.
Last updated
.
Post not yet marked as solved
0 Replies
116 Views
I have an old project Objective-C iOS app I've been updating to Swift. It used to use Carthage, but now uses only SPM for dependencies. One such dependency is TrueTime (which was updated to support SPM by that author). It has two products, TrueTime, a Swift library, and CTrueTime a header-only C library with some packed, byte-aligned structs used when parsing NTP responses. I’m adding unit tests to my project, and when I import the app module with @testable import MyApp, the build fails on that line with @testable import MyApp ^ <unknown>:0: error: missing required module 'CTrueTime' The app itself builds and runs just fine. If I don’t import the app, then I have to expressly add code I want to test to the test target, which is not the right way to do these things. The other dependencies I have all work fine, but none have a C library product. I get a warning about implicitly including a bridging header, but I don’t think that has anything to do with this. Update: I also just tried adding TrueTime to a modern, pure SwiftUI iOS app, and I get the same issue. Is there something more I need to add to my test target config? (I've also posted this to stack overflow https://stackoverflow.com/questions/76284838/when-importing-app-with-testable-get-missing-required-module-ctruetime-usi)
Posted
by JetForMe.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
I am developing a swift application and trying to send data to Kafka topic. Still couldn't identify any native swift implementation for this transmission and no reliable packages available to make use of it. Can anyone guide me for possible solutions to start sending data from my swift application. My data would be in JSON format. Thanks.
Posted Last updated
.
Post not yet marked as solved
0 Replies
176 Views
These were the commands included in run script: "${PODS_ROOT}/FirebaseCrashlytics/run" "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}//GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}" And in build options -> Debug Information Format I have set it Dwarf with DSYM file If the Bitcode is enabled in the build settings I'm not able run the app What should I do to upload dsym from Xcode rather than manually uploading it ?
Posted
by vishakh77.
Last updated
.