In Podfile I
pod 'AFNetworking', '~> 2.6.0'
pod update and I open project using xcworkspace.
And everything gone my way,but:
when i import AFNetworking ,Xcode prompt 'No such module AFNetworking'
I searched the solution for this question, and did like this: in 'Built setting ->User Header Search Paths ' add ${SRCROOT} and choose recursive.
But it didn't work . Xcode throw the same mesage :'No such module AFNetworking'
Okay,I just did a mistake operation .
platform :ios, '8.0'
use_frameworks!
Two line above is necessary ! After I added them and run pod update, my project's Link Binary With Libraries add a row contain Pods_.framework .Then I import AFNetworking is OK.
check out there :No such module 'RestKit' with cocoapods and swift
Go to
Project > General > Linked Frameworks and Libraries
When press "Plus" and add your framework from list.
Related
I'm trying to install the MapboxGeocoding framework with Cocoapods and Xcode9. Unfortunately Xcode can't find the module. It shows me the following error: Cannot load underlying module for 'MapboxGeocoder'
The pod file looks as the following:
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
target 'FrameworkTest' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'MapboxGeocoder.swift', '~> 0.7'
# Pods for FrameworkTest
end
I checked also the build settings of the Xcode Project. It looks like the following:
Framework Search Path
Finally nothing worked for me. Any suggestions to solve this problem?
PS: The normal MapBox Framework works well with cocoapods
I guess your framework header search path is missing this path. Try adding $(inherited) $(PROJECT_DIR) $(PROJECT_DIR)/YourProjectFramework folder in Framework search path
Hope this helps you!
I've installed FBSDK with Cocoapods but can't import it in my AppDelegate.swift file for some reason. The FBSDK kit appears in my Xcode project so I feel like it should be working.
I'm not an iOS developer by any means, I'm just trying to write a simple native plugin for Flutter SDK. Anyone an idea?
--Here is what the pod file looks like--
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
if ENV['FLUTTER_FRAMEWORK_DIR'] == nil
abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework')
end
target 'Runner' do
use_frameworks!
# Pods for Runner
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
# Flutter Pods
pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR']
if File.exists? '../.flutter-plugins'
flutter_root = File.expand_path('..')
File.foreach('../.flutter-plugins') { |line|
plugin = line.split(pattern='=')
if plugin.length == 2
name = plugin[0].strip()
path = plugin[1].strip()
resolved_path = File.expand_path("#{path}/ios", flutter_root)
pod name, :path => resolved_path
else
puts "Invalid plugin specification: #{line}"
end
}
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
---EDIT---
I''m getting the following error atm: FBSDKCoreKit.framework: No such file or directory.When I open the Frameworks folder in xCode, all file names are in red:
But that exact folder in Finder is empty. So I guess that's why the error is showing. The question is how to fix this...
This is what my embedded binaries and linked frameworks and libraries look like in the project:
Select your Project Target
Go to Build Settings.
Search for Header Search Paths.
Add this value $(SRCROOT)/Pods with recursive, then Xcode will resolve the path for you.
Are you opening the .xcodeproj or the .xcworkspace? Make sure it is the workspace whenever you install a cocoapod
I'll naively suppose you don't have use_frameworks! in you Podfile. If that's true, than you have two ways to go from here:
In your Runner-Bridging-Header.h add #import <FBSDKCoreKit/FBSDKCoreKit.h>, remove import FBSDKCoreKit from AppDelegate.swift and just continue writing the code.
Add use_frameworks! to your Podfile and run pod install again. That might bring some other issues, but if that works, than I'd suggest it.
If you use cocoapods, it should have generated a *.xcworkspace file for you. Open this file instead so your project can see the FBSDK installed and has reference to it.
When you install your pods, you must build your application first. Then your imports stop showing errors.
Why not simply use the Swift pods?-
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
and then import as normal, like-
import FBSDKLoginKit
import FacebookLogin
Once done, do a clean and build (command/⌘ + Shift + K) and Build (command/⌘ + B). Make sure you are using the .xcworkspace file to open the project.
More info on Swift FBSDK here.
Once you use the Swift pods, you should see these Frameworks in your project.
If you still continue to see the error then "Clean the build folder" using command + shift + alt + K.
Start by cleaning your project using Command + Shift + K then close the project and delete the pods folder and the pod.lock file and your .xcworkspace file. Then run pod install and see if that fixes the issue.
First Clean your project directory. And add $(inherited) in framework search path in Build settings.
As importing the FBSDKCoreKit.framework etc. will be performed in the [CP] Embed Pods Frameworks build phase when using CocoaPods, you should remove the references to these frameworks in the Embed Frameworks build phase.
CocoaPods will not create those references, I assume you have tried other ways of importing the Facebooks frameworks, and these link have been created in the process. You can also delete the references to the Facebook frameworks in the Frameworks Folder of you App-Project (the ones in your screenshot written in red, not the ones in the Pods-Project!), but keep the Pods_Runner.framework there.
From what I can tell, your Linked Frameworks and Libraries section looks valid.
If it still doesn't work, I'd advise you to create a new Xcode Project with an empty Podfile, and only include the Facebook frameworks via CocoaPods. Importing the Facebook-SDK in the AppDelegate should work then, otherwise I can share a sample project with you. Then you should check your build setting and build phases, maybe something is wrong there. If you still can't figure out the problem, you will probably need to re-create you xcode-project and import all your files again.
Without a sample Project that reproduces the error, that's the best advise I can give.
Good Luck! :)
The above solutions for Header Search Path should work.
If you are too lazy to go there.
Copy podfile content, remove all pods, pod install, then revert your podfile, pod install again.... Should work ;-)
In my case, it was correctly installed but I realized the pod is Objective-C and couldn't import it on a Swift file. I had to create a bridging header to make it work.
Refer to this stackoverflow thread
How to import existing Objective C classes in Swift
I'm using switf and pods. When i type 'pod install' on my terminal, Instead of having the frameworks downloaded to my project, i get the files.
This makes no difference to me, except for the fact that when i want to import them in my project, i always get an error saying they can't be found.
Here is my pod file
# 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 'Project' do
pod 'MSSTabbedPageViewController'
pod 'PageMenu'
end
As ocarol stated, import the framework. However, before importing at the top of the file you want to use the framework, build the project, as Xcode seems to not link the pod's to the project automatically.
Also open the .xcworkspace file that pod install generates.
You use these libraries as frameworks (use_frameworks!). So you have to import the framework at the top of the Swift file, like:
import MSSTabbedPageViewController
if had created a bridging header file, you can import the framework in it.
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
I have just started a new Swift project and I would like to use different libraries. In particular, I would like to use Realm.io, an Obj-C library. But, I would also like to use pure Swift libraries such as Alamofire or Dollar.
I use Cocoapods for managing my dependencies. I use the latest version (0.37.0) and the new use_frameworks! flag. pod install is successful anytime.
Unfortunately, when I try to build my project I get two errors (for my main target):
Umbrella header Realm.h not found from module.modulemap
Could not build Objective-C module Realm from any file using import Realm
Other imports work fine.
I have noticed the following: if I remove pure Swift libs and use_frameworks, everything works fine. I am aware about this current issue from Cocoapods. However, it should not be a problem for Realm asks developers to use that flag.
Here is my Podfile:
platform :ios, '8.0'
use_frameworks!
target 'rothrock' do
pod 'Realm'
pod 'Cent'
pod 'SwiftyJSON'
pod 'Alamofire'
end
target 'rothrockTests', :exclusive => true do
end
I use no bridging header. Should I?
Any idea or workaround?
Alright, here is the full walkthrough:
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
You need a bridging header and import your Objective-C library headers there.
If you are using only Realm you can check out this documentation for Swift http://realm.io/docs/cocoa/ (go to CocoaPods down in the tabs)
Swift
Install CocoaPods 0.36.0 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'Realm' to your app target.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!
Download the latest release of Realm and extract the zip.
Drag the file at Swift/RLMSupport.swift into the File Navigator of your Xcode project, checking the Copy items if needed checkbox.
I just installed the Realm library in a project I have with some of the libraries you mention above like Alamofire and SwiftyJSON and others and it works fine when you build the project and even put the import Realm, no compilation errors at all.
I'm using Cocoapods 0.36.0, the stable version and this is my PodFile :
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
link_with 'ApiWorkflow', 'ApiWorkflowTests'
pod 'SwiftyJSON', '~> 2.2'
pod 'Alamofire', '~> 1.2'
pod 'Typhoon', '~> 3.0'
pod 'SwiftCSV', '~> 0.1'
pod 'Realm'
I hope this help you