4

我有一个新项目,我正在使用通过 cocoapods 导入的 GoogleMaps 使用 XCode 7 beta 3 和 Swift 2.0。这是一个 WatchKit 2.0 应用程序,所以我有一个 iPhone 的主要目标(目的地)、一个 Apple Watch 的目标(目的地 WatchKitApp 和目的地 WatchKitExtension)和一个内部框架(目的地Kit),它负责与 GoogleMaps 交互其他事情。

我可以成功地将 GoogleMaps 导入到主要目标(目的地)并成功显示地图。

import UIKit
import DestinationsKit
import GoogleMaps

class DestinationDetailsViewController : UIViewController
{
    // our selected destination
    var destination: Destination!

    // our map view
    var mapView : GMSMapView!

    // ... code to display a map centering on the destination ...
}

上面的代码导入了我的内部框架 DestinationsKit,并成功使用了 GoogleMaps。

但是,我现在正在编写计算两点之间路线的代码,并将该代码添加到内部框架 (DestinationsKit)。每当我尝试导入 GoogleMaps 时,我都会收到“没有这样的模块 'GoogleMaps'”。

import Foundation
import CoreLocation
import GoogleMaps  // Error 'No such module 'GoogleMaps''

public class UserTrip {   
}

我做了以下没有成功:

  • 'In Build Phases' -> 'Link Binary With Libraries',我添加了 Pods.Framework (这是我在主要目标中成功所做的)
  • 将“允许框架模块中的非模块化包含”设置为是
  • 在构建设置中将“打包”->“定义模块”设置为“是”

我的 Pods 文件如下:

source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

pod 'GoogleMaps'

我确保 Pods.Framework 包含在两个目标中。因此,我无法弄清楚为什么主要目标可以找到 GoogleMaps,但我的内部框架却找不到。

提前致谢!

4

1 回答 1

2

当然,一旦我发布问题,我就会找出原因。

即使我手动将 Pods.framework 添加到构建阶段,我也需要更新我的 Pods 文件以将框架包含为目标,然后再次运行“pod install”。因此,更新后的 Pods 文件为:

source 'https://github.com/CocoaPods/Specs.git'

# We need to link with all targets. If target is added, this must be updated

use_frameworks!

pod 'GoogleMaps'

link_with 'Destinations', 'DestinationsKit'

target 'Destinations' do
end

target 'DestinationsKit' do
end

不确定“目标”行是否是必要的,但最好包含这样特定于目标的依赖项有一个家。

于 2015-07-17T19:21:58.070 回答