【问题标题】:Unable to import GoogleMaps into framework in Xcode 7无法将 GoogleMaps 导入 Xcode 7 中的框架
【发布时间】:2015-07-17 19:00:24
【问题描述】:

我有一个新项目,我正在使用通过 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,而我的内部框架却找不到。

提前致谢!

【问题讨论】:

    标签: ios cocoapods google-maps-sdk-ios swift2 xcode7-beta3


    【解决方案1】:

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

    即使我手动将 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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 2019-05-22
      • 2014-11-11
      • 1970-01-01
      • 2015-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多