Unrecognized `swift_version` key - swift

I can’t push a new version of my pod to the CocoaPods specs repository.
Running pod trunk push MyPod.podspec results in the following error:
[!] The Pod Specification did not pass validation.
The following validation failed:
- Warnings: Unrecognized `swift_version` key.
Here’s my podspec:
Pod::Spec.new do |spec|
spec.name = "MyPod"
spec.version = "0.1.1"
spec.summary = "[REDACTED]"
spec.homepage = "[REDACTED]"
spec.license = "Apache License, version 2"
spec.author = "[REDACTED]"
spec.social_media_url = "[REDACTED]"
spec.module_name = "MyPod"
spec.swift_version = "5.0"
spec.platform = :ios, "8.0"
spec.source = { :git => "https://github.com/[REDACTED].git", :tag => "v#{spec.version}" }
spec.source_files = "MyPod/**/*.{h,m,swift}"
end
What am I doing wrong?
I first noticed these errors before updating to Swift 5 and Xcode 10.2.

It seems to be a server-side bug. It’s been reported on GitHub.
However, since it’s a warning, not an error (despite it’s in red font color, which is confusing), it can be ignored with the --allow-warnings argument.

Summary, to update a pod:
Update the version and the tag in podspec beforehand
Commit, push code to git
Create new tag with the current code, make sure it's the same tag as the one in podspec
git tag 0.1.1
git push origin 0.1.1
Call pod spec lint to check and pod trunk push to update it on repo master list
pod lib lint YourSDK.podspec
pod trunk push YourSDK.podspec
It appears that your podfile is using the tag v0.1.1, however the tag in your repository is 0.1.1 without the v. This would also cause linting to fail.

Related

What is the correct way to change the repo on a podspec?

I created my first cocoapod from a personal repo, and deployed it to cocoapods via the pod trunk push command. Since it is my first framework, I wanted to develop it on a personal repo to keep my messy commits private. Now that the product is ready, I need to migrate the work over to an open source repo, and update the cocoapod's source.
I tried changing the s.homepage and s.source lines of the podspec, but I get this fatal: Remote branch 1.0.0 not found in upstream origin error.
Updating spec repo `master`
Validating podspec
-> EvolvKit (1.0.0)
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/evolv-ai/EvolvKit.git /var/folders/jb/xlkpf4sn6fl9wtsh3g7pkqrh0000gp/T/d20190729-87754-7w53ir --template= --single-branch --depth 1 --branch 1.0.0
Cloning into '/var/folders/jb/xlkpf4sn6fl9wtsh3g7pkqrh0000gp/T/d20190729-87754-7w53ir'...
warning: Could not find remote branch 1.0.0 to clone.
fatal: Remote branch 1.0.0 not found in upstream origin
) during validation.
[!] The spec did not pass validation, due to 1 error and 1 warning.
➜ EvolvKit git:(master)
old pod spec:
Pod::Spec.new do |s|
# more configs
s.homepage = 'https://github.com/<personal_repo>/EvolvKit'
s.license = { :type => 'APACHE', :file => 'LICENSE' }
s.author = { 'PhyllisWong' => 'phyllis.wong#evolv.ai' }
s.source = { :git => 'https://github.com/<personal_repo>/EvolvKit.git', :tag => s.version.to_s }
# more configs
end
The new podspec lines changed:
s.homepage = 'https://github.com/<opensource_repo>/EvolvKit'
s.source = { :git => 'https://github.com/<opensource_repo>/EvolvKit.git', :tag => s.version.to_s }
Some things I tried are:
0. update git tag with version 1.0.0
1. updating the urls in the pod spec
2. clone the repo into a new directory, create a new git repo, and follow steps to trunk push
3. deleting the pod (was only able to delete versions) ...no one is using this pod btw.
4. considered changing the pod name, but that is less than ideal
Any ideas about a good way to go forward is greatly appreciated.
edit
Turns out I was missing a step in updating my repo with the git tag. Needed to push the tags.
Building off of my above comment about tagging the branch, did you git push --tags as well? Applying tags is a two step process, and without both, you can get the above error.

Linking the same framework to multiple targets in CocoaPods

I have a Swift project with some local frameworks that are linked with the main app. One of the frameworks requires a CocoaPod that the main project also requires elsewhere. Obviously I'd only like one copy. That seems to work fine, but the unit tests are getting confused. This is a slightly simplified version of the Podfile:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
# The main app target
target 'TheApp' do
pod 'Instabug'
target 'TheAppTests' do
inherit! :search_paths
pod 'OHHTTPStubs/Swift'
end
end
# A framework target that's linked by TheApp
target 'Logging' do
pod 'Instabug'
target 'LoggingTests' do
inherit! :search_paths
end
end
I believe I'm supposed to nest the test targets inside their subject. TheApp imports Logging. Both import Instabug. TheAppTests has a host application of TheApp. LoggingTests has not host application.
I get Pods-TheApp, Pods-TheAppTests, and Pods-Logging the way I expect. Sometimes I get Pods-LoggingTests and sometimes I get Pods-Logging-LoggingTests. (This turns out to be tied to the inherit setting. If it's not set, then I get Pods-Logging-LoggingTests; if it is set to search_paths then I get Pods-LoggingTests.)
I'm often getting errors that Instabug isn't copied into the LoggingTest bundle, or I get errors that Instabug has been processed twice. The app itself seems to work fine. It's just that unit tests fail. (There are several other local frameworks that don't have any dependencies, and I don't list them in the Podfile.)
Note that all the framework targets live in one xcodeproj.
I suspect I'm just writing the Podfile incorrectly. Is there a canonical way to handle local (non-pod) frameworks that have their own tests and their own dependencies that match the app's?
This is CocoaPods 1.7.0. I had the same issue with 1.6.2.
I faced the same issue and I personally found it much easier to manage pods in a linear way and creating helper methods for referring each pod. This way when you share a pod among projects, you update the pod version only in one place:
platform :ios, '11.0'
inhibit_all_warnings!
use_frameworks!
##
## Group pods
##
def alamofire_pods
pod 'Alamofire', ~> '4.0'
end
def snapkit_pods
pod 'SnapKit', '~> 4.0'
end
#
# Now, lets create all subprojects and main project pod dependencies
#
target 'MySubproject' do
project 'rel_path_to/subproject.xcodeproj'
alamofire_pods
target 'MySubproject Tests' do
inherit! :complete
end
end
# Following same pattern for all other subprojects
target 'MainProject' do
project 'Mainproject.xcodeproj' # path to main project
snapkit_pods
alamofire_pods
target 'Mainproject Unit Tests' do
end
end
target 'Mainproject UI Tests' do
# specific pods for your UI Test
end
This approach worked the best and helped with running also subproject tests in the project.
Rule of thumb, also always make sure to remove old pod references from your project. That was causing issues in my case and throwing errors when building for unit tests I believe for subprojects. Cocoapods doesn't clean the old pod target references from your project's build phase.
Note pod install shouldn't change the pod target name if you don't change anything in your podfile.
You can create abstract targets that your real targets inherit from, thereby having 2 sets of dependencies, some of which are shared.
This is what I do:
project "NSScreencast/NSScreencast.xcodeproj"
use_frameworks!
abstract_target "NSScreencast-Base" do
pod "Kingfisher"
pod "R.swift"
target "NSScreencast" do
platform :ios, "11.0"
pod "AppCenter"
pod "FXReachability"
pod "Colorkit"
pod "SVProgressHUD"
pod "1PasswordExtension"
pod "OneSignal", ">= 2.6.2", "< 3.0"
pod "Reveal-SDK", :configurations => ["Debug", "Debug-LocalServer"]
end
target "OneSignalNotificationServiceExtension" do
platform :ios, "11.0"
pod "OneSignal", ">= 2.6.2", "< 3.0"
end
target "NSScreencastTV" do
platform :tvos, "10.0"
end
end
This allows me to use the shared pods in multiple targets (here, iOS and tvOS) and have specific ones for each target as well.
Does this solve your problem?

None of your spec sources contain a spec satisfying the dependency

I am referencing the pod 'MatomoTracker' in my own pod
I get this error while linting : with pod lint spec
-> TrackerPod.v3 (0.0.1)
- ERROR | [iOS] unknown: Encountered an unknown error (CocoaPods could not find compatible versions for pod "Pods/MatomoTracker/MatomoTracker":
In Podfile:
TrackerPod.v3 (from `/Users/****/Documents/projects/ios/libs/TrackerPod.v3/TrackerPod.v3.podspec`) was resolved to 0.0.1, which depends on
TrackerPod.v3/Matomo (= 0.0.1) was resolved to 0.0.1, which depends on
Pods/MatomoTracker/MatomoTracker (= 5.2.0)
None of your spec sources contain a spec satisfying the dependency: `Pods/MatomoTracker/MatomoTracker (= 5.2.0)`.
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.) during validation.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error.
this is my podspec:
Pod::Spec.new do |spec|
spec.name = 'TrackerPod.v3'
spec.version = '0.0.1'
spec.license = 'Copyright ****'
spec.homepage = 'https://*******8/TrackerPod/blob/master/README.md'
spec.author = { '****' => '****#****.com' }
spec.summary = 'Some description'
spec.source = { :git => '****', :tag => spec.version.to_s }
spec.source_files = 'TrackerPod.v3/*.{h,m, swift}'
spec.ios.deployment_target = '8.0'
spec.osx.deployment_target = '10.10'
spec.requires_arc = true
spec.swift_version = '4.0'
spec.xcconfig = { 'SWIFT_VERSION' => '4.1' }
spec.dependency 'MatomoTracker', '5.2.0'
spec.subspec 'Matomo' do |lib|
lib.dependency 'Pods/MatomoTracker/MatomoTracker', '5.2.0'
lib.source_files = 'Pods/MatomoTracker/MatomoTracker/**/*.{h,m,swift}'
end
end
and, this is a screenshot to show my project navigator.
You can see that MatomoTracker is nested 2 levels downs inside 'Pods'
the project navigator
Am using the right path to reference MatomoTracker Pods/MatomoTracker/MatomoTracker, it does not seem to find the pod Matomoto ?
Am I correct ?
to answer the question. I kind of know where the error stands.
In my podspec, I am using spec.dependency 'MatomoTracker', '~> 5.2'
without the above the line, the validation passes
it seems that a higher minimum deployment target is required. I have update to deployment target as 11.0 everywhere.
- Podfile
- build settings (pod target) in Xcode
- spec ios target as well in the pod spec
and, this is the error I get
ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
ERROR | [OSX] unknown: Encountered an unknown error (CocoaPods could not find compatible versions for pod "MatomoTracker":
In Podfile:
TrackerPod.v3 (from `/Users/*****/Documents/projects/ios/libs/TrackerPod.v3`) was resolved to 0.0.1, which depends on
MatomoTracker (~> 5.2)
Specs satisfying the `MatomoTracker (~> 5.2)` dependency were found, but they required a higher minimum deployment target.) during validation.
Although I feel like I did by the book and as per the cocoapods guide, I am still missing sthg.
The MatomoTracker does not pass the validation

error installing package on a branch with install_github

I've forked a package from github have made some changes. I'm trying to install the version of the package to which I've made changes with install_github(), but am getting an error message. Any suggestions?
The forked version: https://github.com/embruna/refnet
The edited version on the branch: https://github.com/embruna/refnet/tree/proposed-updates
I can install the forked version with:
install_github("embruna/refnet", subdir="pkg")
I tried to install the version on the branch with the following:
install_github("embruna/refnet#proposed-updates", subdir="pkg")
But then get this error:
** help
*** installing help indices
** building package indices
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 1 did not have 6 elements
ERROR: installing package indices failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/refnet’
Error: Command failed (1)
Thanks for any suggestions.
EDIT: There were two problems: 1) the install_github syntax I used incorrect and 2) there was a folder in "pkg" that was throwing an error even after correcting the syntax. See below for details.
I'm guessing that specifying the branch with # but the subdirectory with the subdir argument is confusing devtools.
This works for me (specifying both subdir and branch in the repo argument):
install_github("embruna/refnet/pkg#proposed-updates",
So does this (specifying both branch and subdir as separate arguments):
devtools::install_github("embruna/refnet",
ref = "proposed-updates", subdir = "pkg")
The output starts this way ...
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo embruna/refnet#proposed-updates
from URL https://api.github.com/repos/embruna/refnet/zipball/proposed-updates
Installing refnet
This is with devtools 1.12.0
I was able to install your proposed-updates branch with this:
install_github("embruna/refnet", branch = "proposed-updates", subdir = "pkg")
I get a bunch of warnings, but no error messages.

Cocoapods - podspec validates but can't be pushed to repo

I am setting up a Swift framework through CocoaPods.
Goals are:
Use a private repo for the Podspecs
Have the framework to be distributed as binary (as opposed to source code)
I've read already the CocoaPods frameworks, Making a CocoaPod plus other references (can't seem to be able to include more than 2 links with current SO reputation but I can point sources in comments).
The Podspec I am using is:
Pod::Spec.new do |s|
s.name = 'SDK'
s.version = '0.0.1'
s.summary = 'My SDK'
s.description = 'SDKs description'
s.homepage = 'https://github.com/XXX/sdk'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'XXX' => 'xxx#xxx.com' }
s.source = { :git => 'https://github.com/XXX/sdk.git', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.platform = :ios, '9.0'
s.source_files = 'SDK/Classes/**/*'
s.preserve_paths = 'Frameworks/SDK.framework'
s.ios.vendored_frameworks = 'Frameworks/SDK.framework'
end
The Pods xcode project was changed to build also i386 arch besides the standard (arm64, armv7).
This spec successfully validates locally with, provided that I copy the SDK.framework file to the /Frameworks folder in the .podspec folder:
pod lib lint
Issue: when I try to push the spec to the repo, the validation fails as the output below show:
pod repo push mySDKPrivateRepo SDK.podspec
Validating spec
-> SDK (0.0.1)
- ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.
- ERROR | file patterns: The `preserve_paths` pattern did not match any file.
- ERROR | [iOS] file patterns: The `vendored_frameworks` pattern did not match any file.
[!] The `SDK.podspec` specification does not validate.
Questions:
How can I make the podspec validation successful when pushing it to repo?
Other notes:
Copying the SDK.framework to /Frameworks works manually.
If I include a Copy Files build step in the Pods Xcode project the file is not copied.
Using CocoaPods 1.1.0.
I was having a similar problem, the culprit was the project structure itself.
Be sure to check your at which directory you're pointing your source_files to. I've found that maintaining any kind of structure in this way is very difficult and it's easier to include all of your files in a single folder.
s.source_files = '<InsertName>/**/Classes/*'
Take a look at cocoapods advice on File Patters for some help on this.
By a process of elimination, I would suggest trying to push to the repo commenting out source_files in the podspec first, and work your way forward from there.