Travis CI not using master branch cache - travis-ci

I'm using Carthage as my project package manager and Travis CI.
The problem that I'm facing is that yesterday, Travis did create a cache from master branch correctly, as you can see in the picture below, and everything was working fine.
But today, when I did switch to another branch and pushed changes to it, Travis is not fetching the cache that it has made from master branch. Instead, it's creating a new cache for this branch that I've created. I want it to use master cache always, and don't try to create a cache for each branch that I create from master.
How should I proceed to achieve that?
Source Files:
.travis.yml
#Xcode 9.4 image default contents: https://blog.travis-ci.com/2018-07-19-xcode9-4-default-announce
#Need to create: "if: branch = master" and "if: branch = development"
language: swift
os: osx
osx_image: xcode10
sudo: required
cache:
directories:
- Carthage
before_install:
# Update Homebrew
- brew update
# Clean install Carthage
- brew uninstall --force carthage
- brew install carthage
- brew cask install fastlane
# Provide travis machines with github access
- echo -e "machine github.com\n login $CI_USER_TOKEN" >> ~/.netrc
# Print script to avoid travis_wait from stopping build process
- while sleep 480m; do echo "=====[ $SECONDS seconds, Carthage still building... ]====="; done &
# Carthage Bootstrap
- carthage bootstrap --cache-builds --platform ios,watchos --no-use-binaries
# Stop Print script
- kill %1
script:
- fastlane beta

Related

Flutter iOS build on the App Center fails with error: "Invalid Podfile file: Generated.xcconfig must exist

I've just set up my app to be built on the App Center, by following the article here.
Although the Android version builds and deploys fine on App Center, I'm getting an error with the iOS build, shown in the excerpt from the build output below:
==============================================================================
Task : CocoaPods
Description : Install CocoaPods dependencies for Swift and Objective-C Cocoa projects
Version : 0.151.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/cocoapods
==============================================================================
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod --version
1.9.1
[command]/usr/local/lib/ruby/gems/2.6.0/bin/pod install --repo-update
[!] Invalid `Podfile` file: Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first.
# from /Users/runner/runners/2.165.2/work/1/s/bdstories/ios/Podfile:51
# -------------------------------------------
# unless File.exist?(generated_xcode_build_settings_path)
> raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
# end
# -------------------------------------------
##[error]The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[error]The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/2.6.0/bin/pod' failed with exit code 1
##[section]Finishing: Pod install
##[section]Starting: Xcode build (signed)
My build script is:
#!/usr/bin/env bash
# Place this script in project/ios/.
# Fail if any command fails.
set -e
# Debug log.
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel beta
flutter doctor
echo "Installed flutter to `pwd`/flutter"
# Build the app.
flutter build ios --release --no-codesign
I did add the flutter pub get as mentioned in the error, but that didn't make a difference. Also worth noting that the build works fine when I do it in Xcode locally. I can also deploy the built archive to Testflight with no problems. It's just the App Center build process I'm having issues with.
I'm a bit lost now and I can't find any information on how to resolve this. I'm also new to CI/CD, so any help appreciated!
Update
I've also tried adding the following to the script to force App Center to run the same version of Cocoapods as my local machine, but it didn't make a difference to the error.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.9.1
pod setup
I did this to my post-clone script and it worked:
#!/usr/bin/env bash
#Place this script in project/ios/
echo "Uninstalling all CocoaPods versions"
sudo gem uninstall cocoapods --all --executables
COCOAPODS_VER=`sed -n -e 's/^COCOAPODS: \([0-9.]*\)/\1/p' Podfile.lock`
echo "Installing CocoaPods version $COCOAPODS_VER"
sudo gem install cocoapods -v $COCOAPODS_VER
# fail if any command fails
set -e
# debug log
set -x
pod setup
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel master
flutter doctor
flutter pub get
echo "Installed flutter to `pwd`/flutter"
flutter build ios --release --no-codesign
The trick seems to have been moving the "fail if any command fails" section to after the pod re-installation
I had the same issue. It happens when the appcenter-post-clone.sh fails to run, so, the flutter is not installed and the command flutter build ios does not run to generate the Generated.xcconfig.
To fix it, I just:
Deleted the appcenter-post-clone and pushed this commit
Opened the configuration of the branch, on Build section. Now the post-clone tag has gone. Save it.
Push another commit with the appcenter-post-clone.sh again.
Configure the branch again, now with the post-clone tag back.
Save & Build.
Check your .gitIgnore. Had the same issue due to the file being excluded from the repo.
Once added back everything went fine.
Be also careful on the Paths defined for Flutter in your project.
1- Navigate to the flutter module directory
2- Do a flutter pub get
** Also make sure that you are on the stable channel "Flutter"
It appears to work now. I think there's been an update to the App Center build process.
For your info, I've included my final post-build script below, in case this is useful:
#!/usr/bin/env bash
#Place this script in project/ios/
# fail if any command fails
set -e
# debug log
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel beta
flutter doctor
echo "Installed flutter to `pwd`/flutter"
flutter build ios --release --no-codesign
I encountered the same issue after I copied an existing build profile from another branch. The problem was resolved after deleting the build config and creating a new one from scratch for the target branch.
Try to enter the IOS folder then pod installor
pod update
in the terminal

Bamboo job with cocoapods giving error: You cannot run CocoaPods as root

I am trying to set up a remote Bamboo agent as a CI for my iOS development. I am using Fastlane to run tests, create builds etc.
The problem I am having is that in Fastlane I want to clear and reinstall all of my pod files. There is a built in action to fastlane that handles both of these tasks: clean_cocoapods_cache and cocoapods.
When I run my lane with the these actions I get an error in Bamboo:
You cannot run CocoaPods as root. (CLAide::Help)
When I run the lane locally this error does not occur. However if I run the lane locally with sudo permissions I do in fact get the same error.
So it appears that Bamboo jobs are all run as root user by default when doing so through a remote agent. Is there any way I can change/control this so that the job runs without this level of access?
Instead of doing this cocoapod operation in Fastlane I then tried to run this as a script directly in the Bamboo job using this code:
rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; pod install;
however this gave the same error as before.
I have scoured the internet but apparently not many others have this problem, which is surprising as I would have thought iOS development would be popular on Bamboo and most projects are using CocoaPods.

TravisCI - ERR : Package flute_music_player requires Flutter SDK version ^0.1.2 but the current SDK is 0.0.0-unknown

I am new travis and started working on it with flutter.
I am using flute_music_player plugin for my music player app.
Now app is working/building fine locally on my machine but I cant build it on Travis
Here is what I get
$ ./flutter/bin/flutter test
Running "flutter packages get" in tumultus...
Package flute_music_player requires Flutter SDK version ^0.1.2 but the current SDK is 0.0.0-unknown.
---- Log transcript ----
.
.
.
.
---- End log transcript ----
pub get failed (1)
The command "./flutter/bin/flutter test" exited with 1.
store build cache
nothing changed, not updating cache
Done. Your build exited with 1.
Here is the link to my complete Job log.
And my travis.yml is :
os:
- linux
sudo: false
addons:
apt:
# Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
sources:
- ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version
packages:
- libstdc++6
- fonts-droid
before_script:
- git clone https://github.com/flutter/flutter.git -b alpha --depth 1
- ./flutter/bin/flutter doctor
script:
- ./flutter/bin/flutter test
cache:
directories:
- $HOME/.pub-cache
My complete project can be found on github here
Actually I have copied most of the code from here and I tried to run his project on travis but same error on log.
Is there anywhere I am lacking, please help.
Thanks for any help or suggestions in advance.
Alright the Issue was with plugin version not actually Travis.

on mac os sierra, stuck on "Setting up CocoaPods master repo"

After moving to mac os sierra, I completely formatted my mac now I'm facing problem to install cocoapods, every time I run sudo gem install cocoapods --pre
every thing installed well, and when I try to install a pod, the terminal stack on Setting up CocoaPods master repo
.
Already updated the system with sudo gem update --system and still got the same problem, searched online to found old answers to use pod install --verbose
Ss I found in THIS answer fail again tells to install it manually.
NOTE : I have the latest version of 'Command Line Tools'. Any suggestion or how to install master repo manually?
From https://stackoverflow.com/a/21852985/1033581:
on 4th Nov 2016, the repo is 1.07 GB
From https://stackoverflow.com/a/33699136/1033581:
To get a progression, you can clone master yourself:
pod repo remove master
git clone https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
pod setup
In my first installation, I got the same problem too, it takes too much time in "setting up master repo".
Actually, you can see it through "activity monitor" that it's actually downloading, but it seems the connection is slow from the server.
Try these steps, it solves my problem:
1. pod setup
It will do "setting up master" again, don't wait, continue these steps below:
2. Ctrl +C
3. pod repo remove master
4. cd ~/.cocoapods/repos
5. git clone --depth 1 https://github.com/CocoaPods/Specs.git master
It takes less than 7 minutes for me (I think it depends on internet connection), then I can do pod install.

how can I homebrew install gradle 1.12?

I currently have gradle 1.10
I have tried:
brew versions gradle
and then:
git checkout 8ef0672 /usr/local/Library/Formula/gradle.rb
because I saw:
1.12 git checkout 8ef0672 /usr/local/Library/Formula/gradle.rb
but got this error:
fatal: Not a git repository (or any of the parent directories): .git
how can I install specific gradle version using homebrew?
Do something like this:
cd $(brew --prefix)
brew versions gradle
## copy and run the git checkout for your desired gradle version
brew unlink gradle
brew install gradle
That worked for me. I am on a Mac OSX though.
First the problem with your git request, is you are trying to pull a non git repository. An example of what a git repo looks like is
https://github.com/gradle/gradle.git
Also you you might be struggling with the wrong version being listed in your ruby dependencies file.
However to install another version of gradle (assuming you have the most recent one, if you don't I can help too):
Check to see if you have the older version of gradle with: $ brew info gradle
If the version you want exists, switch versions $ brew switch gradle SOME_VERSION where you replace SOME_VERSION with the version number you want (and was shown to be installed).
In the interest of not being redundant, if you don't have the version desired installed refer to this other post: Homebrew install specific version of formula?
To install different versions of the software package with homebew,
brew tap homebrew/versions
Search for the desired package:
brew search gradle
The results :
gradle homebrew/versions/gradle18 homebrew/versions/gradle24
homebrew/versions/gradle110 homebrew/versions/gradle20 homebrew/versions/gradle26
homebrew/versions/gradle112 homebrew/versions/gradle21 homebrew/versions/gradle27
homebrew/versions/gradle16 homebrew/versions/gradle221 homebrew/versions/gradle28
Caskroom/cask/qlgradle
Now chose your desired version:
brew install homebrew/versions/gradle112

Resources