no such module 'Firebase' when creating own pod - ios

I am trying to create a new framework called Experiments. It is wrapping Firebase RemoteConfig APIs for any app I may build using it.
When I run the following command pod lib lint Experiments.podspec, I get the following output with errors.
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- NOTE...
- NOTE...
.
.
- ERROR | [iOS] xcodebuild: <path/to/file>: error: no such module 'Firebase'
Here is my Podfile
platform :ios, '13.0'
target 'Experiments' do
pod 'Firebase'
pod 'Firebase/RemoteConfig'
target 'ExperimentsTests' do
# Pods for testing
end
end
Here is a relevant portion of my podspec file
Pod::Spec.new do |s|
s.name = 'Experiments'
s.version = '0.1.3'
s.summary = 'This pod allows A/B Testing.'
s.description = <<-DESC
This pod facilitates AB Testing. Currently, it is powered by Firebase only.
DESC
s.license = { :type => 'MIT', :file => 'LICENSE.txt' }
s.ios.deployment_target = '13.0'
s.source_files = "Experiments/*.{swift}"
s.swift_version = "5.0"
s.frameworks = 'UIKit', 'Foundation'
s.dependency 'Firebase'
s.dependency 'Firebase/RemoteConfig'
end
I was able to successfully build my framework on XCode after pod install.
I tried using s.static_framework = true in .podspec file but I keep getting an error.
Please post a comment if you need clarity.

s.static_framework = true is required.
There's likely no reason to depend on the Firebase pod.
s.dependency 'FirebaseRemoteConfig' without the slash is more likely to work.
If you're still seeing errors with these changes, please include them in the question.

Related

Using the framework from one target as a pod in another target locally

I'm having trouble using a framework I wrote in other targets (the same project) using modular imports. I'm using Cocoapods. I'm getting Could not build module: errors while trying to import the module using modular imports (#import CMPComapiFoundation;). I attach a link to the repo for more information.
I did try both local (:path =>) and remote (:git =>) ways of pulling the SDK in Podfile, none of which seems to work. It's worth noting that if added via Cocoapods in a separate project, the code compiles and the SDK can be imported.
SDK's .podspec file:
Pod::Spec.new do |s|
s.name = 'CMPComapiFoundation'
s.version = '1.2.2'
s.license = 'MIT'
s.summary = 'Foundation library for connecting to and consuming COMAPI services'
s.description = <<-DESC
# iOS SDK for Comapi
Client to connect your iOS application with [Comapi](http://comapi.com/) services and add it as a channel to our cloud messaging platform. Written in Objective-C.
For more information about the integration please visit [the website](http://docs.comapi.com/reference#one-sdk-ios).
DESC
s.homepage = 'https://github.com/comapi/comapi-sdk-ios-objc'
s.author = { 'Comapi' => 'support#comapi.com' }
s.source = { :git => 'https://github.com/comapi/comapi-sdk-ios-objc.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/comapimessaging'
s.ios.deployment_target = '10.0'
s.requires_arc = true
s.source_files = 'Sources/**/*.{h,m}'
s.resources = []
s.dependency 'SocketRocket'
end
And here's the Podfile I'm using for the entire project:
platform :ios, '10.0'
use_frameworks!
def shared
pod 'CMPComapiFoundation', :path => '/Users/dominik.kowalski/Documents/comapi-sdk-ios-objc'
pod 'JWT'
end
target 'CMPComapiFoundation' do
pod 'SocketRocket'
end
target 'CMPComapiFoundationTests' do
shared
end
target 'ComapiFoundationSample' do
shared
end
target 'ComapiFoundationSample-Swift' do
shared
pod 'SnapKit'
end
I expect the test and sample targets to import the modules and compile the code.
Okay I managed to fix it myself. Some header files were missing Target membership, but Xcode gave me misleading hints.

Pod install : Unable to find a specification for 'Foo'

i am trying to install my custom pod created and when i run the pod install i see below error. Any one can please help I did try similar links on stack overflow but no luck.
Error : Unable to find a specification for 'Foo'.
Terminal Logs :
ExampleApp djrecker$ pod install
Analyzing dependencies
Pre-downloading: `Foo` from `https://github.com/deepesh259nitk/mixedFramework.git`, tag `1.0.7`
[!] Unable to find a specification for 'Foo'.
Pod file
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
target 'ExampleApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ExampleApp
pod 'Foo', :git => 'https://github.com/deepesh259nitk/mixedFramework.git', :tag => '1.0.7'
end
More pod commands output : pod try , pod install and pod list
AUK03154:ExampleApp djrecker$ pod try Foo
Updating spec repositories
[!] An unexpected version directory `Foo.xcodeproj` was encountered for the `/Users/djrecker/.cocoapods/repos/deepesh259nitk/Foo` Pod in the `Foo` repository.
AUK03154:ExampleApp itrmg$ pod install
Analyzing dependencies
Pre-downloading: `Foo` from `https://github.com/deepesh259nitk/mixedFramework.git`, tag `1.0.7`
[!] Unable to find a specification for 'Foo'.
AUK03154:ExampleApp djrecker$ pod list | grep Foo
AUK03154:ExampleApp djrecker$
pod spec file
Pod::Spec.new do |s|
s.name = "Foo"
s.version = "1.0.7"
s.summary = "This is a iOS framework containing both objective c and swift code"
s.description = "This is a iOS framework containing both objective c and swift code and shows how modules with with POD"
s.homepage = "https://github.com/deepesh259nitk/mixedFramework"
s.license = "MIT"
s.author = { "Deepesh" => "deepesh259nitk#gmail.com" }
s.platform = :ios, "11.0"
s.source = { :git => "https://github.com/deepesh259nitk/mixedFramework.git", :tag => "1.0.7" }
#s.source_files = "Foo/**/*.{h,m,swift}"
#s.source_files = "Foo/**/*.{modulemap}"
#s.source_files = "Foo/**/*.private.modulemap"
# s.exclude_files = "Classes/Exclude"
# s.public_header_files = "Foo/*.h"
s.vendored_frameworks = 'Foo/Foo.framework'
end
Put the podspec in the top level directory at github.com/deepesh259nitk/mixedFramework

Building a Cocoapod with both Swift and Objective-C: How to Deal with Umbrella Header Issues?

I have an existing Xcode framework, that uses both Swift and Objective-C, that I'm trying to get working as a Cocoapod. My steps so far are:
1) I used pod lib create SMCoreLib to initialize a new folder (https://guides.cocoapods.org/making/using-pod-lib-create.html).
2) I copied the Swift and Objective-C code from my framework into the SMCoreLib/Classes folder in this newly initialized pod folder. I also dragged this code into the relevant group in _Pods.xcodeproj.
3) I made some changes to the .podspec file for my project. It's as follows (note that the Github repo hasn't been updated yet with these changes; I can do that if someone wants):
Pod::Spec.new do |s|
s.name = 'SMCoreLib'
s.version = '0.0.2'
s.summary = 'Spastic Muffin Core Library for iOS'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
Objective-C and Swift classes to support Spastic Muffin code.
DESC
s.homepage = "https://github.com/crspybits/SMCoreLib.git"
s.license = { :type => "GPL3", :file => "LICENSE.txt" }
s.author = { "Christopher Prince" => "<snip>" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/crspybits/SMCoreLib.git", :tag => "#{s.version}" }
s.ios.deployment_target = '8.0'
s.source_files = 'SMCoreLib/Classes/**/*'
s.resources = "SMCoreLib/Assets/**"
# s.resource_bundles = {
# 'SMCoreLib' => ['SMCoreLib/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
s.dependency 'AFNetworking'
s.dependency 'HPTextViewTapGestureRecognizer', '~> 0.1'
s.dependency 'Reachability'
end
My problem is that I get failures both trying to build the Example Xcode project and trying to lint the pod. Building the Example Xcode project, I get the following errors:
From the command line, when I do:
pod lib lint --allow-warnings --verbose --no-clean
I get the following errors:
- NOTE | [iOS] xcodebuild: <module-includes>:2:9: note: in file included from <module-includes>:2:
- ERROR | [iOS] xcodebuild: /Users/chris/Library/Developer/Xcode/DerivedData/App-bhqthebvswpzxeesjidsqpmmwovu/Build/Products/Release-iphonesimulator/SMCoreLib/SMCoreLib.framework/Headers/SMCoreLib-Swift.h:103:9: error: 'SMCoreLib/SMCoreLib.h' file not found
- NOTE | [iOS] xcodebuild: <unknown>:0: error: could not build Objective-C module 'SMCoreLib'
The problem appears to be that in the automatically generated SMCoreLib-Swift.h Generated Interface Header, the SMCoreLib.h umbrella header cannot be found. I would greatly appreciate any suggestions.
I have a hack fix for this problem. I'd like a better one. The fix is to put a SMCoreLib.h file at: SMCoreLib/Classes/SMCoreLib.h. The file contains the single line:
#import "SMCoreLib-umbrella.h"
The problem seems to be that the Generated Interface Header doesn't respect a name change for the umbrella header given in a module map. Cocoapods creates this module map and the name change. This hack fix is present in the Git repo for this project https://github.com/crspybits/SMCoreLib.git.

Empty podspec for vendored_framework (The spec is empty...)

I've successfully compiled a framework using Cocoapods Packager
When attempting to lint the podspec that contains that framework, I'm getting the following error:
ERROR | File Patterns: The spec is empty (no source files, resources, resource_bundles, preserve paths, vendored_libraries, vendored_frameworks, dependencies, nor subspecs).
My podspec is simple and looks like this:
Pod::Spec.new do |s|
s.name = 'MyFramework'
s.module_name = 'MyFramework'
s.version = '0.0.1'
s.summary = 'Summary goes here...'
s.license = 'MIT'
s.homepage = 'http://GITHUB_ACCOUNT.com'
s.frameworks = ["CoreData", "CoreGraphics", "CoreImage", ...more frameworks]
s.requires_arc = true
s.source = {
:git => "https://github.com/GITHUB_ACCOUNT/MyFramework.git",
:tag => s.version.to_s
}
s.ios.platform = :ios, '9.0'
s.ios.preserve_paths = 'MyFramework.embeddedframework/MyFramework.framework'
s.ios.public_header_files = 'MyFramework.embeddedframework/MyFramework.framework/Versions/A/Headers/*.h'
s.ios.vendored_frameworks = 'MyFramework.embeddedframework/MyFramework.framework'
end
The basic format of the podspec is actually generated by Cocoapods-Packager. I've ensured that the following paths in the podspec all point to the expected files:
s.ios.preserve_paths = 'MyFramework.embeddedframework/MyFramework.framework'
s.ios.public_header_files = 'MyFramework.embeddedframework/MyFramework.framework/Versions/A/Headers/*.h'
s.ios.vendored_frameworks = 'MyFramework.embeddedframework/MyFramework.framework'
Running pod spec lint --verbose first tells me that ** BUILD SUCCEEDED **', but then generates the error.
Using the framework in a project via pod update works! But I can't get the pod to lint, so I'll never be able to submit it to the Cocoapods repo.
Note that all of the silly paths in the podspec I've pasted here ('http://GITHUB_ACCOUNT.com') are just placeholders and are valid paths in my actual podspec.
I'm using cocoapods 0.39.0.
Any ideas?
Found out what was wrong here.
s.ios.platform = :ios, '9.0'
means that the linter will build for ALL platforms.
The podspec as created by Cocoapods-Packager initially has this:
s.platform = :ios, '9.0'
s.ios.platform = :ios, '9.0'
At some point I inadvertently deleted the first line, I guess. At any rate, the absence of s.platform tells the linter that you want to test on all platforms.
See valid = spec.available_platforms.send(fail_fast ? :all? : :each) do |platform| here
I never expected to be testing on all platforms, only iOS. It turns out that the linter was failing while testing for watchOS, which I don't care about...
Hopefully this will help someone who makes the same mistake!

Building a Cocoapod with Swift and dependency on Objective-C framework

I know there are already a few questions on this theme here on SO, but very few have accepted answers, and I don't think I have found the exact same problem as mine.
I'm building a Swift pod, and in my code I rely on the Google Maps iOS SDK, which is bundled as a .framework file. The project builds OK in Xcode, however I have troubles publishing the lib to Cocoapods.
I managed to have a Podspec file that almost validates using the pod lib lint command. However, now that I've added the Google-Maps-iOS-SDK pod as a dependency in the Podspec file, it fails with the following message:
$ pod lib lint
[!] The 'Pods' target has transitive dependencies that include static
binaries:
(/private/var/folders/n2/qyjfpk6n7zz_mngtwswlmsy00000gn/T/CocoaPods/Lint/Pods/Google-Maps-iOS-SDK/GoogleMaps.framework)
$
Is this expected? Why can't I add the Google Maps iOS SDK as a pod reference in my own Swift-based pod?
Here's the Podspec:
Pod::Spec.new do |s|
s.name = '(name)'
s.version = '1.0.0'
s.summary = '(summary)'
s.platforms = { :ios => '8.0', :osx => '10.10' }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.source_files = 'Sources/*.{h,swift}', '*.framework'
s.source = { :git => "https://github.com/(Github repo).git", :tag => "1.0.0" }
s.requires_arc = true
s.frameworks = "Foundation", "CoreLocation"
s.author = { 'Romain L' => '(email)' }
s.dependency 'Google-Maps-iOS-SDK'
end
If I don't include the Google Maps iOS SDK as a dependency, then pod lib lint fails in the Bridging Header, and complains it cannot find <GoogleMaps/GoogleMaps.h> (file not found).
I'm stuck, and I don't know if it's a bug from Cocoapods 0.36 (still in Beta) or if I'm doing something wrong.
Thanks for your help!
I finally found another thread on SO dealing with similar problems: Linker errors in a Swift project with Google Maps for iOS added via CocoaPods.
It appears that the errors were due to a combination of bad Podspec file (on the Google Maps iOS SDK side), and bugs in Cocoapods 0.36 Beta.
It's actually possible to workaround the issues by using #fz.'s revised Podspec file for Google Maps: https://stackoverflow.com/a/28471830/145997. Another article that also was of great interest to understand how the vendored_frameworks setting works in Podspec is: http://codereaper.com/blog/2014/creating-a-pod-with-crashreporter/.
So, to correctly import the Google Maps iOS SDK in a Pod project, first use the following Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# altered version of Google's Podspec
pod 'Google-Maps-iOS-SDK', :podspec => "https://raw.githubusercontent.com/Reflejo/GoogleMapsPodspec/master/Google-Maps-iOS-SDK.podspec.json"
use_frameworks! # don't forget this!
I'm now able to reference Google Maps classes from my Swift code simply by doing import GoogleMaps. And, to distribute the Pod, my final Podspec now resembles the following:
Pod::Spec.new do |s|
s.name = 'MyPod'
s.version = '1.0.0'
s.homepage = "https://github.com/..."
s.summary = '(pod summary)'
#s.screenshot = ""
s.author = { 'Romain L' => '(email)' }
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.social_media_url = "https://twitter.com/_RomainL"
s.platforms = { :ios => '8.0' }
s.ios.deployment_target = '8.0'
s.source_files = 'MyCode/*.{h,swift}'
s.module_name = 'MyPod'
s.source = { :git => "https://github.com/....git", :tag => "1.0.0" }
s.requires_arc = true
s.libraries = "c++", "icucore", "z" # required for GoogleMaps.framework
s.frameworks = "AVFoundation", "CoreData", "CoreLocation", "CoreText", "Foundation", "GLKit", "ImageIO", "OpenGLES", "QuartzCore", "SystemConfiguration", "GoogleMaps" # required for GoogleMaps.framework
s.vendored_frameworks = "Dependencies/GoogleMaps.framework" # Put the Google-provided framework in that subfolder of your Pod project
#s.dependency 'Google-Maps-iOS-SDK' # Careful! this will cause errors if enabled!
end
I am now able to start a new iOS app in Xcode and use the following Podfile to link against my own pod, itself referencing the Google Maps iOS SDK:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'MyPod'
use_frameworks! # do not forget this!
Not that easy, but feasible after all! Hoping Google will soon patch its Podspec file for Swift developments, though.

Resources