How to specify a username for a private pod - cocoapods

I am setting up a private pod that will be used across our team. In my podfile I have something like:
pod 'MySDK', :git => 'https://myusername#bitbucket/...git'
Is there a way to replace myusername with the username that downloaded the current project.
I can get the current username by parsing the url from
git config --get remote.origin.url
Plan B is to make a script that modifies the podfile before running pod install. I am curious if I can make it without this extra step?

This is what I came up, below is part of my podfile
#try to keep the current git user in the pod url
remoteUrl = %x|git config --get remote.origin.url|
username = remoteUrl.scan(/[A-Z0-9._%+-]+#[A-Z0-9.-]+\.[A-Z]{2,4}/i).first
podUrl = "https://#{username}/mycompany/myrepo.git"
puts podUrl
pod 'MySDK', :git => podUrl, :commit => 'commitid'
Works great for me! Respect to all cocopods devs that made it so customizable!

Related

Different result on CocoaPod install with identical Podspecs for EarlGrey 2.0 app

I am trying to figure out why I get two different results after running pod install on what should be identical podspec files. The component is called EarlGreyApp, which had a 2.0.0 release this year. The podspec for the 2.0.0 release is here in the earlgrey2 branch of the EarlGrey repo: https://github.com/google/EarlGrey/blob/earlgrey2/EarlGreyApp.podspec
When I have this defined in the podfile (I am using Demo/EarlGreyExample to reproduce) :
target 'EarlGreyExampleSwift' do
pod 'EarlGreyApp', '2.0.0'
end
It correctly modifies this section of EarlGreyExample.xcodeproj/project.pbxproj to reference EarlGrepApp's AppFramework.framework component:
/* Begin PBXShellScriptBuildPhase section */
4D216774E658C2E4470F936E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-EarlGreyExampleSwift/Pods-EarlGreyExampleSwift-frameworks.sh",
"${PODS_ROOT}/EarlGreyApp/AppFramework.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AppFramework.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-EarlGreyExampleSwift/Pods-EarlGreyExampleSwift-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
However when I change the podfile to point to the branch:
target 'EarlGreyExampleSwift' do
pod 'EarlGreyApp', :git => 'https://github.com/google/EarlGrey.git', :branch => 'earlgrey2'
end
The above section does not get generated into the project.pbxproj file.
I am at a loss to explain why as the podspec registered for EarlGreyApp should be the same. When I do pod spec cat EarlGreyApp I see the same contents as what is in the earlgrey2 branch.
pod spec cat EarlGreyApp --show-all
Shows me that there are only two Podspecs available, 2.0.0 and 2.0.0-rc
Any ideas on what the difference could be?
The reason for this is because the Podspec is not published through the earlgrey2 branch it is published through the earlgrey2pod branch.
The reason for this is some users want to use EarlGrey without CocoaPods and some want to use it with. The two branches have subtle differences to allow for both use cases (compiling issues).
Additionally there are further intricacies with CocoaPods when you do a manual pod install, as you did when you referenced the github directly. I would recommend not trying that. Since EarlGreyApp is compiled as a Framework you cannot just do that unfortunately (you can with EarlGreyTest which is compiled from source). CocoaPods has poor undefined behavior in this regard.

Error pushing to cocoapod trunk

I'm receiving "[!] An internal server error occurred. Please check for any known status issues at https://twitter.com/CocoaPods and try again later." when trying to push a new version of my pod NRSPieChart. I just created this last night and it's the my first time creating my own pod. Everything seemed to have worked on the first submission. Today I updated my version in order to expand my example project and expand my README.md file to provide better Usage instructions. Upon trying to push to Trunk though I get the above error. Since I'm new to this my assumption is I've done something wrong rather than coincidentally there's an error with the spec repo?
I saw one reference to the s.source tag might need a hard code tag string. I tried that but same problem. This is the before (commented line) and after of that attempt:
# s.source = { :git => 'https://github.com/neils4fun/NRSPieChart.git', :tag => s.version.to_s }
s.source = { :git => "https://github.com/neils4fun/NRSPieChart.git", :tag => "0.1.1" }
Update: I tried again "later" as the error message suggested and it's now working. I made no changes to my pod code or pod spec, so chalk this up to something internal on the cocoa pods side of the fence.

Deploy path doesn't work for Git Deploy Method in middleman-deploy

I am using middleman-blog and middleman-deploy.
What I would like to do, is within the branch I am deploying to, I want the static files to be deployed to a subfolder within the repo (i.e. not the root folder).
I tried doing this in my config.rb:
activate :deploy do |deploy|
deploy.build_before = true
deploy.deploy_method = :git
deploy.branch = 'gh-pages-2'
deploy.remote = 'github'
deploy.path = 'blog'
end
But that doesn't work, it still deploys to the root directory. In fact, it doesn't even create the /blog folder I am looking for.
When I visit the config settings locally, these are the settings I see under :deploy:
:deploy
:branch = "gh-pages"
:build_before = true
:clean = false
:commit_message = nil
:deploy_method = :git
:flags = nil
:host = nil
:password = nil
:path = "blog"
:port = 22
:remote = "github"
:strategy = :force_push
:user = nil
This indicates to me that the path attribute is being set correctly.
I also tried doing deploy.path = '/blog' and that still doesn't work.
So how can I get this to deploy to \blog\ subfolder within my repo rather than the root directory?
The versions of the different gems are as follows:
middleman (4.1.10)
middleman-blog (4.0.1)
middleman-cli (4.1.10)
middleman-deploy (2.0.0.pre.alpha)
Note: I am purposely using gh-pages-2 because I don't want to overwrite my current gh-pages without being certain that it will deploy to the correct subfolder.
I think the easiest thing you could do is write an extension with an after build step: https://middlemanapp.com/advanced/custom-extensions/#after_build. That way you move the files during your build process and middleman-deploy just can push the whole build folder.
If the root of your site is also deployed on Github Pages you can create another repo called blog and deploy your middleman site there. Then by enabling GitHub Pages for the blog repo, you will actually have it deployed on yoursite.com/blog.
It is not the techiest solution you 'd expect but it works well for me

Cocoapods and SVN

How can I use the pods files from a remote SVN server, a private server protected by username and password, after creating the complete structure needed for Cocoapods ?
thanks
Update
Move the all sources inside a sub-directory named with version of sources (eg trunk/2.0.0) and declare it on pod like below :
pod 'MyLibrary', :svn => 'http://svn-your-ip/svn/MyLibrary/trunk/2.0.0'
The easiest variant would be to create a local checkout, and then reference the path like so:
pod 'AFNetworking', :path => '~/Documents/AFNetworking'

RestKit 0.2 not logging

I'm updating my app to use RestKit 0.2pre3, but on the process I lost the logging system that RestKit provides, it simply doesn't show anything anymore. I use cocoapods to install RestKit.
This is my Podfile
platform :ios , '5.1'
pod 'SSPullToRefresh'
pod 'MBProgressHUD'
pod 'Facebook-iOS-SDK'
pod 'TestFlightSDK'
pod 'SDWebImage'
pod 'KISSmetrics'
pod 'CustomBadge'
pod 'GoogleAnalytics-iOS-SDK'
pod 'JSONKit'
pod 'LibComponentLogging-Core'
pod 'LibComponentLogging-LogFile'
pod 'LibComponentLogging-qlog'
pod 'LibComponentLogging-pods'
pod 'RestKit/Testing'
pod 'RestKit'
pod 'OHAttributedLabel'
And, of course, in my code I'm calling
RKLogConfigureByName("RestKit", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
RKLogConfigureByName("RestKit/CoreData", RKLogLevelDebug);
I can even make successful request and get objects mapped, but I can't watch what is my server returning, how the mapping process is performed or anything and this is vital.
I think the problem is that something is misconfigured in LCL but I can't find any clues about it.
Any ideas where the problem could be?
After a long debugging I found that LCL now comes with a set of default configurations and on LCLLogFileConfig.h I had:
// Tell LCLLogFile whether it should mirror the log messages to stderr.
#define _LCLLogFile_MirrorMessagesToStdErr /* (BOOL) */ \
NO
I set it to YES and now everything is working fine.
This behavior is caused by the following 2 pods in the Podfile:
pod 'LibComponentLogging-pods'
pod 'LibComponentLogging-LogFile'
The LibComponentLogging-pods pod causes an integration of RestKit's logging with the LibComponentLogging files which are installed via the Podfile, e.g. RestKit's log components can now be configured via the standard lcl_configure... configuration functions and RestKit will use the log writer which is configured via the Podfile (instead of its built-in log writer).
The LibComponentLogging-LogFile pod chooses the file-based log writer for LibComponentLogging. By default, this log writer doesn't mirror its messages to stderr. _LCLLogFile_MirrorMessagesToStdErr in LCLLogFileConfig.h can be used to change this behavior.

Resources