使用 Cocoapods 在 Pod Spec Test 的 App Host 中指定权利

bjt*_*tus 5 cocoapods

我有一个使用 iOS 钥匙串的 pod,并围绕此功能编写了测试。requires_app_host = true我已通过在测试规范中指定来指定我需要一个应用程序主机。钥匙串功能无法工作并出现以下错误:

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

看起来该应用程序可能需要具有application-identifierkeychain-access-groups(共享钥匙串)集之一的权利。有什么方法可以将其添加到应用程序主机目标中吗?

小智 3

您可以创建自定义 app_spec 并将其指定为 app_host 以进行测试。之后,您可以配置该目标的权利

例如:


  s.test_spec 'Tests' do |t|
    t.source_files = [
      'MyLibrary/Tests/*.swift',
    ]
    
    t.requires_app_host = true
    t.app_host_name = 'MyLibrary/Example'
    t.dependency 'MyLibrary/Example'    
  end

  s.app_spec 'Example' do |app_spec|
      app_spec.source_files = 'Example/*.swift'
      app_spec.xcconfig = {
          'CODE_SIGN_ENTITLEMENTS' => 'MyLibrary/Extension.entitlements'
      }
  end
Run Code Online (Sandbox Code Playgroud)