导入RealmSwift不再使用CocoaPods [英] Import RealmSwift no longer working using CocoaPods

查看:1122
本文介绍了导入RealmSwift不再使用CocoaPods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RealmSwift的CocoaPods安装 Kruherson 建议这里(或者也推荐从realm.io页面这里)基本上有效 - 但是我的应用程序中使用Swift 0.92.3还有一个问题:

The CocoaPods installation of the RealmSwift Kruherson recommended here (or also is recommended from the realm.io page here) basically works - however there is one problem that is remaining in my App using Swift 0.92.3:

以下导入不再被识别!

import RealmSwift

为了让CocoaPods在Swift下工作,我还需要做些什么?

What do I still need to do in order to make CocoaPods work under Swift ?

这是内容使用我的Podfile:

Here is the content of my Podfile used :

platform :ios, '8.3'
use_frameworks!

xcodeproj '/Users/XXX/.../MyApp/MyApp.xcodeproj'

target 'MyApp' do
  pod 'RealmSwift', '>= 0.92.3'
end

这是我的Xcode项目的截图(仅限Pods部分) )看起来像pod install之后:

Here a screenshot of my Xcode project (only Pods part) looks like after the "pod install" :

有一些红色的东西 - 问题可能在这里或者我还有什么遗漏?

There are a few "red things" - might the problem lie here or what do I still miss ?

我需要做什么才能获得导入RealmSwift 再次工作?

What do I need to do in order to get import RealmSwift working again ??

推荐答案

所有Pod框架的红色颜色都没有害处!框架在物理上并不存在 - 因此Xcode无法改变颜色。它肯定不会在这里表明错误...

The "red" color of all the Pod-frameworks is no harm! The frameworks are not physically there - therefore Xcode cannot change the color. It, for sure, does not indicate a mistake here...

但是,如果你想使用MyApp WatchKit Extension,上面的Podfile不是正确的。正确的是:

However, the Podfile above is not the right one if you want to use your "MyApp WatchKit Extension". The correct one is:

xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'

source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!
link_with 'MyApp', 'MyApp WatchKit Extension'

def shared_pods
      pod 'RealmSwift', '>= 0.92.3'
end

target 'MyApp' do
    shared_pods
end

target 'MyAppTests' do
    shared_pods
end

target 'MyApp WatchKit Extension' do
    shared_pods
end

此外,它是重要的是你仍然在你的Realm-Object定义中导入RealmSwift,如下例所示:

Also, it is important that you still "import RealmSwift" in your Realm-Object definition(s) as can be seen in an example below:

此外,如果您打算在两个目标中使用您的Realm-Object (即MyApp和MyApp WatchKit Extension),确保在RealmObject.swift文件的目标选择窗格中选择相应的目标(见下图):

Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):

这篇关于导入RealmSwift不再使用CocoaPods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆