Import RealmSwift no longer working using CocoaPods

心不动则不痛 提交于 2019-12-01 19:18:21

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...

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

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

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):

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!