简体   繁体   English

Xcode 7 CocoaPods 中的 Objective C 项目错误

[英]Objective C Project in Xcode 7 CocoaPods Error

The Terminal Error I am receiving after running pod install is:运行pod install后我收到的终端错误是: 在此处输入图片说明

I realize that ReactiveCocoa 's cocoapod is entirely in SWIFT and that I need to Bridge the header files, but my attempts have been far from successful.我意识到ReactiveCocoa的 cocoapod 完全在 SWIFT 中,我需要接头文件,但我的尝试远未成功。

I did find this response from one of TeamTreehouse's Staff:我确实从 TeamTreehouse 的一名员工那里找到了这个回应:

" The SimpleAuth library has it's own set of dependencies one of which is ReactiveCocoa. ReactiveCocoa was recently rewritten completely in Swift so that's the Swift code that's getting added to your project. Unfortunately there are 2 versions of ReactiveCocoa out there, written in Swift 1.2 and Swift 2.0. " The SimpleAuth library has it's own set of dependencies one of which is ReactiveCocoa. ReactiveCocoa was recently rewritten completely in Swift so that's the Swift code that's getting added to your project. Unfortunately there are 2 versions of ReactiveCocoa out there, written in Swift 1.2 and Swift 2.0.

SimpleAuth is currently automatically pulling the 1.2 version of ReactiveCocoa. Swift 1.2 can only be run in Xcode 6.1 and not in Xcode 7 (which requires Swift 2).

So if you are using Xcode 7, then you're pulling in the Swift 1.2 version by default and this is causing all the Swift errors.

Also, you have to do some cleanup work to get Swift frameworks to run in a mixed Objective-C/Swift project which includes adding a bridging header and stuff."

. .

^^ Explains my Problem ^^ ^^ 解释了我的问题 ^^

Thanks in advance!提前致谢!

Edit编辑

After adding use_frameworks!添加use_frameworks! to my Podfile, I was receiving errors like:到我的 Podfile,我收到如下错误:

在此处输入图片说明

The error message says to add the line use_frameworks!错误消息说要添加一行use_frameworks! to your file called Podfile .到您的名为Podfile的文件。

Add it below the first line that should probably say platform :ios, 'x.0' .将它添加到应该是platform :ios, 'x.0'的第一行下方。

You need to use ReactiveCocoa 4.0, which is target Swift 2.0, yet still under alpha version.您需要使用 ReactiveCocoa 4.0,它的目标是 Swift 2.0,但仍处于 alpha 版本。

If you want to have a try, check this out.如果你想试一试,看看这个。

use_frameworks!

target 'YOUR_TARGET' do
    pod 'ReactiveCocoa', '~> 4.0.0-alpha'
end

After attempting use_frameworks!在尝试use_frameworks! within my pod file, I was still experiencing errors due to ReactiveCocoa and the .swift files (even after auto-correcting the errors that Xcode attempted to fix for me).在我的 pod 文件中,由于ReactiveCocoa.swift文件,我仍然遇到错误(即使在自动更正了 Xcode 试图为我修复的错误之后)。

Within my Podfile I was able to resolve both sets of errors I was experiencing: 1. When including use_frameworks!在我的Podfile我能够解决我遇到的两组错误: 1. 当包含use_frameworks 时! in the Podfile 2. Also when running my original pod install in hopes of adding the Parse cocoapod在 Podfile 2 中。此外,在运行我的原始pod install以希望添加 Parse cocoapod 时

Final code in Podfile Podfile 中的最终代码

pod 'ReactiveCocoa', '2.4.7'
pod 'SimpleAuth/Instagram', '0.3.6'
pod 'SSKeychain'
pod 'Parse'

You can actually request the latest version of the dependencies.您实际上可以请求最新版本的依赖项。 Your Podfile should look like this:您的 Podfile 应如下所示:

platform :ios, "9.0"
use_frameworks!

target 'MyAppNameHere' do

    end

pod 'Box', :head
pod 'Result', :head
pod 'SimpleAuth/Instagram'

Then peform a pod update and in your project, Product > Clean and Product > Build and will work again.然后执行pod update ,在您的项目中, Product > Clean and Product > Build将再次运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM