Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entitlements error while tests #556

Open
vani2 opened this issue Feb 24, 2023 · 2 comments
Open

Entitlements error while tests #556

vani2 opened this issue Feb 24, 2023 · 2 comments

Comments

@vani2
Copy link

vani2 commented Feb 24, 2023

I have no problem with calling from the main bundle.

But I want to write a unit test, and I've got

OSStatus error:[-34018] Internal error when a required entitlement isn't present, client has neither application-identifier nor keychain-access-groups entitlements.

My project structure is following:

  • Main Bundle
    • Modules (Swift Package)
      • API Target that has KeychainAccess as a dependency.
      • APITests Target where I tried to test class that uses KeychainAccess.

My package file

// 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: "Modules",
    defaultLocalization: "en",
    platforms: [.iOS(.v15)],
    products: [
        .library(
            name: "Modules",
            targets: ["API"]
        )
    ],
    dependencies: [
        .package(url: "[email protected]:kishikawakatsumi/KeychainAccess.git", from: "4.2.0")
    ],
    targets: [
        .target(
            name: "API",
            dependencies: [
                .product(name: "KeychainAccess", package: "KeychainAccess")
            ]
        ),
        .testTarget(
            name: "APITests",
            dependencies: ["API"]
        )
    ]
)

I test at the iPhone Simulatore, Xcode 14.2.
Keychain capability is on.
I also tried #549 (comment) but didn't help.

@NikolaGrujic91
Copy link

NikolaGrujic91 commented Mar 16, 2023

I am experiencing the same problem.

Running unit test in swift package gives the error:

OSStatus error:[-34018] Internal error when a required entitlement isn't present, client has neither application-identifier nor keychain-access-groups entitlements.

Keychain capability is on as well.

Executing the unit test in the app project works. There is a problem with swift package not handling entitlements.

https://forums.swift.org/t/host-application-for-spm-tests/24363

@nakajimayoshi
Copy link

@NikolaGrujic91 @vani2 This is a while after but to anyone reading this, the solution I found was to select a host application in your unit test framework.

Targets->TestFramework->General->Testing->Host Application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants