Module not found - cocoapods - ios

I'm trying to pod install this library into my project's (lets say child xcodeproj) parent project (lets say Parent xcodeproj).
Child .xcodeproj has its own podfile where I have added RxSwift, RxCocoa, Realm and this GeoSwift library. Here is the cocoapods file as show below
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, "9.0"
inhibit_all_warnings!
use_frameworks!
project 'LocationManager/LocationManager'
def pods
pod 'GEOSwift'
pod 'RxSwift', '~> 4.0'
pod 'RxCocoa', '~> 4.0'
pod 'RealmSwift', '~> 3.0'
end
target 'LocationManager' do
pods
target 'LocationManagerTests' do
inherit! :search_paths
pod 'RxBlocking', '~> 4.0'
pod 'RxTest', '~> 4.0'
end
end
This LocationManager is installed into another XCode project as another podfile
def location_pods
pod 'GEOSwift'
pod 'LocationManager', :git => 'git#github.com:myrepo/locationmanager.git', :branch => 'users/me/add-geoswift'
end
target 'TestApp' do
location_pods
project 'TestApp.project'
end
When I try to compile the TestApp target, XCode throws an error as below
GeoSwift module is not found. This error is inside the Pods > LocationManager > MockLocationManager.swift The same module imported else where in that Pods > LocationManager works. Also import RxSwift and import RxCoca works. When I accessed Pods > Targets > LocationManager > Build Phases > Target Dependencies I see all the pods except GeoSwift
May I know how to fix this issue? Adding GeoSwift to this targetDependency doesn't compile either. When compiling LocationManager.xcworkspace as a separate entity it works perfectly fine. That module import GeoSwift doesn't throw any compilation error.

I had an issue similar to this.
Go into Pods:
Then click on "Build Settings", find the row titled "Swift Language Version", and try updating it to the latest (in my case, it was 4.1).
This worked for me! Hopefully it helps someone else out there too.
More info: Xcode 9 Swift Language Version (SWIFT_VERSION)

From what I know Cocoapods do not support sub-projects. I had an issue with this too and I promoted all my sub-projects as folders within the main project and put them under a different target. Now those targets can use Cocoapods too.

Related

Not importing podfile in our project

I'm using Xcode 7 for ios development. I'm new to Swift. I use in my project CocoaPods. But I'm unable to import the files into our project.
MY Cocoapodfile is
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
target 'SCLAlertView2' do
pod 'SCLAlertView'
end
target 'IceCreamShopTests' do
end
Podfiles are created. But I'm unable to import the files.
import SCLAlertView
I'm getting no such module error getting. How to resolve it. Any help welcome.
Not only podfile has to be created, you also have to run
pod install
Or, if you already installed and you want to update/add new libraries:
pod update
Then, build the project again (Command+B)
Follow the "Getting Started" instructions at cocoapods.org. Here are the specific steps listed:
List the dependencies in a text file named Podfile in your Xcode project directory:
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
Tip: CocoaPods provides a pod init command to create a Podfile with smart defaults. You should use it.
Now you can install the dependencies in your project:
$ pod install
Make sure to always open the Xcode workspace instead of the project file when building your project:
$ open App.xcworkspace
Now you can import your dependencies e.g.:
#import <Reachability/Reachability.h>

How to use CocoaPods with multiple Framework subprojects

First of all, I've turned on use_framework! in Podfile.
Assume the main project is MAIN_APP, and two subprojects are FRAMEWORK_A and FRAMEWORK_B.
MAIN_APP requires FRAMEWORK_A and FRAMEWORK_B, and FRAMEWORK_B requires FRAMEWORK_A as well.
All projects/targets are using CocoaPods to manage third party libraries.
For now, my Podfile looks like:
target :MAIN_APP do
project 'MAIN_APP'
pod 'PodA'
end
target :FRAMEWORK_A do
project 'FRAMEWORK_A'
pod 'PodB'
end
target :FRAMEWORK_B do
project 'FRAMEWORK_B'
pod 'PodC'
end
I manually added FRAMEWORK_A to build settings of FRAMEWORK_B, and both FRAMEWORK_A and FRAMEWORK_B to build settings of MAIN_APP.
All code compiles well, but when running the MAIN_APP crashes because it cannot load Framework of PodB.
I know I can manually add PodB to MAIN_APP and FRAMEWORK_B as well, but is it possible to define this kind of target dependency in Podfile?
Btw, when pod install, I got the warning:
[!] The Podfile contains framework targets, for which the Podfile does not contain host targets (targets which embed the framework).
If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).
As I know, I can use nested target for host targets like:
target :FRAMEWORK_A
target :MAIN_APP
end
end
So CocoaPods will setup MAIN_APP to use FRAMEWORK_A and inherit pod dependencies from FRAMEWORK_A. But seems I cannot do it with multiple dependencies like:
target :FRAMEWORK_A
target :MAIN_APP
end
end
target :FRAMEWORK_B
target :MAIN_APP
end
end
Because target :MAIN_APP cannot be declared twice.
Is there any better solutions instead of defining pod dependencies as a function in Podfile and include in all target?
This is a great question and I've struggled with a similar situation. This is my PodFile:
platform :ios, '8.0'
workspace 'mygreatapp.xcworkspace'
project 'app/MyGreatApp/MyGreatApp.xcodeproj'
project 'platform/MyGreatFramework/MyGreatFramework.xcodeproj'
abstract_target 'This can say whatever you want' do
target 'MyGreatApp' do
project 'app/MyGreatApp/MyGreatApp.xcodeproj'
pod 'AFNetworking', '~> 2.6.0'
pod 'PromiseKit', '~> 1.5'
pod 'PromiseKit/Join'
pod 'KVOController', '~> 1.0'
pod 'FLAnimatedImage', '~> 1.0'
pod 'Crashlytics', '~> 3.3'
pod 'SSZipArchive'
end
target 'MyGreatAppTests' do
project 'app/MyGreatApp/MyGreatApp.xcodeproj'
pod 'OCMock', '~> 3.1'
end
target 'MyGreatFramework' do
project 'platform/MyGreatFramework/MyGreatFramework.xcodeproj'
pod 'SSZipArchive'
end
target 'MyGreatFrameworkTests' do
project 'platform/MyGreatFramework/MyGreatFramework.xcodeproj'
pod 'OCMock', '~> 3.1'
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
end
As you can see I'm not using frameworks and I use an abstract_target to group it all together. I wish these kinds of dependencies were easier to do in CocoaPods. I know this doesn't really answer your question but it might be helpful nonetheless.
I think you can also get around this by just making FrameworkA and FrameworkB into local (static library) pods and it will de-duplicate everything for you and integrate it into the host app properly.
Examples: https://github.com/rob-keepsafe/PodFrameworksIssue
master branch shows duplicate classes and umbrella frameworks like you have
deduped branch makes the internal dynamic frameworks into local pods (as static libs) to de-dupe and still link in the dependencies
I'm not entirely sure your issue is the same as mine, but I'm going to leave my solution here just-in-case someone has a similar issue.
I have a project with multiple sub-projects I use to modularize my code (and potentially prepare to extract to my own private pods).
I had the issue of one importing an external pod to one of the sub-projects, and receiving a dyld error due to a "missing image".
I found this Medium article from which I concluded that I had to always include the pods in the main project for the sub-projects to be able to find them. Neither of my external pods are used in the main project.
( https://medium.com/#akfreas/how-to-use-cocoapods-with-your-internal-ios-frameworks-192aa472f64b )
(I'm probably not writing the podfile as correctly or efficiently as I could, but this seems to fix my issue)
My podfile is therefore as follows:
abstract_target "RandomName" do
target "MainProject" do
inherit! :complete
workspace './MainProject.xcodeproj'
pod 'Moya', '~> 13.0'
pod 'KeychainSwift', '~> 17.0'
end
target "ModuleA" do
project './ModuleA/ModuleA.xcodeproj'
workspace './ModuleA/ModuleA.xcodeproj'
pod 'Moya', '~> 13.0'
end
target "ModuleB" do
project './ModuleB/ModuleB.xcodeproj'
workspace './ModuleB/ModuleB.xcodeproj'
pod 'KeychainSwift', '~> 17.0'
end
end

Xcode and Cocoapods "No such module" error

I recently upgraded to Xcode 8 and an existing project to Swift 3. After having a variety of issues with Cocoapods, I decided to start over from scratch. After running pod deintegrate and deleting Podfile, Podfile.lock, and [Project].xcworkspace, I had a blank slate as far as Cocoapods was concerned.
I then took the following actions:
Opened a terminal at the project location and ran pod init, then pod install (using the stub Podfile that pod init creates).
This appeared to be successful, but came with the following two warnings:
[!] The `Xena [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `Xena [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-Xena/Pods-Xena.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
At this point, opening Xcode and building the project gives the "No such module" error, which is entirely expected.
Following the instructions at this question solves this problem and rerunning pod install is a success.
Closed Xcode, added the modules I'm using to the Podfile (see below), the ran pod install again. According to the terminal output, this is successful.
Opened Xcode and built the project. I again receive the "No such module" error, specifically No such module 'ReactiveCocoa'
I have confirmed that the same problem occurs with SnapKit, Hue, KMPlaceholderTextView, KeychainSwift, and Siren, depending on the order of the import statements. For some reason, none of the Google modules are affected by this problem.
My Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Xena' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Xena
pod 'ReactiveCocoa', :git => 'https://github.com/ReactiveCocoa/ReactiveCocoa.git'
pod 'SnapKit', '~> 3.0.2'
pod 'Hue', '~> 2.0.1'
pod 'KMPlaceholderTextView', '~> 1.3.0'
pod 'GooglePlacePicker'
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'KeychainSwift', '~> 7.0'
pod 'Siren'
target 'XenaTests' do
inherit! :search_paths
# Pods for testing
end
target 'XenaUITests' do
inherit! :search_paths
# Pods for testing
end
end
Make sure you are opening .xcworkspace and not .xcodeproj file.
You may further look into this post.
Also under : Target > General > Linked Frameworks and Libraries
Make sure your frameworks are there. Even Pods_Xena.framework is there
Try:
Xcode ->Preferences ->Location ->DerivedData
open the folder DerivedData and move it to Trash
Uncomment the next line to define a global platform for your project
platform :iOS, '9.0'
Uncommenting the second line in your pod file will help you.

ld: framework not found error in xcode 8

I am using xcode 8 for development and cocoapods 1.0.1 for frameworks. After installing frameworks, i couldn't able to build my project. I am getting "ld: framework not found" error. I am using following lines in pod file:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'Sample' do
use_frameworks!
pod 'MBProgressHUD', '~> 0.9'
pod 'TPKeyboardAvoiding', '~> 1.2'
pod 'SDWebImage', '~> 3.7'
pod 'UIActivityIndicator-for-SDWebImage'
pod 'UITextView+Placeholder', '~> 1.2'
pod 'Alamofire', '~> 4.0'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
After installing the frameworks, did you closed your project and opened the newly created workspace?
Once you start using CocoaPods to install framework, you must use the workspace as it includes your Sample project and the Pod project containing the frameworks.
In you project directory, make sure to open the .xcworkspace instead of .xcodeproj.
Edit:
If that is not the issue, go to your Sample target/General/Linked Framework and Librairies
You should only have one that should be name something like: Pods_Sample.framework
If you are only using cocoa pods to install frameworks it should be the only one there as it includes all the pods.
select your target -> General ->Embedded Binary , click + ,and add Alamofire.framework
try adding project 'APP_NAME.xcodeproj' to your podfile after use_frameworks! and do pod install again
if you receive warnings like below, after pod install
[!] The `APP_NAME [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-BasePods-APP_NAME/Pods-BasePods-APP_NAME.debug.xcconfig'. This can lead to problems with the CocoaPods installation
Go to Build Settings of your target and add $(inherited) to Framework Search Paths
I had this problem, and it happened a while after renaming my project.
It was using my Pod_Old_Project_Name as a framework.
I fixed this by going to Build Phases -> Link Binary With Libraries, and removed that framework.
There are two reasons this error occurs
I have faced the same issue, This comes only due to change in the
pod file or maybe the pod file may not exist, double check the pod
file and run the cmd pod install
After successfully installing the pod file still if you getting this
error please restart the Xcode, error goes away

CocoaPods - iOS, add new OSX target, not linking properly?

I've got an iOS app, that now needs an osx build. As it's 80%-ish shared code I've added an OSX build to the project.
With my cocoapods I'm getting a few build errors (after pod install, also tried pod update)
Also found I had explicitly add a pod to the osx target to get it do the link and build phase magic in the workspace file.
The first and key error:
Target 'Pods-scoreosx' of project 'Pods' was rejected as an implicit dependency for 'Pods_scoreosx.framework' because it doesn't contain platform 'macosx' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Any one know what I'm doing wrong?
edit:
Current Podspec file:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
use_frameworks!
pod 'EmitterKit'
pod 'SwiftDate'
pod 'CocoaAsyncSocket'
pod 'ReactiveKit', '~> 1.0'
pod 'ReactiveUIKit', '~> 1.0'
pod 'ReactiveFoundation', '~> 1.0'
pod 'AsyncSwift'
target 'score' do
end
target 'scoreTests' do
end
target 'scoreUITests' do
end
target 'scoreosx' do
pod 'EmitterKit'
end
target 'scoreosxTests' do
end
target 'scoreosxUITests' do
end
The error message says you need to explicitly configure the platform for the target. Setting declaring the platform in the target would help.
target 'scoreosx' do
platform :osx
pod 'EmitterKit'
end

Resources