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

233 Posts
Sort by:
Post not yet marked as solved
2 Replies
375 Views
In my iOS project, I have 20 Swift packages. When I reset the caches Xcode is at normal speed. Once I resolve the Package versions. Xcode gets way slower, even scrolling takes a 1-second delay. This started to happen after Updating to macOS Ventura. I am using a Macbook Pro m1 max with 32 GB of Ram. Any idea why it is happening?
Posted Last updated
.
Post marked as solved
6 Replies
5.4k Views
Today, after Xcode 12.5 upgraded, when I try to work on my projects, Xcode keeps running "Resolve Swift Packages" every second or so, this means that it both keeps flashing the display the whole time - it never settles, and it also keeps the machine busy and eventually, Xcode becomes unusable. This has a movie showing what my Xcode looks like tonight, the pauses in the video are caused by Xcode not responding to scrolling, since I left that thing idling while I had dinner: tirania.org/tmp/xcode-hang.mov This can be reproduced by downloading github.com/migueldeicaza/SwiftTerm and opening either the Swift solution or the Xcode projects. I have submitted a bug report.
Posted Last updated
.
Post not yet marked as solved
3 Replies
146 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 Last updated
.
Post not yet marked as solved
0 Replies
102 Views
Hello, I have a small application already developed in the Cordova/Xcode/swift environment This application was developed to receive the URL of a page viewed in an Internet browser when the user uses the "Share" function of the browser. When sharing my application appears in the list of applications that can potentially receive this data (URL of the page viewed), then my application processes this data (but that's good, no help needed) My need : that my application can receive data when sharing from an APPLICATION or when the sharing function is offered by a site within a page Indeed in these 2 cases, the icon of my application does not appear. I think I need to enable something in my Xcode environment but I don't know where. Thanks
Posted Last updated
.
Post not yet marked as solved
0 Replies
113 Views
I'm trying to create an xcframework for a project that looks roughly like this: CoolLib ├── include │   └── A.h ├── lib │   └── libdep.dylib ├── libA.dylib └── libA.dylib.dSYM    └── Contents    ├── Info.plist     └── Resources    └── DWARF    └── libA.dylib By running this command: xcodebuild -create-xcframework -library ./build/libA.dylib -headers ./build/include -debug-symbols /absolute/path/for/some/reason/build/libA.dylib.dSYM -output CoolLib.xcframework I get a framework that does not include an of the contents of folder lib. This results in my project failing when I try to launch it (but not build it) because of course dyld cannot find the dependencies (which are pointed to using @rpath/lib/libdep.dylib). Is it possible to create an xcframework that includes such dependencies? Thanks
Posted
by frammaa.
Last updated
.
Post not yet marked as solved
0 Replies
114 Views
How to create a scheme that should have the ability to provide public methods that are only accessible to the main application. For example, I have my Main Test project on XCode, I added my custom local Dependency Swift Package SDK, and I want to create a scheme only for access to the swift classes SDK and SDK+TestApp, the main project must not access/could to any other file, I research in the official documentation but are the main example, I'm looking for theses specifically details, any help, please?
Posted Last updated
.
Post not yet marked as solved
0 Replies
118 Views
after upgrading to Ventura started to show this error, no one knows how to fix it? but if you delete Xcode, then this error does not exist, but if you download it back, it appears again dyld[870]: Library not loaded: @rpath/libswiftCore.dylib   Referenced from: <1BF3BE5E-DAD7-3109-B2CF-E336B6CC19D3> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libswift_Concurrency.dylib   Reason: tried: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx/libswiftCore.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libswiftCore.dylib' (no such file), '/usr/local/lib/libswiftCore.dylib' (no such file), '/usr/lib/libswiftCore.dylib' (no such file, not in dyld cache)
Posted
by Haxonate.
Last updated
.
Post not yet marked as solved
2 Replies
607 Views
My team's app has several dependencies on Swift Packages via Swift Package Manager, and uses manual specification of the provisioning profile when built on CI via xcodebuild. This has worked fine for many versions of Xcode through 13.2.1, but with Xcode 13.3 Beta 2 we get an error for each package like this: error: [package name] does not support provisioning profiles. [package name] does not support provisioning profiles, but provisioning profile [profile name] has been manually specified. Set the provisioning profile value to "Automatic" in the build settings editor. (in target '[target name]' from project '[project name]') (The bracketed parts are different for each package.) Our xcodebuild command looks like this: /usr/bin/xcodebuild -sdk iphoneos -configuration Release -workspace [path to workspace] -scheme [scheme name] clean build archive CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY=[redacted] PROVISIONING_PROFILE=[redacted] PROVISIONING_PROFILE_SPECIFIER= (Yes, there is nothing following the last =.) Web search results for that error message are almost always from a few years ago and have to do with CocoaPods, with the fix being in the Podfile. We're not using CocoaPods but rather Xcode's Swift Package Manager integration. We need Xcode 13.3 because it fixes a crash on iOS < 13 when back-deploying async/await code. Anyone else seeing this? Thank you.
Posted
by tthomas.
Last updated
.
Post not yet marked as solved
0 Replies
119 Views
I am currently using swift-log library to output the logs in my application. swift-log -> https://github.com/apple/swift-log Is there a way to write these logs to a file in the same time they comes in console?(like at the end of the day we can see all the log using that created file)
Posted
by Yehen.
Last updated
.
Post not yet marked as solved
4 Replies
163 Views
I was a middleware programmer for a company and a junior one at that. I wrote 95% of my middleware with c#. They did have me do some IOS/Android for them and I used Xamarin just after it came out...this was about 2014 I believe. Fast forward to 2022 and I am not just discovering Swift as well as I have Visual Studio 2022 and I see Xamarin is now native to that IDE since Microsoft owns that platform now. I just wanted to poll the forum and get a feel for what language do you develop your IOS code with mainly and why? I am of course very familiar with c#/.net but my first look at Swift it looks pretty cool! (except I keep trying to put in a ; after a line of code out of habit lol). I appreciate your time, advise and opinions.
Posted Last updated
.
Post marked as solved
1 Replies
125 Views
This is my code, yet on the line let db = Firestore.firestore(), it not working I have added the FirebaseApp.configure and import Firebase at the start. I also followed all instructions in the lessons. Thanks! Any help would be deeply appreciated!
Posted
by srthploid.
Last updated
.
Post not yet marked as solved
0 Replies
127 Views
Hello everyone, I have two different frameworks A and B. Framework A can work as standalone and also can be included in framework B which is also have some unique features. When user using FrameworkB xcframwork, they can avail the framework B methods and also framework if they want as optional. So they don't need to embed frameworkA xcframework if they want functions only from FrameworkB. So the implemented solution is Created Framework A xcframework Craated Framework B and embedded A-xcframework. After generated xcframework for B. After if we try to use FrameworkB-Xcframework in any app, it requires to embed FrameworkA also which is not required by the user. If i am doing the same with normal framework version. it is working fine. But if i do it with xcframework version it is throwing error as No module Found "FrameworkA". Am i missing anything or is this not possible? If it is not possible, is there any other way we can achieve this? Please help me on this
Posted Last updated
.
Post not yet marked as solved
0 Replies
579 Views
I am using XCode 13.1 and wondering a way to execute XCode->File->Packages->Reset Package Cache on terminal. I see my CI machine is failing every time not for specific package but some random package. And when manually do XCode->File->Packages->Reset Package Cache, it resolves the package graph properly. I already tried clearing DerivedData and also clearing /Users/bostonsamddv/Library/Caches/org.swift.swiftpm with no luck :( Any help will be appreciated.
Posted
by AmiBSC.
Last updated
.
Post not yet marked as solved
1 Replies
186 Views
Hi everyone. For example, i want to develop attendance check application. User will come to classroom, then they will use fingerprint reader and my app will check on databases that any match on. (I will register before) Can i use my fingerprint reader for my application? In macos or ios? platform dosen't matter. Thanks in advance.
Posted
by GospaX.
Last updated
.
Post not yet marked as solved
0 Replies
171 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 rwessel.
Last updated
.
Post not yet marked as solved
6 Replies
865 Views
Hi, I am using swiftgen as a prebuild command plugin in one of my internal swift packages to generate a swift file for Translations. When using Xcode cloud to build the project, it is giving me the error, Can not find Translations in scope. It seems Xcode cloud is not able to access the generated file (The file gets generated in context.pluginWorkDirectory in prebuild command plugin and is available in my project when build locally). Has anyone faced a similar issue? Is there any thing I can do to make it work in Xcode Cloud?
Posted Last updated
.
Post marked as solved
3 Replies
266 Views
Xcode always creates targets /schemes for referenced Swift packages. In my app there are 14 Swift packages that are referenced. My app itself has two targets (app and an auto launcher) and Xcode creates targets for two schemes. I don't understand why those schemes are created (and why not for every package). Is there any way to disable this feature? Can someone explain why Xcode creates schemes for referenced Swift packages? I deleted the schemes several times, but Xcode simply recreates them.
Posted
by inexcitus.
Last updated
.
Post not yet marked as solved
0 Replies
201 Views
Hello, in our project we transform SPM to a XCFramework because we also distribute it in pods. We had a lot of problems with the script from SPM to Pods, but finally we got one that worked. We used to had the problem of Swift Version compatibility problems Failed to build module 'selphid_component'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)', while this compiler is 'Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)'). Please select a toolchain which matches the SDK. But we added BUILD_LIBRARY_FOR_DISTRIBUTION=YES and it worked. But right now this problem is happening again. And you only find that the solution is to add that to the Xcode command. We did a lot of research but we can't find what we are doing wrong with this. Are we missing something in the script? Or we are adding things that are wrong. As a curiosity, in the podfile with our libraries we use: post_install do |installer|  installer.pods_project.targets.each do |target|   target.build_configurations.each do |config|    config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'    end   end end but it doesn't work too Maybe the problem is SPM to pod but I saw a lot of projects that they do this but they don't have this problem. We compile with GitHub actions, macos-11, macOS-latest, and even with our Mac, but we are having that compatibility problem. This is the script we use for building from SPM to xcframework. (the part after the archive is because we added the bundle to the xcframework). Thank you for your support and your time, have a good day. for PLATFORM in "iOS" "iOS Simulator"; do case $PLATFORM in "iOS") RELEASE_ARCH="Release-iphoneos" ARCHS=$ARCH_IPHONE ;; "iOS Simulator") RELEASE_ARCH="Release-iphonesimulator" ARCHS=$ARCH_SIMULATOR ;; esac ARCHIVE_PATH=$BUILD_DIR/$RELEASE_ARCH xcodebuild archive -workspace $PROJECT_DIR -scheme $TARGET \ -destination "generic/platform=$PLATFORM" \ -archivePath $ARCHIVE_PATH \ -derivedDataPath $BUILD_DIR \ ARCHS="$ARCHS" \ SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES FRAMEWORK_PATH="$ARCHIVE_PATH.xcarchive/Products/usr/local/lib/$TARGET.framework" MODULES_PATH="$FRAMEWORK_PATH/Modules" mkdir -p $MODULES_PATH BUILD_PRODUCTS_PATH="$BUILD_DIR/Build/Intermediates.noindex/ArchiveIntermediates/$TARGET/BuildProductsPath" RELEASE_PATH="$BUILD_PRODUCTS_PATH/$RELEASE_ARCH" SWIFT_MODULE_PATH="$RELEASE_PATH/$TARGET.swiftmodule" RESOURCES_BUNDLE_PATH="$RELEASE_PATH/${TARGET}_${TARGET}.bundle" # Copy Swift modules if [ -d $SWIFT_MODULE_PATH ] then cp -r $SWIFT_MODULE_PATH $MODULES_PATH else # In case there are no modules, assume C/ObjC library and create module map echo "module $TARGET { export * }" > $MODULES_PATH/module.modulemap perl -lne 'print $1 if /\<'${TARGET}'\/(\S+.h)/' $TARGET/$TARGET .h | \ xargs -I {} find . -name "{}" -print | \ xargs -I {} cp {} $HEADERS_PATH/. cp $TARGET/$TARGET.h $HEADERS_PATH/. fi # Copy resources bundle, if exists if [ -e $RESOURCES_BUNDLE_PATH ] then cp -r $RESOURCES_BUNDLE_PATH $FRAMEWORK_PATH fi done } We create the archive, and finally the xcframework. -framework Release-iphoneos.xcarchive/Products/usr/local/lib/$TARGET.framework \ -framework Release-iphonesimulator.xcarchive/Products/usr/local/lib/$TARGET.framework \ -allow-internal-distribution -output $TARGET.xcframework
Posted Last updated
.
Post marked as solved
1 Replies
185 Views
I have a MacOS package dependency which defines some class: FontPens import Foundation ... public class BoundsPen: Pen { var bounds = CGRect.null private var currentPoint = CGPoint.zero .... After upgrading Xcode to 14.1 both lines throws errors Type 'CGRect' has no member 'null' and Type 'CGPoint' has no member 'zero'. Calling CGPoint.zero and CGRect.null from an app is OK if Foundation is imported. Is it a way to solve this problem without changing package source?
Posted
by ludzik.
Last updated
.