Cocoa pod: Swift compiler error "Error connecting to bridge" error?

I am using cocoa pod version 1.1.1, swift 3.0.1 and Xcode 8.1. I have an application that uses cocoa pod like this (Podfile)

# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
platform :ios, '8.0'
use_frameworks!

target 'TestApp' do
    pod 'GoogleAnalytics', '~> 3.14.0'
end

target 'TestAppTests' do
    pod 'Quick'
    pod 'Nimble'
end

And I also have an objective-C file, so I used the Bridging-Header.h file.

//
//  Use this file to import your target public headers that you would like to expose to Swift.
//

#import <CommonCrypto/CommonCrypto.h>

#import <GoogleAnalytics/GAI.h>
#import <GoogleAnalytics/GAIFields.h>
#import <GoogleAnalytics/GAIDictionaryBuilder.h>
#import <GoogleAnalytics/GAILogger.h>

#import <CoreBluetooth/CoreBluetooth.h>

#import "AModel+Level.h"
#import "AModel+AutoStatus.h"
#import "AModel+Settings.h"
#import "APacketData+Decoders.h"
#import "Reachability.h"

When I run TestApp, it works fine. But I run unit test cases, I got an error in TestAppTests → Swift compiler error → Failed to import the header title “TestApp-Bridging-Header.h” into #import “GoogleAnalytics / GAI.h” not found.

I fix this problem using this technique in podfile:

platform :ios, '8.0'
use_frameworks!

target 'TestApp' do
    pod 'GoogleAnalytics', '~> 3.14.0'
end

target 'TestAppTests' do
    pod 'GoogleAnalytics', '~> 3.14.0'
    pod 'Quick'
    pod 'Nimble'
end

I just want to find out below the mention of points when I port the code in Swift 3.0.1:

1. Is it require to install every pods in different targets? or we have any alternate solution.
2. What is the best technique to handle this kind of problems?

Please explain the reasons.

+4
2

unit test , cocoapods . , , .

platform :ios, '8.0'
use_frameworks!

target 'TestApp' do
    pod 'GoogleAnalytics', '~> 3.14.0'
end

target 'TestAppTests' do
    pod 'GoogleAnalytics', '~> 3.14.0'
    pod 'Quick'
    pod 'Nimble'
end

1. ? .

, .

2. ?

.

, , .

+1

. .

, , :

target 'MyTarget' do

  pod 'somePod'
  pod 'somePod2'

  target 'MyTargetTests' do
      inherit! :search_paths

      pod 'somePod2'
  end
end
0

Source: https://habr.com/ru/post/1660493/


All Articles