Import RealmSwift no longer working using CocoaPods

前端 未结 1 742
时光取名叫无心
时光取名叫无心 2021-01-19 19:44

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

相关标签:
1条回答
  • 2021-01-19 20:25

    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:

    enter image description here

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

    enter image description here

    0 讨论(0)
提交回复
热议问题