我使用的是可可豆荚版本1.1.1,swift 3.0.1和Xcode 8.1。我有一个应用程序,它使用可可豆荚像这样(Podfile)cocoa pod:Swift编译器错误“无法导入桥接头”原因?
# 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
而且我有一些客观-C文件还,这就是为什么我用桥接-Header.h文件。
//
// Use this file to import your target's 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"
当我运行TestApp时,它完美运行。但是我运行单元测试用例,在TestAppTests上出现错误 - > Swift编译器错误 - >无法在#import“GoogleAnalytics/GAI.h”中导入桥接头“TestApp-Bridging-Header.h”未找到。
我解决这个问题,使用上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
我只是想知道下面提点,当我的代码迁移到斯威夫特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?
请解释原因。
为什么我把同样的吊舱在两个目标,此前它的正常工作。 –
我想你可以将目标从Xcode添加到如果你不想使用pod添加。 –