Automating the folder creation and push the xcframework in Git repo - ios

I am trying to automate the xcframework creation in my pipeline for every commit and upload it to the folder created in its Tag name just like below,
e.g. LoggerFramework(Root) -> 1.0.0(tag number) -> Logger.xcframework
1.0.1 -> Logger.xcFramework
If folder with tag name already exists, then the latest xcframework should be uploaded, else new folder with newly created tag should be created and xcframework should be created to git repo.
I am trying the below script in my pipeline for every code merge.
# Pushing the framework to remote Git path
function pushFrameworkToGit {
# Change the current working directory to the newly created directory:
cd ${DYNAMIC_FRAMEWORK}
cd frameworks/xcframeworks
# Push the frameworks to a remote repository
git init
# Create a directory:
mkdir ${DYNAMIC_FRAMEWORK}
# Get the latest Git tag
TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
# Create a folder with the name of the Git tag
mkdir "$TAG"
git add ${DYNAMIC_FRAMEWORK}.xcframework
git commit -m "Initial commit of ${DYNAMIC_FRAMEWORK}"
git remote add origin "http://XXX.xx.xxx/xxx/xxx/frameworks.git"
git push -u origin master
}
But I am getting below error,
error: src refspec master does not match any error: failed to push
some refs to "http://XXX.xx.xxx/xxx/xxx/frameworks.git"
Also I am not sure how to take care of automatic folder creation and ignoring if the folder already exists.

Related

The RWPickFlavor.podspec specification does not validate

I'm learning by following this tutorial:
https://www.raywenderlich.com/5823-how-to-create-a-cocoapod-in-swift
And I'm stuck in the place where it says:
Using Your New CocoaPod
in the terminal I wrote:
cd ~/Documents/Libraries/RWPickFlavor
pod repo add RWPodSpecs https://github.com/user/RWPodSpecs.git
pod repo push RWPodSpecs RWPickFlavor.podspec
but I get a lot of errors:
[!] /usr/bin/git clone https://github.com/user/RWPodSpecs.git -- RWPodSpecs
fatal: destination path 'RWPodSpecs' already exists and is not an empty directory
and:
Validating spec
-> RWPickFlavor (0.1.0)
- NOTE | url: The URL (https://github.com/user/RWPickFlavor) is not reachable.
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/user/RWPickFlavor.git /var/folders/bw/h527d_4x6yb7rv3tdrldty1c0000gn/T/d20220525-6530-de485a --template= --single-branch --depth 1 --branch 0.1.0
Cloning into '/var/folders/bw/h527d_4x6yb7rv3tdrldty1c0000gn/T/d20220525-6530-de485a'...
warning: Could not find remote branch 0.1.0 to clone.
fatal: Remote branch 0.1.0 not found in upstream origin
) during validation.
[!] The `RWPickFlavor.podspec` specification does not validate.
Any ideas?
I had this very issue and here is how I resolved it:
Verify you are in the ~/Documents/Libraries/RWPickFlavor directory before performing any commands in Terminal.
Verify that the contents of RWPickFlavor.podspec are correct. Mine was not and, if something is wrong, then it will not validate the Podspec.
I went ahead and deleted the remote repository on GitHub and then ran rm -rf .git (again, make sure you are in ~/Documents/Libraries/RWPickFlavor). This step might be excessive, but I figured I had missed something when pushing to GitHub and, since this was just an initial commit, I did not feel like it really harmed anything. Yes, I am aware this is not best practice with regards to version control.
I then went ahead and recreated the remote repository on GitHub.
With the remote repository once again available, I did the following:
git init
git add .
git commit -m "Initial commit"
git tag 0.1.0
git branch -M main
git remote add origin https://github.com/user/RWPickFlavor.git
git push -u origin main --tags
pod repo push RWPodSpecs RWPickFlavor.podspec
Explanation: I think I/we might have forgotten the tag creation in the process and also forgot to include it in the push. Before I deleted the remote repo, I noticed that there was no tag and, even if I added a tag, the Podspec still would not validate.
Hope this is helpful.

How to ignore untracked files

Untracked files:
(use "git add ..." to include in what will be committed)
META-INF/
classes/
repository/
sample-2.0.9-SNAPSHOT-mule-application.jar
temp/
test-classes/
the above are untracked files and i want jar file and ignore other file.
basically i am doing is trying to push jar files from jenkins to bitbucket.
and i facing issue is when i do changes in that particular pom file and push again i am facing this issue. although i tried adding .gitignore file but i am unable to over come this problem.
It will be helpful if you help me with this error
and the jenkins file code looks like:
stage('bitbucket deploy') {
steps {
script{
GIT_CREDS = credentials('bitbucket-server-cred')
sh '''
echo "${WORKSPACE}"
cd ${WORKSPACE}/target
git init
git config --global user.name "admin"
git status
git remote add origin http://***:*****#**:***:**:***:7990/scm/or/lla-esb-artifactory.git
git remote -v
git pull origin master --allow-unrelated-histories
git add -f *.jar
git status
git commit -a -m "push into bitbucket"
git push origin master
'''
}
Thanks in advance
It seems like you are missing the step of actually creating the JAR file. Untracked files are not staged or committed, and it will not be pushed into the git repo. When you perform the git pull, it pulls the master branch from your remote. But since you are not tracking the JAR file, it means that it is not being uploaded to git to begin with.
The ideal thing to do here would be to build the JAR file after pulling the repo using mvn package or whatever action you have in your POM to build the JAR file. Remember to clean your workspace when the build stage is complete.
Alternatively, since it seems that all you are doing in this build step is including the JAR file in the repo, you can run git add *.jar to add the JAR file to the repo where you have it as an untracked file, and remove this build step, since the file will be in the repo to begin with.

Push Workspace with multiple projects on Bitbucket repository

I have Xcode workspace which has multiple projects - the main project and a pod project. How do I push the code (the first time) on Bitbucket so that everything is set on repository ? Attached is the project structure just for clarification
This is the folder structure I have
All you got to do is go to the Project folder in Terminal and follow the below commands in the same order. I am assuming both your main project and pod project are inside the same folder
So in terminal go inside your first AppIT folder. If you run command ls -l in terminal on that folder you will see a list of all folders and files inside it like AppIt, .xcodeProj file, Pod folder, Podfile etc. Just run the below commands on that location where you see this list.
git init
git add -A .
git commit -m "first commit"
git remote add origin https://github.com/.... .git // your complete URL
git push -u origin master

I am getting fatal message i.e not a git repository, when I am typing "git add ." in git command prompt.

I wanted to add screen shot of that, but i didn't have that much reputation as I am new to this. I am getting fatal message i.e not a git repository, when I am typing "git add ." in git command prompt. I am currently new to ruby on rails.What should I do?
It sounds to me that when you are executing git add . your current directory is not part of the working tree of a git repository.
Make sure that there is a .git folder (containing the Git repository) in you current directory or a parent directory of the current directory. If there is not, you need to properly initialize a git repository by git clone (if you are starting from some other git repository) or git init (if you are starting a new repository).

How to install a plugin from github?

I have tryed to run this code in my console:
script/plugin install git://github.com/apotonick/cells.git
...but i only get an empty folder named "cells" in my "vendor/plugins" dir.
What's wrong?
Check you Git version.
This may be related with you gitconfig file, as described in this thread
The reason is that it appears rails-2.3.5/lib/commands/plugin.rb is trying use git pull to grab the plugin code (see the install_using_git method), which doesn't work right.
Example:
script/plugin install git://github.com/fesplugas/typus.git
mkdir vendor/plugins/typus
cd vendor/plugins/typus
git init
git pull --depth 1 git://github.com/fesplugas/typus.git
That last line exits 1, but that error is being masked by the install_using_git method, and the directory is just rm -rf'ed.
I tracked this down to a conflict with ~/.gitconfig. If I remove these lines it works:
[branch "master"]
remote = origin
merge = refs/heads/master
It appears a naked git pull has problems with these settings.
Actually, the problem would be here because of a global git config file (in your homedir: '~/.gitconfig'), defining a master which may be incompatible with the master expected by the git pull within that specific Git repo.

Resources