测试失败,fastlane中出现错误

时间:2018-07-18 07:32:52

标签: ios swift unit-testing fastlane

通过快速通道运行测试时,它失败,没有这样的模块Alamofire。请指教

> Compiling Constants.swift

[x] /Users/stevejobs/Documents/Development/Project-G/ProjectG/Repository/UserRepository.swift:10:8: no such module 'Alamofire'

import Alamofire
   ^


> Compiling RegisterViewController.swift

[x] /Users/stevejobs/Documents/Development/Project-G/Project-G/Repository/UserRepository.swift:10:8: no such module 'Alamofire'

import Alamofire
   ^


2018-07-18 12:38:02.160 xcodebuild[3528:114637] Error     Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9r/4z5xs53d3b55jnddyc8bm1g40000gn/T/com.apple.dt.XCTest/IDETestRunSession-DCC3811A-224F-4AA7-9575-906F2900372E/Project-GTests-0A12DD23-88A5-429A-BE87-5DF131B0B53A/Session-Project-GTests-2018-07-18_123759-jw3pTl.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9r/4z5xs53d3b55jnddyc8bm1g40000gn/T/com.apple.dt.XCTest/IDETestRunSession-DCC3811A-224F-4AA7-9575-906F2900372E/Project-GTests-0A12DD23-88A5-429A-BE87-5DF131B0B53A/Session-Project-GTests-2018-07-18_123759-jw3pTl.log}
2018-07-18 12:38:02.160 xcodebuild[3528:114637] Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9r/4z5xs53d3b55jnddyc8bm1g40000gn/T/com.apple.dt.XCTest/IDETestRunSession-DCC3811A-224F-4AA7-9575-906F2900372E/Project-GUITests-0D9C98C0-8BBA-4E97-88D9-157AB4DBDCFD/Session-Project-GUITests-2018-07-18_123759-tAdazU.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9r/4z5xs53d3b55jnddyc8bm1g40000gn/T/com.apple.dt.XCTest/IDETestRunSession-DCC3811A-224F-4AA7-9575-906F2900372E/Project-GUITests-0D9C98C0-8BBA-4E97-88D9-157AB4DBDCFD/Session-Project-GUITests-2018-07-18_123759-tAdazU.log}

Testing failed:
No such module 'Alamofire'
** TEST FAILED **

pod文件

# platform :ios, '9.0'

target 'Project-G' do
 # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Alamofire', '~> 4.5'
pod 'IQKeyboardManagerSwift'
pod 'KVNProgress'

# Pods for Project G

target 'Project-GTests' do
inherit! :search_paths
pod 'Alamofire', '~> 4.5'
pod 'IQKeyboardManagerSwift'
pod 'KVNProgress'
# Pods for testing
end

target 'Project-GUITests' do
inherit! :search_paths
pod 'Alamofire', '~> 4.5'
pod 'IQKeyboardManagerSwift'
pod 'KVNProgress'
# Pods for testing
 end

end


and I don't install pod through fastlane

我的FastFile

class Fastfile: LaneFile {
 func customLane() {
    let itcTeamId = "39941823"
    let username = "iosapp@dreamapps.com"
    let appIdentifier = "com.softence.Project-G"
    let appleId = "iosapp@dreamapps.com"
    let devPortalTeamId = "5PN99X4SDS"
    let scheme = "Project-G"
    let xcodeproj = "Project-G.xcodeproj"

    let versionNumber = getVersionNumber(xcodeproj: xcodeproj)

    cocoapods(
        clean: true,
        repoUpdate: true,
        podfile: "./Podfile",
        tryRepoUpdateOnError: true

    )

    latestTestflightBuildNumber(
        appIdentifier: appIdentifier,
        username: username,
        version: versionNumber,
        teamId: itcTeamId
    )

    let fastlaneContext = laneContext()

    let currentBuildNumber = fastlaneContext["LATEST_TESTFLIGHT_BUILD_NUMBER"] as! Int

    // Incremeting build number
    let newBuildNumber: Int = currentBuildNumber + 1

    incrementBuildNumber(
        buildNumber: String(newBuildNumber),
        xcodeproj: xcodeproj
    )

    buildIosApp(scheme: scheme)

    uploadToTestflight(
        username: username,
        appIdentifier: appIdentifier,
        appleId: appleId,
        teamId: itcTeamId,
        devPortalTeamId: devPortalTeamId
    )
}
}

1 个答案:

答案 0 :(得分:0)

您应该将cocoapods操作添加到Fastfile中。 查看文档https://docs.fastlane.tools/actions/cocoapods/

添加到您的Gemfile中:

gem "cocoapods"
gem "fastlane"

并转到您的Fastfile:

default_platform(:ios)

$XCODEPROJ = 'your_proj_name.xcodeproj'
$TARGET = 'your_target_name'
$SCHEME = 'your_scheme_name'

platform :ios do
    desc 'Builds and archives the project'
    lane :build_only do
    cocoapods(
        clean: true,
        podfile: "./Podfile",
        try_repo_update_on_error: true
    )
    gym
  end
end