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

268 Posts
Sort by:
Post not yet marked as solved
2 Replies
1.1k Views
I converted an iOS framework project to a Swift Package. Everything went smoothly and I can find and add the package to other projects. But Xcode won't display the README for the project. It only displays, "Unable to load the Read Me." I've stripped the README down to just a header and one line of text. I've removed the couple of extra files from the project that exist at the root level. But I still just get the same message. The project is located at: https://github.com/ecrichlow/IoGInfrastructure-iOS.git
Posted
by
Post marked as solved
2 Replies
1.4k Views
So far I'm unable to use Regex literals in my Swift Packages. Xcode simply gives a syntax error and has no idea I'm trying to do Regex. This is with Xcode 14.1 and all the platforms in the Package.swift have been set to the minimum requirement (iOS 16, macOS 13, etc) as well as the swift-tools-version set to 5.7. Using the Regex type directly (try Regex("[a-z]")) does work. It's just the literals that Xcode refuses to recognize. Regex literals do work in app projects and playgrounds. Is there a setting in the Package.swift or something I'm forgetting? Thanks in advance!
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
I'm working on a package that requires mixed language functionality (an Objective-C function calls a function in a Swift class). I've divided the language files into two targets - one for Swift and the other for Objective-C. The class called from Objective-C is declared with @objc and I can see the correct header is emitted for this class. I attempt to import this file into the Objective-C code as noted in this article However, when I attempt to import the emitted header into the Objective-C file, Xcode keeps saying this file can't be found. I assume this is because it's in another target in the same package. I can manually copy the emitted header directly into the package directory and then everything works correctly, but this isn't a sensible long-term solution. I assume there's something I need to do to make Xcode look in the correct directory for the emitted header - any suggestions/solutions?
Posted
by
Post marked as solved
6 Replies
2.7k Views
Hi, Many developers are working behind a company proxy and Xcode doesn't seem to pick up the system's settings (either with automatic or manual configuration). It makes it impossible to use SPM as Xcode is not able to fetch dependencies, getting very regularly the error message "No Route to host (-1)". I came across some workaround like changing the java config to use the system's settings or modifying the java exec used by Xcode to specify the proxy, but Xcode 14 doesn't seem to use java anymore (or at least I can't find where the config is located now). I also tried to set the JAVA_TOOL_OPTIONS env variable with my proxy details and with java.net.useSystemProxies=true, with no luck. Is there any way to configure the proxy within Xcode ? As anyone managed to make Xcode and SPM work behind a company proxy? I'd really appreciate some help. Thanks!
Posted
by
Post not yet marked as solved
7 Replies
2.2k Views
Out iOS app consists of a main project and several swift packages under a workspace. Every time I open the workspace, I end up with Xcode 14 being unusable for 10+ seconds, being stuck on Resolving package graph Adding/renaming/deleting files to any of the swift packages we have seems to trigger this as well. Has anyone experienced this as well?
Posted
by
Post not yet marked as solved
2 Replies
893 Views
Hello, I wrote a package with Float16 inside. When I compile a macos (13.x) app that includes this package, the compiler complains for unavailable Float16. However, If I compile the same code app with the code directly included (i.e. not in a package), everything is OK. It looks like the package is compiled for a macOS target < V11 despite the manifest specifies v13 Does anyone knows how to tell the SPM to use a specific version or as a workaround for tis issue ?
Posted
by
Post not yet marked as solved
1 Replies
2.6k 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
by
Post not yet marked as solved
4 Replies
1.9k Views
I have created a Swift package build tool plugin for colour generation. The plugin takes two input files from a project or swift package and from them generates a new Swift file containing references to all of the generated UIColors. When building locally and when using Github Actions the plugin is able to generate the required file within the pluginWorkDirectory and the project that references it can then access it as an input file during its build process. However, when building my project using Xcode Cloud, the plugin appears to be unable to create the file, it fails with the following error: Error while generating colours Files encountered an error at '/Volumes/workspace/DerivedData/SourcePackages/plugins/GLA.output/GLA/ColorGeneratorPlugin/GeneratedColors/Colors.swift'. 2022-11-22T15:46:11.344345498Z Reason: fileCreationFailed 2022-11-22T15:46:11.344390826Z LLVM Profile Error: Failed to write file "default.profraw": Operation not permitted` This then means that the build of the project fails with this error: Error opening input file '/Volumes/workspace/DerivedData/SourcePackages/plugins/GLA.output/GLA/ColorGeneratorPlugin/GeneratedColors/Colors.swift' (No such file or directory) It appears that Xcode Cloud is blocking the creation of files in the pluginWorkDirectory, even though locally it can. Has anyone faced a similar issue? Is there anything I can do to make it work in Xcode Cloud?
Posted
by
Post marked as solved
1 Replies
738 Views
So I've added swift-format as one of my dependencies to my own swift package so that I can use their lint swift package plugin. Here is my Package.swift: // swift-tools-version: 5.7 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "EssentialFeed", platforms: [ .iOS(.v16), .macOS(.v13), .macCatalyst(.v16), .tvOS(.v16), .watchOS(.v9) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "EssentialFeed", targets: ["EssentialFeed"]), .library( name: "EssentialFeedTestHelpers", targets: ["EssentialFeedTestHelpers"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-format", .upToNextMajor(from: "0.50700.1")), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages this package depends on. .target( name: "EssentialFeed", dependencies: [], plugins: [ .plugin(name: "LintPlugin", package: "swift-format"), .plugin(name: "FormatPlugin", package: "swift-format"), ] ), .target( name: "EssentialFeedTestHelpers", dependencies: []), .testTarget( name: "EssentialFeedTests", dependencies: ["EssentialFeed", "EssentialFeedTestHelpers"]), .testTarget( name: "EssentialFeedAPIEndToEndTests", dependencies: ["EssentialFeed", "EssentialFeedTestHelpers"]), ] ) I get the following error when pulling this package: product 'LintPlugin' required by package 'essentialfeed' target 'EssentialFeed' not found in package 'swift-format'. But if you look at swift-format's Package.swift, you can see the plugins exist.
Posted
by
Post not yet marked as solved
1 Replies
710 Views
I am compiling a flutter project in xcode which includes a NEPacketTunnelProvider extension. I want to launch a shell command in extension using Process class. I have use import Foundation but I get this error Swift Compiler Error (Xcode): Cannot find Process in scope I am using XCode 14.2 on macOS 14
Posted
by
Post not yet marked as solved
2 Replies
2.6k Views
Hello! I have a Swift package (SPM) with a number of tests associated with it. These all work well locally, and I have created a GitHub repository for the package that can be used by any app. I would like to set it up where my package's tests are triggered automatically whenever I push a change to a branch in the repository. Unfortunately, per the documentation, Xcode Cloud is currently unable to build and test standalone Swift packages. I hope that this will be rectified some point soon as automated testing for them seems like it'd be a pretty common and understandable use case. My question: Is there a way to set an Xcode Cloud workflow up wherein a package's tests are triggered? Xcode Cloud clearly does support Swift packages that are used when building full apps, and there is plenty of documentation to that end. But it's not clear how to trigger those package's tests even through the use of a "dummy" app without moving a bunch of tests to the app itself. Is this possible? I'd really not like to duplicate all my tests in a dummy app if at all possible. Thanks!
Posted
by
Post not yet marked as solved
5 Replies
1.3k 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
Post not yet marked as solved
11 Replies
4.8k 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
by
Post not yet marked as solved
4 Replies
3.7k 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
by
Post not yet marked as solved
2 Replies
666 Views
I need to install the GoogleSignIn for my iOS application, and I did so. The issue is that the watchOS app inside the project stops working because of build failures that are caused by the GoogleSignIn package. I cannot figure how to fix it, because inside the project settings, that package appears in the list of Frameworks for the iOS target, and is not present into the list of Frameworks for the watchOS target, as you can see in the first image below.
Posted
by
Post not yet marked as solved
2 Replies
878 Views
When I upgraded Xcode to the latest version 14.3, I have some problems with AEPServices. Showing Recent Errors Only underlying Objective-C module 'AEPServices' not found failed to verify module interface of 'AEPServices' due to the errors above; the textual interface may be broken by project issues or a compiler bug So I use more solutions about config search paths, target in build settings, and build phases, but it does not work for me. If anyone has encountered this problem, please give me a solution to fix it. Thanks a lot!
Posted
by
Post not yet marked as solved
1 Replies
883 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
Post not yet marked as solved
0 Replies
354 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
by
Post not yet marked as solved
0 Replies
1k 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