Test failed with error in fastlane

when test is run through fastlane it fails with no such module Alamofire. please advice

> 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 file

# 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

My 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 answer

  • answered 2018-07-18 08:37 whoover

    You should add cocoapods action to your Fastfile. Check documentation https://docs.fastlane.tools/actions/cocoapods/.

    Add to your Gemfile:

    gem "cocoapods"
    gem "fastlane"
    

    And to your 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