【问题标题】:How to import cocoapod into Xcode 7.3?如何将 cocoapod 导入 Xcode 7.3?
【发布时间】:2016-06-02 17:13:00
【问题描述】:

我浏览了许多指南,它们似乎都指向对 podfile 使用“link_with”命令,就像本教程一样:

https://littlebitesofcocoa.com/138-using-cocoapods-in-xcode-playgrounds

但是,当我尝试这个时,cocoapod 似乎不喜欢我的 podfile 的语法,并且会告诉我现在不支持 'link_with' 并且它似乎将游乐场文件的名称解释为 podfile。

target 'Jawn’ do
  link_with 'UrlMetaData'             <----- (UrlMetaData.playground)
  use_frameworks!
  platform :ios, '8.4'
  pod 'Kanna', '~> 1.0.0'
  pod 'SlackTextViewController'
  pod 'M13ProgressSuite'
  pod 'Alamofire', '~> 3.4'
  pod 'YouTubePlayer'
  workspace 'Jawn'
end

当我执行 pod install 时,我会得到以下输出:

My-iMac:MyProject USERNAME$ pod install

[!] Invalid `Podfile` file: [!] The specification of `link_with` in the Podfile is now unsupported, please use target blocks instead..

 #  from /Users/USERNAME/Xcode Projects/MyProject/Podfile:2
 #  -------------------------------------------
 #  target 'Jawn' do
 >    link_with 'UrlMetaData'
 #    use_frameworks!
 #  -------------------------------------------

【问题讨论】:

    标签: xcode uitableview cocoapods swift-playground


    【解决方案1】:

    如果你有多个目标,

    像这样写你的 podfile。

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, ‘8.0’
    use_frameworks!
    
    def pods
    
    pod 'Alamofire', '~> 3.4'
    pod 'EZSwiftExtensions'
    
    end
    
    target 'AppName' do
        pods
    end
    
    target 'AppNameTests' do
       pods 
    end
    

    如果您有多个目标,将所有依赖项添加到一个位置会很有帮助。

    【讨论】:

      【解决方案2】:

      将你的 podfile 放在你的项目所在的文件夹中,并确保你的目标是正确的。

      我的 pod 文件如下所示:

      target 'ProjectName' do
      
      source 'https://github.com/CocoaPods/Specs.git'
      platform :ios, ‘8.0’
      use_frameworks!
      
      pod 'Alamofire', '~> 3.4'
      
      end
      

      快乐编码

      【讨论】:

        【解决方案3】:

        使用 Xcode 7.3 安装 pod

        # Uncomment this line to define a global platform for your project
         platform :ios, '9.0'
        
        target 'demoAlamofire' do
          # Comment this line if you're not using Swift and don't want to use dynamic frameworks
          use_frameworks!
          
          # Pods for demoAlamofire
        
          pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire'
          pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
        
          target 'demoAlamofireTests' do
            inherit! :search_paths
            # Pods for testing
          end
        
          target 'demoAlamofireUITests' do
            inherit! :search_paths
            # Pods for testing
          end
        
        end
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-04-05
          • 2017-03-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多