AppDelegate.swift中没有此类模块“AWSMobileClient”错误

问题描述 投票:2回答:3

我正在尝试将aws框架​​与本机应用程序相关联。我正在使用cocoapods,我已经在我的Podfile中包含并安装了我需要的依赖项

platform :ios, '9.0'
use_frameworks!

target 'auth' do

    inherit! :search_paths

    pod 'AWSMobileClient'
    pod 'AWSUserPoolsSignIn'
    pod 'AWSAuthUI'
  # Pods for auth

  target 'authTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'auth-tvOS' do

  # use_frameworks!

  # Pods for auth-tvOS

  target 'auth-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

这时,当我在我的import AWSMobileClient文件中的AppDelegate.swift时,我收到了这个错误。

No such module 'AWSMobileClient'

我还不确定是什么导致了此错误,但我还有其他AWS框架不会产生任何错误。这也可以解释为什么app build在xcode中运行时会出现故障。有什么想法吗?

ios swift xcode amazon-web-services aws-mobilehub
3个回答
1
投票

安装pod后,您需要打开.xcworkspace您无法从.xcodeproj访问它们

Here是Xcode项目和Xcode Workspace之间差异的一个很好的总结。


2
投票

我正在使用Xcode 9.2,使用Swift 3.2。起初我会在AppDelegate.swift文件中获得相同的“没有这样的模块'AWSMobileClient'”错误。

我的解决方案

  1. 务必打开.xcworkspace文件
  2. 在项目设置中,转到构建阶段并添加适当的框架。我添加了所有AWS框架,它对我有用。 Here is a Screenshot of Build Phase Settings

1
投票

最重要的是@Stephen Kwan [https://stackoverflow.com/a/48572298/3941896]

我的问题是当我在podfile中复制+粘贴的冗余目标时。它看起来像这样:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target :'RM1' do
    use_frameworks!
    # other pods
    pod 'AWSMobileClient', '~> 2.6.6'
end

target 'RM1' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for RM1

  target 'RM1Tests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'RM1UITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

一旦我合并了2个target: 'RM1',运行pod install就可以了。

© www.soinside.com 2019 - 2024. All rights reserved.