RealmSwift installation on Xcode - ios

I am trying to create a project which uses Realm and RealmSwift. I have used Cocoapods to install these dependencies. I have seen the other posts too on stackoverflow and tried their solutions. They don't work for me. In my project, I'm getting the error "No such module as RealmSwift" when I write the import RealmSwift statement. Here are the steps I took for installation:
I created an empty xcode project
I went into terminal and navigated to my project directory
I gave the pod init command to create a pod file
I went into the pod file(it already had the use_frameworks! statement
I wrote in pod 'Realm' and pod 'RealmSwift'. I gave the sources as:
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
I wrote in pod install
The pods were installed successfully. I went into the .xcworkspace file.
I had already installed the realm plugin so I created a new realm object file
The template file opens with the following file. I'm getting the error that there is no RealmSwift module.
What am I doing wrong? Or what am I not doing? Is a bridging header required? Has anybody else managed to resolve this error?
Any relevant suggestions or insights are most welcome.

Its working now! Its so weird since I didn't do anything. I just went into my pod file commented out the use_frameworks! statement and ran pod update on the terminal. It gave me an error, so I added it back to my pod file. I wrote in pod update again and hit enter. I restarted Xcode cleaned it and built it and I wasn't getting this error anymore.

Need to uncomment platform in your pod file then try once again your pod.
# Uncomment this line to define a global platform for your project
platform :ios, '9.0' // Uncomment this
# Uncomment this line if you're using Swift
use_frameworks!
target 'Demo_Realm' do
pod 'RealmSwift'
end
target 'Demo_RealmTests' do
end
target 'Demo_RealmUITests' do
end

Related

No such module 'AWSCore'

Im new to swift and going through a Tutorial on integrating AWS tools and I keep getting this error, " No such module 'AWSCore' "
However, on the left, you can see these modules are downloaded and there in the pod File.
My question is how to get rid of these errors and correctly import those features. Any help on how to fix this problem will be much appreciated!
re-create a new 'Podfile' on the Root folder of your Xcode project by running the command:
$ pod init
Now make sure your 'Podfile' contains the AWSCore module like shown below.
platform :ios, '9.0'
target :'MyNotes' do
use_frameworks!
# Analytics dependency
pod 'AWSPinpoint', '~> 2.6.10'
pod 'AWSCore', '~> 2.6.10'
# other pods
end
Kindly note for every module you import in your project you will need to include it in your 'Podfile' and then update the 'Podfile' by running the command :
$ pod install
or
$ pod install --repo-update
Close the Xcode project and then open the *.xcworkspace file to relaunch Xcode
I was able to get past this issue by adding $(BUILD_PRODUCT_DIR) ------ recursive. I added it to me release settings as well.
Do not open PROJ.xcodeproj but rather open PROJ.xcworkspace in some case to build pods.
In your case, other answer should lead to right way.

Cocoapods frameworks not installing properly

I can't seem to understand what is going on with my project and cocoapods, Xcode cannot find the frameworks except Firebase which is why I am confused. I'm getting the error Project ' file not found. Xcode also gives me the error, In file included from <built-in>:342: I have tried to clean and build, emptying Xcode's cache and reinstalling Xcode. Can anyone please explain this thanks.
Here's my podfile:
# Uncomment this line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'Soar_iPad' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Soar_iPad
pod 'Firebase'
pod 'Firebase/Auth'
pod 'ExpandingMenu', '~> 0.1'
pod 'SwiftyJSON'
end
I figured out what was wrong and why Xcode could not find the pod files. It was because my directory had double quotation marks in it, for example I had /username/Desktop/Project "MyApp"/Project and Xcode could not find my pod files. But for some reason I found that using single quotes worked so for example /username/Desktop/Project 'MyApp'/Project. It's weird but glad a solution was found. Thanks to everyone that helped!
Delete workspace (.xcworkspace)
Delete Podfile.lock and Pods/ directory
Make sure your project builds
Upgrade cocoapods gem install cocoapods (optional)
Close project and run pod install
Can you try this:
pod deintegrate
pod install
If it doesn't work, create a new project and add the same Podfile (just change the target name). Run pod install.
If it compiles fine, then your project must have been misconfigured somehow. You may want to migrate your project into that newly created one. (copy all files and add project references)
If it does not compile, I think there is something wrong with your system.
Please try those steps and let me know if it works.
It seems that you cocoapods is the latest version.
Try to install cocoapods that lower than 1.0.
config the podfile and run pod install.

Getting started with Firebase, iOS and Swift

Perhaps this is a n00b question but I'm going to ask it anyways. I followed the instructions for adding Firebase to a Swift app via CocoaPods. Everything seems to have worked fine. Here is my Podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'FirebaseDemo2' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for FirebaseDemo2
pod 'Firebase'
end
When trying to import the Firebase module into the AppDelegate, at first Xcode complains it cannot find it but the project builds just fine. However, when trying to add the FIRApp it then fails to build because it cannot find the class.
The Podfile is in the same directory as the .xcodeproj and I am opening the .xcworkspace file in Xcode. This is really confusing me. Can someone see what I am doing wrong? Is CocoaPods misconfigured?
I had the same problem, it installed 2.5.1 but you need 3.2.0
Try running
pod update Firebase
You should now have Firebase 3.2.0
I think your Podfile should look like this:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
use_frameworks!
target 'FirebaseDemo2' do
pod 'Firebase'
end
Make sure to open the Xcodeworkspace and not the Project

Cocoapods Installation

Dears,
I have this case I am trying to make this Control work:
https://github.com/mikaoj/BSImagePicker
Its a image picker that needs to be installed using Cocoapods. I know its a newbie question.
But i downloaded the Installed cocoapods and then went to my example folder and ran the "pod install" and it was successfull:
"Pod installation complete! There is 1 dependency from the Podfile and 3 total pods installed."
So everything should be great. But when i open the project and try to run it, This error occurs:
"No such module 'BSImagePicker'"
I cant get how things work here. Is there is any further steps should i do after "pod install" I am new for cocoapods. Maybe something i missed.
Your support is appreciated
Thank you
Three points:
Make sure your pod file has use_frameworks! line uncommented. if not, uncomment and reinstall pods.
Make sure you have opened the workspace, not the project file. Clean (Cmd+Shift+K) and Build (Cmd+B).
In the code where you want to use the BSImagePicker, make sure you import it i.e. import BSImagePicker
I just tried it and it works fine, here's what the Podfile looks like:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'ExampleApp' do
pod "BSImagePicker", "~> 2.2"
end
target 'ExampleAppTests' do
end
target 'ExampleAppUITests' do
end

Unable to add Parse using CocoaPods

Following are the steps I did to add Parse using CocoaPods but still getting unresolved error.
Added Pods File:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
pod 'Parse'
target 'GroomCal' do
end
target 'GroomCalTests' do
end
target 'GroomCalUITests' do
end
After that I did pod install. Parse and Bolts frameworks got installed (I can see them in XCode).
I then added -Bridging-Header.h and added #import <Parse/Parse.h>to it.
When I try to import Parse in AppDelegate.swift file, I still get No such Module Parse error message. What am I missing here.
I did use the *.xcworkspace file to open the project too.
To use cocoapods with swift you need to add the flag
use_frameworks! to the podfile as swift doesn't allow to add static libraries.
source Cocoapods blog

Resources