首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xcode 10 UI测试原因: Cocoapods找不到图像

Xcode 10 UI测试原因: Cocoapods找不到图像
EN

Stack Overflow用户
提问于 2018-10-05 16:27:53
回答 3查看 2.6K关注 0票数 3

我试图在我的应用程序中运行UI测试,但是一旦模拟器启动,我就会得到:

包“AppUITests”无法加载,因为它已损坏或缺少必要的资源。试着重新安装包。

2018-10-05 11:04:59.772078-0500应用程序-Runner53273:1645870

我的UITest是Xcode 10创建的模板,我使用Cocoapods 1.5.3和SWIFT4.2

我的项目结构:

  • 工作区
    • 自定义框架( Podfile在这里)
    • 应用程序A(这里我正在运行UITests)
    • App

我的文件看起来是这样的:

代码语言:javascript
复制
platform :ios, '10.0'

inhibit_all_warnings!
use_frameworks!

target 'App Library' do
    use_frameworks!

    pod 'Intercom'
    pod 'Spreedly'
    pod 'Alamofire'
    pod 'IGListKit'
    pod 'CardIO'
    pod 'SwiftKeychainWrapper'
    pod 'OneTimePassword', :git =>   'https://github.com/john/OneTimePassword.git', :branch => 'develop'
    pod 'SnapKit'
    pod 'DateToolsSwift'
    pod 'BetterSegmentedControl'
    pod 'SDWebImage'
    pod 'SwiftLocation'
    pod 'Nuke'
    pod 'Instabug'
    pod 'Mixpanel-swift'


    target 'App LibraryTests' do
        inherit! :search_paths
        # Pods for testing
    end

    target 'App' do
        project '../App/App'
        inherit! :complete

        use_frameworks!

        pod 'FacebookCore'
        pod 'FacebookLogin'

        target 'AppTests' do
            inherit! :search_paths
            # Pods for testing
        end
    end

    target 'App Business' do
         project '../App Business/App Business'
         inherit! :complete

         use_frameworks!

         target 'App BusinessTests' do
             inherit! :search_paths
             # Pods for testing
         end

         target 'App BusinessUITests' do
             inherit! :search_paths
             # Pods for testing
         end
     end

end

# The UI Test target I'm trying to run
target 'AppUITests' do
     inherit! :search_paths
     use_frameworks!
     # Pods for testing
     project '../App/App'
     pod 'Intercom'
     pod 'Spreedly'
     pod 'Alamofire'
     pod 'IGListKit'
     pod 'CardIO'
     pod 'SwiftKeychainWrapper'
     pod 'OneTimePassword', :git => 'https://github.com/john/OneTimePassword.git', :branch => 'develop'
     pod 'SnapKit'
     pod 'DateToolsSwift'
     pod 'BetterSegmentedControl'
     pod 'SDWebImage'
     pod 'SwiftLocation'
     pod 'Nuke'
     pod 'FacebookCore'
     pod 'FacebookLogin'
     pod 'Instabug'
     pod 'Mixpanel-swift'
end

workspace '../app-ios-client'

我尝试过用!inherit:complete!inherit:search_paths将UI测试目标放在目标应用程序中,并将其移到外面,就像上面发布的代码一样。我还清理了构建文件夹,删除了派生数据并重新启动了Xcode,我仍然存在这个问题。我也尝试过添加import UIKitimport Alamofire,但是没有什么效果。在所有这些可能的修复之间,我运行了pod deintegratepod install。我认为问题可能与podfile在我的自定义框架内有关,但老实说,我不知道。有什么想法吗?谢谢!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-10-05 17:21:48

我通过将podfile中的目标更改为:

代码语言:javascript
复制
target 'AppUITests' do
    inherit! :search_paths
    use_frameworks!
    # Pods for testing
    project '../App/App'
end
票数 2
EN

Stack Overflow用户

发布于 2019-12-17 00:48:24

我的修补程序与https://stackoverflow.com/a/54034832/883413类似,只是我没有费心使用post_install部分。

以前,我的podfile结构类似于问题中的结构:

代码语言:javascript
复制
platform :ios, '10.0'

target 'AppName' do
  use_frameworks!
  
  pod 'PodName'

  target 'AppNameTests' do
    inherit! :search_paths
  end

  target 'AppNameUITests' do
    inherit! :search_paths
  end
end

改为(更新的?)这样的结构解决了这个问题:

代码语言:javascript
复制
platform :ios, '10.0'
use_frameworks!

def all_pods
  pod 'PodName'
end

target 'AppName' do
  all_pods
end
  
target 'AppNameTests' do
  inherit! :search_paths
  all_pods
end

target 'AppNameUITests' do
  inherit! :search_paths
  all_pods
end
票数 5
EN

Stack Overflow用户

发布于 2019-01-04 07:40:09

除了添加inherit!:search_paths之外,还可以尝试

还可以在ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES中更改post_install

代码语言:javascript
复制
use_frameworks!

def shared_pods
    pod 'SomePod'
end

target 'App_name' do
    shared_pods
end

target 'App_nameTests' do
    inherit! :search_paths
    shared_pods
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
        end
    end
end
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52669835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档