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

185 results found
Sort by:
Post not yet marked as solved
101 Views

SwiftUI Preview don't work in Package with dependencies

Hi, I using packages to modularize my app's features, so my package contains Views. I'm unable to get the preview working in from any of my packages. SwiftUI preview is complaining that it couldn't find the dependency module. MessageSendFailure: Message send failure for send previewInstances message to agent ================================== | RemoteHumanReadableError | | LoadingError: failed to load library at path "/Users/karthik/Library/Developer/Xcode/DerivedData/WWoC-eovhbulekrmpsfbtdmwyilxornun/Build/Intermediates.noindex/Previews/WWoC/Products/Debug-iphonesimulator/PackageFrameworks/Groups.framework/Groups": Optional(dlopen(/Users/karthik/Library/Developer/Xcode/DerivedData/WWoC-eovhbulekrmpsfbtdmwyilxornun/Build/Intermediates.noindex/Previews/WWoC/Products/Debug-iphonesimulator/PackageFrameworks/Groups.framework/Groups, 0x0000): Library not loaded: @rpath/UIConvenience.framework/UIConvenience | Referenced from: /Users/karthik/Library/Developer/Xcode/DerivedData/WWoC-eovhbulekrmpsfbtdmwyilxornun/Build/Intermediates.noindex/Previews/WWoC/Products/Debug-iphonesimulator/PackageFrameworks/Groups.framework/Groups | Reason: tried: '/Users/karthik/Library/Developer/Xcode/DerivedData/WWoC-eovhbulekrmpsfbtdmwyilxornun/Build/Intermediates.noindex/Previews/WWoC/Products/Debug-iphonesimulator/UIConvenience.framework/UIConvenience' (no such file), '/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/UIConvenience.framework/UIConvenience' (no such file)) I noticed that that the preview starts to work as soon as I remove all the dependencies on a package. It looks like SwiftUI preview is not working for the packages with dependencies. I'm seeing this bug in Xcode 12.5 and in Xcode 13.0 beta 2 ss well. Can some please help me with this bug. At least please confirm if, at all, this feature is implemented in Xcode.
Asked Last updated
.
Post not yet marked as solved
19 Views

-ObjC linker flag causing build errors with Swift packages?

I'm converting an existing iOS framework to a Swift package; it is being consumed by an IOS app. The Swift package (which contains a mix of Obj-C, Obj-C++, and C++) compiles and I can run unit tests against it. When I try building the app and link against the package, I get a very large number of "duplicate symbol" errors, where the symbols in question are also found in other packages consumed by the app. What I don't understand is that most of these symbols should be completely hidden. In one example from the new package, I have essentially the case below (simplified here): // MyFile.h //(include guards) int doSomething(); // MyFile.cpp #include "MyFile.h" int localFunction() { int result = 0; // do some processing, set result to 0 or 1; return result; } int doSomething() { // do some processing // ... // check an intermediate result if (localFunction() == 0) { return 0; } // do some other stuff return 1; } and yet localFunction is reported as one of the duplicate symbols, because another Swift Package uses the same source file, where that symbol should also be completely hidden. The client app sets the -ObjC linker flag; I have seen where this causes the same (or at least very similar) behavior and was considered a bug (https://developer.apple.com/forums/thread/106694). I am using Xcode 13 Beta and Xcode 13.2 beta, and get the same issue with both. Bug in Xcode? Flaw in my handling/understanding? (Is this related to the ObjC flag, and correctly so?)
Asked
by fish36.
Last updated
.
Post not yet marked as solved
1.8k Views

Can’t archive App that uses a swift package with an xcframework

Hello, We have a situation where: we have a library A distributed as an xcframework. this library A is used in a swift package B that includes it as a binary target. our final iOS App uses our swift package B with swift package manager. We first had issues with code signing and solved it by adding a build phase that code sign the framework A when building the App. Now everything is fine when running in debug but when trying to archive the App, We have a compilation error saying Xcode doesn’t find the framework A.. we try a lots of different setup but didn’t find any solution to fix this compilation error. Any idea on how we could solve this issue? Thanks!
Asked
by zocario.
Last updated
.
Post not yet marked as solved
309 Views

Archive validation error with Binary Swift Package and Appex

I am trying to include a binary swift package dependency in my app to upload to App Store connect. When doing so the framework is embedded in the app which is fine, unless I also want to use that dependency in an App Extension or an embedded App Clip. In those cases when I archive the framework is embedded in the extension and app clip as well which leads to the following errors during validation. CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'com.company.frameworkName-Dynamic' under the iOS application 'MyApp.app' Invalid Bundle. The bundle at 'MyApp.app/Plugins/MyAppExtension.appex' contains disallowed nested bundles. Invalid Bundle. The bundle at 'MyApp.app/Plugins/MyAppExtension.appex' contains disallowed file 'Frameworks' This issue has existed since at least Xcode 12.1 reported here in the Swift forums: https://forums.swift.org/t/swift-package-binary-framework-issue/41922 The XCFramework binary Swift Package archive was built and distributed using Xcode 12.5 build tools with Swift 5.4 tools in the Swift package. The archive is also built and validated using Xcode 12.5
Asked
by emawby.
Last updated
.
Post not yet marked as solved
25 Views

CI tests failing with "Could not compute signing task inputs"

My CircleCI workflow has started failing with an error I can't seem to find any documentation for: Could not compute signing task inputs - operation was cancelled. ... and then a reference to a 3rd party library's product, eg.: (in target 'Appboy_iOS_SDK_AppboyKit' from project 'Appboy_iOS_SDK'). I'm using SPM to manage dependencies and I'm trying to modularize my Xcode project by adding a local SPM package. Below is the relevant part of the CircleCI output. I can't seem to figure out what these errors are referring to and they don't seem to occur when I remove UI tests from the scheme, so I'm assuming this has something to do with the "Copy Bundle Resources" step of the "MyAppUITests" target. Any help would be much appreciated. Xcode version: 12.5.1 [00:00:45]: Running Tests: ▸ Touching MyApp.app (in target 'MyApp' from project 'MyApp') [00:00:45]: ▸ Build Succeeded [00:00:45]: ▸ 2021-07-22 00:00:45.521 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa5036121a0> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:45]: ▸ 2021-07-22 00:00:45.526 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa50305bb20> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:45]: ▸ 2021-07-22 00:00:45.531 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa50306a230> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:45]: ▸ 2021-07-22 00:00:45.536 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa503076680> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:45]: ▸ 2021-07-22 00:00:45.549 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa503660a10> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:45]: ▸ 2021-07-22 00:00:45.555 xcodebuild[1629:69156] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-18212/IDEFoundation/Testing/IDETestRunSpecificationBuilder.m:678 [00:00:45]: ▸ Details: Failed to compute path to baseline file during test run spec construction: <XCTHTestRunSpecification: 0x7fa50366c6a0> [00:00:45]: ▸ Object: <IDETestRunSpecificationBuilder> [00:00:45]: ▸ Method: +testRunSpecificationsForTestingSpecifiers:scheme:buildables:withBuildParameters:additionalEnvironmentVariables:additionalCommandLineArguments:testRerunPolicy:includeClangProfileParameters:shouldDebugAppExtensions:error: [00:00:45]: ▸ Thread: <NSThread: 0x7fa4f9618f70>{number = 1, name = main} [00:00:45]: ▸ Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide. [00:00:51]: ▸ ❌ error: Could not compute signing task inputs - operation was cancelled. (in target 'Appboy_iOS_SDK_AppboyKit' from project 'Appboy_iOS_SDK') [00:00:51]: ▸ ❌ error: Could not compute signing task inputs - operation was cancelled. (in target 'Appboy_iOS_SDK_AppboyUI' from project 'Appboy_iOS_SDK') [00:00:51]: ▸ ❌ error: Could not compute signing task inputs - operation was cancelled. (in target 'Mixpanel_Mixpanel' from project 'Mixpanel') [00:00:52]: ▸ Testing failed: [00:00:52]: ▸ Could not compute signing task inputs - operation was cancelled. [00:00:52]: ▸ Testing cancelled because the build failed. [00:00:52]: ▸ ** TEST FAILED **```
Asked
by SweetDee.
Last updated
.
Post not yet marked as solved
377 Views

Cannot find swift package module in release build

I have created a swift package and successfully added some stub code, imported into another class import PackageName This all works as expected when building in debug configuration. When I try to build for release using xcodebuild, it fails with "no such module : PackageName" Is there something missing that dictates how a package works in different configurations? Thanks
Asked
by SSMCTech.
Last updated
.
Post not yet marked as solved
26k Views

IPHONEOS_DEPLOYMENT_TARGET is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99

Hi, I'm getting warning in my Swift package where one of external dependency supports from iOS8.0, is it as bug in xcode or do we need to ask 3rd party developer to remove iOS8.0 supports, i believe they need to support library in cocoapods for iOS8.0 as well Warning: IPHONEOSDEPLOYMENTTARGET is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99 Forum thread: https://forums.swift.org/t/unable-to-import-multiple-targets-from-external-dependency/39030/3
Asked Last updated
.
Post not yet marked as solved
370 Views

Xcode Previews don't work with Package that includes a .binaryTarget

I am working on rebuilding our large app's dependency graph to use Swift Package Manager, replacing CocoaPods. I have it nearly done and am quite happy with the progress so far. However, I've run into a blocker with Xcode's SwiftUI Previews not working, seemingly due to several .binaryTarget dependencies. I've boiled this down to a simple reproducible case, with this Package.swift: let package = Package( name: "MyLibrary", platforms: [.iOS(.v13)], products: [.library(name: "MyLibrary", targets: ["MyLibrary"]),], dependencies: [], targets: [ .target(name: "MyLibrary", dependencies: ["NewRelic"]), .binaryTarget(name: "NewRelic", url: "https://download.newrelic.com/ios_agent/NewRelic_XCFramework_Agent_7.3.0.zip", checksum: "daaaff7897246e4baddb1b8131a79268de3b6889a48182b4fbdabe5b926d08f4"), ] ) Here I am using NewRelic as a common 3rd party dependency that vends an .xcframework.zip-- but this is not specific to NewRelic and can be reproduced with many (any?) similar examples. This package builds a library successfully and works as expected when included in an app. But when I try to use SwiftUI previews on a trivial view, e.g.: struct MyLibraryView: View { var body: some View { VStack { Text(verbatim: "Hello World, I'm MyLibraryView") } } } struct MyLibrary_Previews: PreviewProvider { static var previews: some View { return MyLibraryView() } } I end up with this Unexpected duplicate tasks build failure, due to the build system seemingly trying to process the XCFramework twice: note: Using new build system note: Building targets in parallel note: Planning build note: Using build description from memory note: Using build description 'e8ea061fcc823688d24edc3f230a0c7c' note: Build preparation complete note: Target dependency graph (3 targets) MyLibrary in MyLibrary MyLibrary in MyLibrary, depends on: MyLibrary in MyLibrary (explicit) MyLibrary in MyLibrary, depends on: MyLibrary in MyLibrary (explicit) error: Unexpected duplicate tasks: 1) Command: ProcessXCFramework /Users/mthole/Library/Developer/Xcode/DerivedData/DuplicateTasksOnPreview-bkclfnyhkfofwaaulhpstpdjggqb/SourcePackages/artifacts/DuplicateTasksOnPreview/NewRelic.xcframework ios simulator 2) Command: ProcessXCFramework /Users/mthole/Library/Developer/Xcode/DerivedData/DuplicateTasksOnPreview-bkclfnyhkfofwaaulhpstpdjggqb/SourcePackages/artifacts/DuplicateTasksOnPreview/NewRelic.xcframework ios simulator I've posted the reproduction case on GitHub here. Tested with Xcode 12.5 Beta 3. https://github.com/mthole/DuplicateTasksOnPreview
Asked
by MichaelT.
Last updated
.
Post not yet marked as solved
50 Views

Export Localizations vs Swift Packages

In regular projects, there is an "Export Localizations" option in the Product menu, but for Swift Packages, this is not available. Adding local Swift Packages as dependencies of a regular project and using Export Localizations on the regular project doesn't include the Localizable strings from the Packages' sources either. The command-line version (xcodebuild -exportLocalizations) has the same restrictions. Is there a way to export NSLocalizedString occurrences to an xliff for Swift Packages? Or are we supposed to do things manually for now?
Asked Last updated
.
Post marked as solved
400 Views

SwiftUI preview failing with failedToGenerateThunkInfo

I have an iOS app by using a swift package to hold most of the logic. However, the previews of SwiftUI views often fail with following error: HumanReadableSwiftError BuildError: failedToGenerateThunkInfo(Error Domain=com.apple.xcbuild Code=19 "could not generate preview info: noTargetBuildGraph" UserInfo={NSLocalizedDescription=could not generate preview info: noTargetBuildGraph}) To reproduce this, please clone https://github.com/pointfreeco/isowords and check for preview of ChangelogView.
Asked
by surajb.
Last updated
.
Post not yet marked as solved
66 Views

Swift Package Manager, target based dependency

I wonder if its possible to get target based dependency using Swift Package Manager without Xcode resolving all dependency in package. I have a package like this: // swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "ReCaptcha", platforms: [ .iOS(.v9) ], products: [ .library( name: "ReCaptcha", targets: ["ReCaptcha"]), .library( name: "ReCaptchaRx", targets: ["ReCaptchaRx"]) ], dependencies: [ .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "6.0.0"), .package(url: "https://github.com/JakubMazur/AppSwizzle.git", from: "1.3.2"), ], targets: [ .target( name: "ReCaptcha", dependencies: [], path: "ReCaptcha/Classes", exclude: ["Rx"], linkerSettings: [ .linkedFramework("UIKit") ] ), .target( name: "ReCaptchaRx", dependencies: [ "ReCaptcha", .product(name: "RxSwift", package: "RxSwift") ], path: "ReCaptcha/Classes/Rx", linkerSettings: [ .linkedFramework("UIKit") ]), .testTarget( name: "ReCaptcha_Tests", dependencies: ["ReCaptcha", "AppSwizzle"], path: "Example/ReCaptcha_Tests", exclude: ["Info.plist"], resources: [ .copy("mock.html") ]) ] ) So it contains RxSwift as a dependency to 1 of 2 targets. So what I wanted to happen is that if I import only one target: This will NOT resolve RxSwift in project Instead it's getting resolved but it's anyway unavailable to import: Original autor of this library using AppSwizzle library for testTarget and then it's not getting resolved as expected, but why then importing only target without dependency resolve dependency to other target? This is open source, so code is available: https://github.com/JakubMazur/ReCaptcha/pull/1
Asked
by jkmazur.
Last updated
.
Post not yet marked as solved
199 Views

[Regression][Xcode 13.0b3]: a normal target in a linked SwiftPM library is treated as an app extension

Feedback ID: FB9337463 Hello, When compiling our application, I see the following problem reproduced with the attached sample example (modified the following repository sample as the problem happens in this library: https://github.com/ephread/Instructions.git ): $HOME/Library/Developer/Xcode/DerivedData/Instructions_Example-hhbleavuawdnqpbogvbuddnqmepj/SourcePackages/checkouts/Instructions/Sources/Instructions/Core/Public/CoachMarksController.swift:215:48: error: 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead. if let windowScene = UIApplication.shared.activeScene { Note that this was not happening in our app or this sample project with Xcode 13.0 beta 2, it started happening today when I updated to Xcode 13.0 beta 3). Thank you in advance for your help :)! Kind Regards, Goffredo Marocchi Sample projects (archive): https://www.icloud.com/iclouddrive/0rc9JcVxDKFF6I8hfzZ7_6KLQ#SampleIssue%5FProj Kind Regards, Goffredo
Asked Last updated
.
Post not yet marked as solved
175 Views

Use a C lib in Swift Package Manager

Hello, I'm trying create a Package that uses a library called tidy-html5. I've successfully created the package, however since I'm using homebrew as a provider, the dylib that gets created is only for x86 architecture. And ideally I would like to have it universal (ie also for iOS). Is there a way to do this? I manually created a universal dylib, but I'm not sure if I can add that as a dependency for SPM? Thanks in advance.
Asked
by Taxxodium.
Last updated
.
Post not yet marked as solved
2.1k Views

Xcode 12 git with "ssh://" and private key still broken

When I use my repository with an "ssh://" URL and a private/public key, Xcode throws a "username does not match previous request (-1)" error. command line git (and every other GUI Git tool I tried) work without problems. Unfortunately this is also a problem for Swift Packages making them unusable for me. Before you ask: Of course "swift package …" works without problems on the command line. The problem exist consistently on every Xcode 12 version so far including Xcode 12b3. Seems like the devs put a bad git library into Xcode and now just leave it like that.
Asked
by Roddi.
Last updated
.
Post not yet marked as solved
235 Views

[Swift Package Manager] [Xcode] XCFramework has different behaviour when integrated manually vs SPM

Hey, I found a different behaviour when integrating a XCFramework manually vs with SPM. When I add the XCFramework directly to Xcode, it recognises it as a XCFramework, and allows me to embedded or not. When I add a XCFramework via Swift Package Manager to the Xcode project, using a binary target, the Xcode recognises it as a static library, and I can't choose if I want to embedded it or not. Example: https://github.com/twilio/twilio-video-ios Is this a bug? Is this related to Xcode or SPM? Thanks EDIT: let me give a bit more context. I'm developing a XCFramework, let's call it MyFramework. MyFramework depends on TwilioVideo (which is also a XCFramework). To avoid the problem of nested Frameworks or umbrella Frameworks, I need to integrate TwilioVideo in MyFramework with the option "Do Not Embed". This way, I will only ship MyFramework, and when someone consume MyFramework, will also need to integrate TwilioVideo. This is what Apple recommends. The problem is that when I'm compiling MyFramework integrated with TwilioVideo directly via Xcode or integrated via SPM on Xcode produces different results. When I integrate TwilioVideo directly on Xcode, it works great, it recognises TwilioVideo as a XCFramework and gives the me option "Do Not Embed", which is the correct behaviour. When I integrate TwilioVideo on Xcode via SPM, Xcode thinks that TwilioVideo is a static library, which is wrong, and doesn't allow me to choose the option "Do Not Embed". This means that MyFramework end up being an umbrella framework which is discouraged by Apple. Check the title "Don’t Create Umbrella Frameworks". https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/CreationGuidelines.html Since it produces different behaviours when integrating the same XCFramework directly via Xcode or via SPM, I think this is a bug or some kind of limitation.
Asked
by bcm1.
Last updated
.