OGeek|极客世界-中国程序员成长平台

标题: ios - 如何为 iOS 扩展定义 pod 文件 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:46
标题: ios - 如何为 iOS 扩展定义 pod 文件

当如下定义我的 Podfile,然后使用我的扩展构建我的应用程序时,我在 DKImagePickerController 框架中遇到构建错误,错误类似于:Error "'sharedApplication' is unavailable: not available on iOS (App Extension)...." when compiling after pod update

如您所见,我没有在我的 Podfile 的扩展目标中包含 DKImagePickerController 框架,所以我想知道我做错了什么?

 platform :ios, '10.0'
    def base_pods
      pod 'Firebase/Core'
      pod 'Firebase/Auth'
      pod 'DKImagePickerController', '~> 3.4.0'
      ...
      pod 'SAMKeychain'
    end

target 'MyApp' do

  use_frameworks!
  base_pods

  target 'MyAppExtension' do
    pod 'Firebase/Auth'
    pod 'SAMKeychain'
  end

  target 'MyAppUnitTests' do
        inherit! :search_paths
        pod 'Firebase'
        pod 'FirebaseAuth'
        pod 'FirebaseUI/Auth'
  end
end

更新

我很感激由于 API 不可用而收到错误,我想弄清楚的是如何避免它。我怀疑我的播客文件,因此我的问题



Best Answer-推荐答案


我遇到了同样的问题,所以对于找到此线程的其他人,我能够通过创建两个顶级目标而不是使用嵌套目标来解决问题。

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

  # Pods for MyApp
  pod 'Eureka', '~> 3.0'
  pod 'ChameleonFramework', '~> 2.0'
  pod 'SharedPod', '~>1.0'

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

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

target 'MyApp Today' do
  use_frameworks!
  # inherit! :none
  # Pods for MyApp Today
  pod 'SharedPod', '~>1.0'
end

为了有个干净的开始,我跑了......

pod deintegrate
-- Then cleaned out the project file in XCode
pod install

关于ios - 如何为 iOS 扩展定义 pod 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41778458/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4