Last active
August 30, 2022 19:47
-
-
Save tareq3/02e07579edff306d97d100ebc149942c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## How we can publish a xcframework to cocoapod with a single command | |
### Step 1: We have to make sure we can publish the framework to cocoapod manually | |
### Step 2: Then start a terminal from remote repo directory which holds the framework and podspec file | |
 | |
### Step 3 : Run `fastlane init` command to initialize fastlane in this directory and press "4" when to select manual deploy | |
This should generate fastlane directory and Gem files and Gemfile.lock | |
 | |
### Step 4: Update Gemfile add cocopod gem for running pod commands | |
 | |
``` | |
source "https://rubygems.org" | |
gem "cocoapods" | |
gem "fastlane" | |
``` | |
## Step 5: Open the fastfile from fastlane directory | |
 | |
``` | |
# This file contains the fastlane.tools configuration | |
# You can find the documentation at https://docs.fastlane.tools | |
# | |
# For a list of all available actions, check out | |
# | |
# https://docs.fastlane.tools/actions | |
# | |
# For a list of all available plugins, check out | |
# | |
# https://docs.fastlane.tools/plugins/available-plugins | |
# | |
# Uncomment the line if you want fastlane to automatically update itself | |
# update_fastlane | |
default_platform(:ios) | |
$podspec_name = "RandomCars.podspec" | |
$framework_name = "RandomCars.xcframework" | |
platform :ios do | |
desc "Release a new version with a patch bump_type" | |
lane :patch do | |
release("patch") # we could use __method__.to_s instead of duplicating the name | |
end | |
desc "Release a new version with a minor bump_type" | |
lane :minor do | |
release("minor") | |
end | |
desc "Release a new version with a major bump_type" | |
lane :major do | |
release("major") | |
end | |
def release(type) | |
pod_lib_lint( | |
allow_warnings: true | |
) | |
version = version_bump_podspec(path: $podspec_name, | |
bump_type: type) | |
git_add(path: [$podspec_name, "."], shell_escape: false) | |
git_commit(path: [$podspec_name, "."], | |
message: "#{version} release") | |
add_git_tag(tag: "#{version}") | |
push_to_git_remote | |
pod_push( | |
allow_warnings: true | |
) | |
end | |
end | |
``` | |
## As on line 42 and 46 we are saying we should add all item on this directory | |
we need to add a .gitignore file which will skip fastlane files | |
``` | |
.gitignore | |
Fastlane/ | |
Gemfile | |
Gemfile.lock | |
``` | |
## Final: As we have created 3 lane we can run any of them minor , major or patch | |
``` | |
fastlane minor | |
``` | |
OR | |
``` | |
bundle exec fastlane minor | |
``` | |
## Tips : If you are having any issue regarding ruby | |
make sure you are using ruby from homebrew not from mac | |
``` | |
which ruby | |
``` | |
this command should say | |
 | |
If you are seeing different make sure you install ruby using homebrew | |
and path in .zshrc like below | |
``` | |
if [ -d "/opt/homebrew/opt/ruby/bin" ]; then | |
export PATH=/opt/homebrew/opt/ruby/bin:$PATH | |
export PATH=`gem environment gemdir`/bin:$PATH | |
fi | |
``` | |
 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment