Skip to content

Commit

Permalink
Fix Lottie SPM (#171)
Browse files Browse the repository at this point in the history
* feat: add lottie to SmileID project as well

* feat: resolved packages

* feat: add updating compile sources to primary workflow

* feat: build for spm on every PR

* feat: modify build script

* feat:test

* feat:add product name to lottie

* feat: bump version to 10.1.3
  • Loading branch information
JNdhlovu authored May 15, 2024
1 parent fbb082e commit 3261ca1
Show file tree
Hide file tree
Showing 10 changed files with 1,029 additions and 377 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/sdk-primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
uses: actions/checkout@v4
- name: Install bundle
run: bundle install
- name: Update Compile Sources
run: ruby ./Scripts/update_compile_sources.rb
- name: Write Smile Config
id: write_smile_config
# Mask the config so that it doesn't show up in the logs
Expand All @@ -63,5 +65,8 @@ jobs:
xcode: '15.2'
- name: Build Example app and Run Unit Tests
run: |
xcodebuild -resolvePackageDependencies
bundle exec rake test:spm
bundle exec rake provision:ios
bundle exec rake test:package
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## 10.1.3

#### Fixed

* Fix lottie SPM dependancy issues

## 10.1.2

#### Fixed
Expand Down
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
}
},
{
"identity" : "zip",
"kind" : "remoteSourceControl",
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/marmelroy/Zip", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/airbnb/lottie-spm.git", from: "4.4.2")
.package(url: "https://github.com/airbnb/lottie-spm", from: "4.4.2")
],
targets: [
.target(
name: "SmileID",
dependencies: ["Zip", "lottie-spm"],
dependencies: ["Zip", .product(name: "Lottie", package: "lottie-spm")],
path: "Sources/SmileID",
resources: [.process("Resources")]
),
Expand Down
18 changes: 14 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace :test do

desc 'Tests Swift Package Manager support'
task :spm do
xcodebuild('build -scheme "SmileID" -destination generic/platform=iOS')
xcodebuild('build -scheme "SmileID" -destination generic/platform=iOS',"SmileID.xcodeproj")
end
end

Expand All @@ -82,18 +82,28 @@ namespace :format do
end
end

def xcodebuild(command)
def xcodebuild(command, project = "Example/SmileID.xcworkspace")
# Determine the project flag based on the file extension
project_flag = if project.end_with?(".xcworkspace")
"-workspace"
elsif project.end_with?(".xcodeproj")
"-project"
else
raise ArgumentError, "Invalid project type. Must be .xcworkspace or .xcodeproj"
end

# Check if the mint tool is installed -- if so, pipe the xcodebuild output through xcbeautify
`which mint`
sh 'rm -rf ~/Library/Developer/Xcode/DerivedData/* && echo "Successfully flushed DerivedData"'
if $?.success?
sh "set -o pipefail && xcodebuild #{command} -workspace Example/SmileID.xcworkspace | mint run thii/[email protected]"
sh "set -o pipefail && xcodebuild #{command} #{project_flag} #{project} | mint run thii/[email protected]"
else
sh "xcodebuild #{command} -workspace Example/SmileID.xcworkspace"
sh "xcodebuild #{command} #{project_flag} #{project}"
end
end



namespace :provision do
desc 'Provision the app for building'
task :ios do
Expand Down
28 changes: 18 additions & 10 deletions Scripts/update_compile_sources.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# We use the Example/SmileID.xcworkspace when
# updating that it may not update the
# updating that it won't update the
# SmileID.xcodeproj on the root of the project
# Which is used for SPM and Carthage
# this will not affect the Example project

require 'xcodeproj'

project_path = 'SmileID.xcodeproj'
project = Xcodeproj::Project.open(project_path)

target = project.targets.find { |t| t.name == 'SmileIDFramework' }
sources_build_phase = target.source_build_phase
# Update a target with the Swift files
def update_target(project, target_name)
target = project.targets.find { |t| t.name == target_name }
return unless target

sources_build_phase = target.source_build_phase

# Remove all files
sources_build_phase.clear
# Remove all files
sources_build_phase.clear

# Add all Swift files from the Sources folder in alphabetical order to avoid
# having these be different every time Carthage is run and or this is run locally
Dir.glob(File.join('Sources', '**', '*.swift')).sort.each do |file|
sources_build_phase.add_file_reference(project.new_file(file))
# Add all Swift files from the Sources folder in alphabetical order
Dir.glob(File.join('Sources', '**', '*.swift')).sort.each do |file|
sources_build_phase.add_file_reference(project.new_file(file))
end
end

# Update both SmileID and SmileIDFramework targets
update_target(project, 'SmileID')
update_target(project, 'SmileIDFramework')

project.save
4 changes: 2 additions & 2 deletions SmileID.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = 'SmileID'
s.version = '10.1.2'
s.version = '10.1.3'
s.summary = 'The Official Smile Identity iOS SDK.'
s.homepage = 'https://docs.usesmileid.com/integration-options/mobile/ios-v10-beta'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Japhet' => '[email protected]', 'Juma Allan' => '[email protected]', 'Vansh Gandhi' => '[email protected]'}
s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.1.2" }
s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.1.3" }
s.ios.deployment_target = '13.0'
s.dependency 'Zip', '~> 2.1.0'
s.dependency 'lottie-ios', '~> 4.4.2'
Expand Down
Loading

0 comments on commit 3261ca1

Please sign in to comment.