Skip to content

Instantly share code, notes, and snippets.

@tareq3
Last active August 30, 2022 19:47
Show Gist options
  • Save tareq3/02e07579edff306d97d100ebc149942c to your computer and use it in GitHub Desktop.
Save tareq3/02e07579edff306d97d100ebc149942c to your computer and use it in GitHub Desktop.
## 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
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/PcttLaFsPA9IdKoR9GKa9KBHGZlq0ly0/33bmox46o.png)
### 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
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/l5eF-9kRtd3lnf1VZXBk9fsPwZS3HUXA/h6zq75h5f.png)
### Step 4: Update Gemfile add cocopod gem for running pod commands
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/MBOqlkDPcNDpeYpYIF0nmhQxFRKVot2_/sn9iu4z69.png)
```
source "https://rubygems.org"
gem "cocoapods"
gem "fastlane"
```
## Step 5: Open the fastfile from fastlane directory
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/BXkWU76XxwSpIxiJSMyplbDaWlqF95jc/5v1bl77dw.png)
```
# 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
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/1XbpINKjfh7ZV2dKeFcAxDi_au4xwOxh/g53pp5eoc.png)
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
```
![](https://cdn.cacher.io/attachments/u/397rshf2ej0sc/GHomwHJ7nmhJF9ZdtsWciQ3UiSUjQGwN/dxnjx7u7x.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment