I'm new to Cocoapods and am trying to use a pod named DateTools in my OS X app Swift project.
I installed Cocoapods, created the podfile, added pod 'DateTools' to it, ran pod install and everything seemed to work fine. (I'm a Ruby dev so I think I got this part right).
As asked by Cocoapods, I now opened my project using the new .xcworkspace file created. I correctly see two projects in Xcode: mine and Pods.
I added a sample model file to my project, let's call it SampleModel but in the code, when I do this:
let date = NSDate()
var year = date.year
I get the error: 'NSDate' does not have a member named 'year'. According to DateTools README, this should work.
As I'm new to both Xcode and Cocoapods, I can't figure out what is the likely error: DateTools not working with Swift or did I fail to import something, somewhere?
You need to import module into your source file
import DateTools
Also, by default is CocoaPods building static libraries - to use those you would need to configure bridging header. Easier way is to make it build dynamic framework by specifying so in Podfile (and run pod install):
use_frameworks!
pod 'DateTools'
Related
I'm trying to follow this guide here to create a native module in React Native.
https://facebook.github.io/react-native/docs/native-modules-setup
When you create the native module these are the setup instructions.
cd react-native-my-library/example
yarn
cd ios
pod install # required starting with React Native 0.60
cd ..
react-native run-ios
I don't have an example subfolder and there is also no pod file installed in the ios directory so pod install just gives me this error.
[!] No `Podfile' found in the project directory.
It's also creating my project with an older verison of react native. It's using react-native: 0.59.10.
The current version I have installed is react-native: 0.61.5.
I'm on Mac OS X 10.15.3.
I was having this issue as well yesterday, here's one reply from the repo owner. Append the following to podfile will do
pod 'react-native-my-library', :path => '../react-native-my-library.podspec'
At the same time I realized podfile is not really necessary unless your module required other depedendency to be installed? Otherwise, I just build on top of .xcworkspace and link to my project. Ta-da, works fine!
** One thing to keep in mind is that, .xcworkspace is not able to compile due to the complain of missing React/***.h
I'm using RealmSwift as a database in my swift project. Today, after opening my project in Xcode-beta version 11, my app crash with this error:
Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole''
My app works properly on the previous version of Xcode(10.2.1).
RealmSwiftPermissionRole is a class from the Realm and I don't have access to it. Maybe in their feature updates, they fix this bug but for now, I search a lot but didn't find any solution.
(I clean the project, delete the app from the simulator, and run the project again but nothing changed.)
Any suggestion?
There's an issue with iOS 13 and Xcode 11 which may cause this problem. All String properties of Realm classes with a default String value set are disregarded somehow.
You can fix this by updating to the latest version (currently 3.20.0) and then on Xcode: Product -> Clean Build Folder.
If you're using cocoa-pods:
Open your project's Podfile, and replace RealmSwift line with:
pod 'RealmSwift', '~> 4.4.1'
Then, open terminal on the project's folder and:
pod repo update
pod install
Developers of Realm have started working on Xcode 11 compatibility. From that page...
Using Realm with Xcode betas requires building from source, and typically will require using dev branches rather than releases.
Carthage
github "realm/realm-cocoa" "tg/xcode-11-b1"
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer carthage bootstrap -no-use-binaries
CocoaPods
pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
Explicitly including the Realm pod as a dependency is required as otherwise it'll try to use the latest release of the obj-c part.
Note that last sentence. You must include the Realm pod as a dependency or it'll use the non-beta version and it won't work.
I had run into the same issue with RealmSwift 4.3.1, the problem was I forgot to mark the property as #objc
#objc dynamic var id = ""
Try deleting and reinstalling your application too.
For me,
Updating the Realm to pod 'RealmSwift', '~> 3.20.0'
and update the pod install
Works for me.
Using Xcode 7.2.1.
I am following this tutorial to get pods working in playground. i have added the playground into the workspace, and the podfile is linking to the playground.
But importing still does not work - "no such module"
https://littlebitesofcocoa.com/138-using-cocoapods-in-xcode-playgrounds
// import does not work
// Podfile
target 'spaceships' do
end
platform :ios, '9.0'
use_frameworks!
link_with 'spaceships', 'imports', 'test'
https://github.com/mingyeow/ImportToPlaygroundDoesNotWork
Not a direct answer to the issues you get from this tutorial, but there's a new tool to automatically generate Playgrounds with pods that I often use.
It's called ThisCouldBeUsButYouPlaying and the source is on GitHub.
Basically it extends the CocoaPods installer, which is then able to generate Playgrounds.
Install:
$ gem install cocoapods-playgrounds
Create a Playground with Alamofire:
$ pod playgrounds Alamofire
Create a Playground with multiple pods:
$ pod playgrounds RxSwift,RxCocoa
The new Playground will automatically open.
You will have to first build the project, to enable the pods, then the Playground will be available.
I'm trying to integrate facebook into my app using CocoaPods, using the use_frameworks! tag, and according to facebook's instructions here, also included the pod bolts. When I try use import FBSDKCoreKit in my appdelegate, I get a no such module 'FBSDKCoreKit error. I've included my podfile below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.2'
use_frameworks!
pod 'Bolts'
pod 'Alamofire', '~> 3.0'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
Additionally, in my Pods folder, there is a question mark next to Bolts, FBSDKCoreKit, and FBSDKSharekit, but not one next to alamofire, which I had been using previously. In the Frameworks folder in my Pods project, FBSDKCoreKit and Bolts are listed there, but are both red.
Any ideas? I've tried cleaning my project, and reinstalling and updating the pods.
For people moving from Carthage to Cocoapods make sure to remove the Carthage references of the FBSDKCoreKit from the Link Binary With Libraries under Build Phases option.
Please try below steps,
Explicitly mention the versions i.e.
pod 'FBSDKCoreKit', '~>5.8.0'
pod 'FBSDKShareKit', '~>5.8.0'
pod 'FBSDKLoginKit', '~>5.8.0'
Update pod repo using sudo pod repo update
Update pod using pod update
Seems that the facebook pods are Objective-C and they need a special way of importing in a swift project.
This is how I got it to work:
Create a bridging header in your project, if you dont have one(I created a new header file called Bridging-Header.h and set it as a bridging header in the project settings, like in the screenshot)
Then in this file import the facebook modules. Here's how my file looks like:
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import FBSDKCoreKit;
#import FBSDKLoginKit;
#endif /* Bridging_Header_h */
Let me know if this workout for you or you need more help.
I fixed this by
Removing the Bridging Header. Facebook SDK doesn't need them anymore after version 4.1
Adding all of the .frameworks to the Projects Build Phases -> Link Binary With Libraries
Selecting each framework and building it. You can do this by selecting your project name next to the run arrow.
Cleaning the project and restarting my computer.
Very simple solution, if you are using Apple Swift Packages:
Go to Navigator pane and select the project
Then make sure you choose project name under "Project" not under "Targets"
Then select Package Dependencies tab
You will find the Facebook package there, double click on it
Change version to 9.0.0 and click "Done"
Rebuild, and it should be corrected.
Note that you may need this url to add Facebook SDK as Apple Swift Packages rather than Cocoapods.
You can try :
pod 'FBSDKCoreKit/Swift'
first add in pod file
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
this is facebook swift library,after that before using FBSDKCoreKit,just use FacebookCore then import FBSDKCoreKit
I've tried multiple methods and Xcode versions to install this method and use it but every time when i use import ConvenienceKit it always fails by saying "No such module ConvenienceKit"
https://github.com/MakeSchool/ConvenienceKit
it can be installed by using use_frameworks! in the Podfile and pod 'ConvenienceKit'. Everything installs fine, just doesn't work.
What am i missing ?
To use pods use have to work in a 'workspace' with the the pod that you are using. If you are using a workspace and it is sill not working you can try the following:
Check to see if there is a update for CocoaPods
Check to see if there is a update for Xcode
Uninstall Xcode and re install it.
Hope this works.