Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift Unit Test Error - framework not found AWSCore for architecture i386

I have Swift 2.3 project working fine with AWS Libraries. I just tried to create a sample unit test for this and I get this error. It seems my unit test class cannot find the frameworks I installed using a Podfile

This is the unit test class

import XCTest
import UIKit
@testable import safetyv1


class OffenceFormVCTests: XCTestCase {
    
    var vc:OffenceFormVC!
    
    override func setUp() {
        super.setUp()
        // called first
        vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("OffenceFormVC") as! OffenceFormVC
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    
    
}

This is the error I get when I do Product > Build for > Testing enter image description here

And my build settings enter image description here

Podfile
enter image description here

Anyone knows how to fix this issue? Thanks a lot!

like image 271
stackflow Avatar asked Sep 30 '16 07:09

stackflow


2 Answers

I had the same problem it seems to be an easy fix. Just add your testing target in your podfile as another target withe same pods.

Your podfile should contain something like this:

target: 'safetyv1Tests' do
   pod 'AWSCore' 
   pod 'AWSS3' 
end 

For Carthage you need to add the frameworks to the test target

Greetings, Alex

like image 157
Sn0wfreeze Avatar answered Oct 09 '22 00:10

Sn0wfreeze


I issue the exact same problem and pass one day to find the answer.

Problem is that when you add your project with cocoapod, you add pod to your project only.

So to solve this issue you need to add this in your PodFile:

target :'YourPojectTests' do
pod 'AWSAutoScaling'
pod 'AWSCloudWatch'
pod 'AWSCognito'
pod 'AWSCognitoIdentityProvider'
pod 'AWSDynamoDB'
pod 'AWSEC2'
pod 'AWSElasticLoadBalancing'
pod 'AWSIoT'
pod 'AWSKinesis'
pod 'AWSLambda'
pod 'AWSMachineLearning'
pod 'AWSMobileAnalytics'
pod 'AWSS3'
pod 'AWSSES'
pod 'AWSSimpleDB'
pod 'AWSSNS'
pod 'AWSSQS'
end

and replace "YourProjectTests" by your project tests name bundle

Just need to do :

pod update

And open your project.workspace on Xcode to get it working.

Safe check is to go in your projecNameTests settings and check that all -framework are set in linker section as shown like in yourProject settings

Enjoy

like image 41
JP Lno Avatar answered Oct 08 '22 22:10

JP Lno