Swift Use of unresolved identifier 'RealmApp' - swift

I was following this Realm ios SDK quickstart
https://docs.mongodb.com/realm/ios/quick-start/
here is my swift code
import Foundation
import SwiftUI
import RealmSwift
import UIKit
let app = RealmApp(id: "xxxx")
however i keep getting this error
Use of unresolved identifier 'RealmApp'
this is my pod file
# Uncomment the next line to define a global platform for your
project
platform :ios, '12.0'
target 'Emma' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Emma
pod 'Firebase'
pod 'RealmSwift', '=10.0.0-beta.2'
target 'EmmaTests' do
inherit! :search_paths
# Pods for testing
end
target 'EmmaUITests' do
# Pods for testing
end
end
RealmSwift module has been installed through the pod file. I don't know how to resolve the issue since that is what is listed in the quick start.

I was getting the same error. At some point it seems let app = RealmApp(id: "xxxx") was changed to let app = App(id: "xxxx").

Related

How can I specify which build target includes a specific swift package dependency?

Using the swift package manager, I have a swift package included in my project and I would only like it to be available in the test target and ui test target. How can I choose the target which has access to the swift package?
the easiest way would be to use cocoapods
your podfile would look like this
# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'MyApp' do
# Comment the next line if you don't want to use dynamic frameworks
#use_frameworks!
#These are the main app frameworks
pod 'Alamofire'
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
# here would be your testing frameworks
pod 'MyTestFramework'
end
target 'MyAppUITests' do
# Pods for testing
# and here your UI tests framework
end
end

No such module RealmSwift

This is not a duplicate question.
I have been using realm for a long time. Recently I am getting the error of "No such module RealmSwift". But this is happening only in release target scheme not in build target scheme. Is there any particular reason as to why it is not working only in release? I have seen this question at a lot of places but none of those solutions worked for me.
My podfile looks similar to this:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
#use_modular_headers!
inhibit_all_warnings!
def shared_pods
pod 'RealmSwift'
end
target ‘************’ do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ************
shared_pods
target '************Tests' do
inherit! :search_paths
# Pods for testing
end
end
target '************UITests' do
inherit! :search_paths
# Pods for testing
# shared_pods
end
This is more of a troubleshooting step than a direct answer since I duplicated your issue.
You've been using Realm a while so you know this but for future readers, ensure that any file where you're using RealmSwift includes
import RealmSwift
I just tried your podfile on a new project and am getting weird behavior as well. I replaced your podfile with the following 5 lines and it works correctly.
project 'Realm Test.xcodeproj'
target 'Realm Test' do
use_frameworks!
platform :osx, '10.13'
pod 'RealmSwift'
end
That was a macOS project but it worked equally well with an iOS project. On that project I uncommented #platform :ios, '12.0'
I think this is the issue
inherit! :search_paths
That lets the target know about the search paths but does not link them in. I would suggest changing that to
inherit! :complete
Which appears to be working in my project.
Oh - for completness, I ran into this once as well and the solution was
add the parent path of RealmSwift.framework (i.e., the containing
directory) to your framework search paths.
This is a common Realm bug which occurs in Xcode after pod install. Clean and Build the project once, the bug should go away!

No such module 'InputBarAccessoryView'

Trying to get MessageKit setup within my project. I'm getting the following error - 'No such module 'InputBarAccessoryView' within the
MessagesViewController+Keyboard.swift:26:8: No such module 'InputBarAccessoryView'
I've tried installing pods, updating pods and deintegrating.
import Foundation
import InputBarAccessoryView
Should compile normally. Only error that persists.
In My case i will update pod file Ios version
# Uncomment the next line to define a global platform for your project
platform :ios, '14.0'
target 'Messanger' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Messanger
pod 'InputBarAccessoryView'
end

Cannot import frameworks on new swift files when using cocoapods

Here is my podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'App' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Fabric'
pod 'Crashlytics'
pod 'Firebase/Database'
# Pods for App
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
target 'AppUITests' do
inherit! :search_paths
# Pods for testing
end
end
I then run pod install. I open the pods workspace as per usual.
Now in my AppDelegate.swift I can import frameworks without issue
import UIKit
import CoreData
import Firebase
import FirebaseCore
import Fabric
import Crashlytics
In my ViewController.swift, I can again import frameworks without issue
import UIKit
import Firebase
import FirebaseAuth
import FirebaseDatabase
The issue is when I get to my new view controller, called HomeController.swift
import UIKit
import Firebase
import FirebaseAuth
import FirebaseDatabase
It cannot find the frameworks, however it builds and runs fine. Just annoying as I lose code completion issues and have error warnings.
Not sure why it works on two files but not the third, it also builds and runs fine so seems like IDE issue rather than actual code/framework reference issue
Just looking at tips to resolve
Check the target membership of this new file to see if has the same as 2 previous one.
Select the file -> File Inspector -> Target Membership

Xcode does not see framework installed via cocoa pods

I am trying to add the SharkORM framework to my application but somehow after installing pod which looks like :
target 'XXX' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for XXX
pod 'Firebase/Core'
pod 'SharkORM'
target 'XXXTests' do
inherit! :search_paths
# Pods for testing
end
target 'XXXUITests' do
inherit! :search_paths
# Pods for testing
end
end
and using command pod install; getting this :
Analyzing dependencies
Downloading dependencies
Using Firebase (3.12.0)
Using FirebaseAnalytics (3.6.0)
Using FirebaseCore (3.4.7)
Using FirebaseInstanceID (1.0.8)
Using GoogleInterchangeUtilities (1.2.2)
Using GoogleSymbolUtilities (1.1.2)
Using GoogleToolboxForMac (2.1.1)
Using SharkORM (2.1.1)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 8 total pods installed.
Which sounds great because the installation is succeed.
In the AppDelegate.swift getting error :
Use of undeclared type 'SRKDelegate' here :
class AppDelegate: UIResponder, UIApplicationDelegate, SRKDelegate {
I would say that i have to use import SharkORM on the top of my file but it does not shows me this file exist. It should - > Inside Pods file i have these components then what is going on ? As u can see I am using Firebase which is working.
Thanks in advance!
Install the framework
pod install
Open your workspace XXX.xcodeproj and create a bridging header. To create bridging header
//File -> New File -> Header File
//Save it as a YourApp-Bridging-Header
Compile the SharkORM framework target
Then include the framework header within your app, by adding this to the bridging header
#include <SharkORM/SharkORM.h>
import module import SharkORM in AppDelegate class
import SharkORM››
Add SRKDelegate in AppDelegate class
class AppDelegate: UIResponder, UIApplicationDelegate, SRKDelegate
You have to import SharkORM to use the pod. Also, make sure you're working on the .xcworkspace file in the same directory as the project (it's automatically created when you execute pod install.