Unable to import AFNetworking dependency into Cocoapod - ios

I'm trying to setup the podspec for my project and I keep getting this error when I run pod spec lint
➭ pod spec lint
-> BRECBathroomFinder (1.0.0)
- ERROR | [iOS] Returned an unsuccessful exit code. You can use `--verbose` for more information.
- ERROR | BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:16:26: error: use of undeclared type 'AFHTTPRequestOperationManager'
- ERROR | [iOS] BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:29:73: error: use of undeclared type 'AFHTTPRequestOperation'
- ERROR | [iOS] BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:48:35: error: use of undeclared type 'AFHTTPRequestOperation'
- NOTE | [iOS] }, failure: { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
- ERROR | [iOS] BRECBathroomFinder/BRECBathroomFinder/BBFOpenDataClient.swift:29:9: error: 'BBFOpenDataClient' does not have a member named 'GET'
Analyzed 1 podspec.
Here is my podspec. You'll notice at the bottom that my I've got .prefix_header_contents = "#import <AFNetworking/AFNetworking.h>" in there; so it doesn't make sense to me that it can't find the AFHTTPRequestOperation class.
Pod::Spec.new do |s|
s.name = "BRECBathroomFinder"
s.version = "1.0.0"
s.summary = "A pod that finds nearby BREC parks with restrooms"
s.description = <<-DESC
This is a project built on top of Baton Rouge's Open Data API. It uses a query to find parks with bathrooms.
The results can be sorted according to how close the parks are to a given location or the user's location.
DESC
s.homepage = "https://github.com/jmhooper/BRECBathroomFinder"
s.author = { "Jonathan Hooper" => "jon9820#gmail.com" }
s.license = 'MIT'
s.source = { git: "https://github.com/jmhooper/BRECBathroomFinder.git", tag: s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = "BRECBathroomFinder/**/*"
s.dependency "AFNetworking", "~> 2.0"
s.frameworks = "CoreLocation"
s.prefix_header_contents = "#import <AFNetworking/AFNetworking.h>"
end

After a lot of frustration I finally figured it out.
In the file it was complaining about, I had to add a import AFNetworking line along with the rest of my Swift imports.
I did that and the podspec passed validation.

Related

Unable to Create Cocoapod dependency with remote framework

I want to create a Cocoapod dependency with a existing framework(A Compiled framework for internal uses which I want to share internally via cocoapods) which is in remote location such as git and drop box.
I am following the Tutorial
Below is the code of podspec file
Pod::Spec.new do |s|
s.name = 'SDK101'
s.version = '0.1.0'
s.summary = 'A Awesomeness of SDK101.'
s.description = <<-DESC
Add long description of the pod here.Awesomeness!!!
DESC
s.homepage = 'https://github.com/'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Sourabh' => 'sourabh.gajbhiye#gmail.com' }
s.source = { :http => 'https://app.box.com/s/ipwollwlh675fkg3oy87rr7nneafafv0', :type => 'zip' }
s.ios.deployment_target = '12.0'
s.platform = :ios
s.ios.vendored_frameworks = 'SDK101.framework'
s.exclude_files = "Classes/Exclude"
end
for this file when i am executing the following command in terminal for the validation of pod I am getting error shown below
pod spec lint --verbose
[!] Error installing SDK101
-> SDK101 (0.1.0)
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/unzip /var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo/file.zip -d /var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo
Archive: /var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo/file.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of /var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo/file.zip or
/var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo/file.zip.zip, and cannot find /var/folders/gq/xrq80ysd50nd5frn2zhb89dc0000gn/T/d20210422-75411-1bv4xo/file.zip.ZIP, period.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error.
After this I followed Cocoapods error installing libopencv-contrib but it didn't helped me.
Please help me what I am doing wrong?

no such module 'Firebase' when creating own pod

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.

Xcode Swift CocoaPods pod spec lint Fails on Embed Pods Frameworks

I'm getting the following error when trying to run pod spec lint --verbose:
sent 1312397 bytes received 106 bytes 2625006.00 bytes/sec
total size is 1311832 speedup is 1.00
/var/folders/3d/v0m_90ty4mg1opbynpnjjvzh2010gm/T/CocoaPods-Lint-20181015-62030-oljqd-MySwiftPackage/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh: line 104: EXPANDED_CODE_SIGN_IDENTITY: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/myuser/Library/Developer/Xcode/DerivedData/App-loplmnuztwibrzfqgadqoxucytrz/Build/Intermediates.noindex/App.build/Release/App.build/Script-09EB8340PON5K18DNW0C63DQ.sh
(1 failure)
Testing with `xcodebuild`.
-> MySwiftPackage (0.1.0)
- WARN | summary: The summary is not meaningful.
- WARN | description: The description is shorter than the summary.
- WARN | url: The URL (https://github.com/fishcharlie/MySwiftPackage) is not reachable.
- NOTE | xcodebuild: note: Using new build system
- NOTE | xcodebuild: note: Planning build
- NOTE | xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
- WARN | xcodebuild: MySwiftPackage/MySwiftPackage/ViewControllers/Shared/MyFirstViewController.swift:102:37: warning: conditional cast from 'UIViewController' to 'MyViewController' (aka 'UIViewController') always succeeds
- WARN | xcodebuild: MySwiftPackage/MySwiftPackage/ViewControllers/Shared/MySecondViewController.swift:145:37: warning: conditional cast from 'UIViewController' to 'MyViewController' (aka 'UIViewController') always succeeds
- ERROR | [OSX] xcodebuild: Returned an unsuccessful exit code.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error and 5 warnings.
I know I have a few warnings that I can clean up. But there is only one error that I'm getting, which is - ERROR | [OSX] xcodebuild: Returned an unsuccessful exit code.. And above that it says that Embed Pods Frameworks was the cause of failure.
Not quire sure how to debug this since I can build and run the example projects in Xcode just fine.
Below I have attached my Podspec as well.
Pod::Spec.new do |s|
s.name = 'MySwiftPackage'
s.version = '0.1.0'
s.summary = 'A short description of MySwiftPackage.'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/fishcharlie/MySwiftPackage'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'fishcharlie' => 'fishcharlie.code#gmail.com' }
s.source = { :git => 'https://github.com/fishcharlie/MySwiftPackage.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/char_fish'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.swift_version = '4.2'
s.source_files = 'MySwiftPackage/Classes/**/*', 'MySwiftPackage/ViewControllers/Shared/**/*'
s.ios.source_files = 'MySwiftPackage/ViewControllers/iOS/**/*'
s.osx.source_files = 'MySwiftPackage/ViewControllers/macOS/**/*'
s.resources = 'MySwiftPackage/Assets/**/*.{ttf,xcassets}'
s.dependency 'Alamofire', '4.7.3'
s.dependency 'Bond', '6.10.2'
s.ios.dependency '1PasswordExtension', '1.8.5'
end
Any ideas on how to fix/debug this?
The error should be about
line 104: EXPANDED_CODE_SIGN_IDENTITY: unbound variable
The solution (as stated in Issue 7708 on github/Cocoapods ) should be to add the following User-Defined Settings to project:
EXPANDED_CODE_SIGN_IDENTITY="-"
EXPANDED_CODE_SIGN_IDENTITY_NAME="-"`
Try adding the flag --no-clean. This flag makes lint leave the build directory
intact for inspection
so you can debug that build failure in a workspace which may be more familiar and give you more information.
Looks like they fixed this for xcode 10 in pr github.com/CocoaPods/CocoaPods/pull/7720, you could try upgrading to 1.6.0, or downgrading xcode to 9.4.

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.

Error using Apple frameworks in my CocoaPod podspec?

I have a cross platform library that I'm trying to push to CocoaPod, but the it is failing on the podspec validation. The error I get is:
ERROR | xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.
ERROR | xcodebuild: MyPod/Sources/CLKComplicationServer.swift:10:8: error: no such module 'ClockKit'
I tried adding the frameworks to my podspec, but it is still not accepting. Here is what my podspec looks like:
Pod::Spec.new do |s|
...
s.ios.deployment_target = "8.4"
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"
s.requires_arc = true
s.ios.framework = 'AVFoundation'
s.watchos.framework = 'ClockKit'
s.source_files = "Sources/**/*.{h,swift}"
end
What am I doing wrong? I'm having the same issue with AVFoundation. I tried adding both to my header file, but ClockKit is not recognized.

Resources