Skip to content

Commit

Permalink
Merge pull request #9 from xendit/add_automation_script_for_ios_sdk_b…
Browse files Browse the repository at this point in the history
…uild

Add initial iOS SDK automation build (v1.0.0)
  • Loading branch information
ahmadAlfhajri authored Jan 14, 2025
2 parents 5828167 + 6edb14f commit 609617d
Show file tree
Hide file tree
Showing 11 changed files with 595 additions and 8 deletions.
14 changes: 14 additions & 0 deletions CardSessionMobileSDK.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Pod::Spec.new do |spec|
spec.name = 'CardSessionMobileSDK'
spec.version = '1.0.0'
spec.homepage = 'https://github.com/xendit/cards-session-mobile-sdk'
spec.source = { :http=> 'https://github.com/xendit/cards-session-mobile-sdk/releases/download/1.0.0/CardsSessionMobileSDK-1.0.0.zip'}
spec.author = { "mobile-sdk-team" => "[email protected]" }
spec.license = { :type => 'MIT', :text => ''}
spec.summary = 'Xendit\'s Cards Session SDK module'
spec.libraries = 'c++'
spec.platform = :ios, '14.0'
spec.ios.deployment_target = '14.0'
spec.vendored_frameworks = 'cardsSdk.xcframework'
spec.dependency 'XenditFingerprintSDK', '1.0.1'
end
2 changes: 2 additions & 0 deletions CardsSessionMobileSDKTarget/Dummy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//https://forums.swift.org/t/swiftpm-binary-target-with-sub-dependencies/40197/7
//NOTE: Without commiting the dummy source file for the stub target to the repo with the manifest, the libSwiftPM just thrown an error about missing source files.
36 changes: 36 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// swift-tools-version:5.9.0
import PackageDescription

let package = Package(
name: "CardsSessionMobileSDK",
platforms: [
.iOS(.v14),
],
products: [
.library(name: "CardsSessionMobileSDK", targets: ["CardsSessionMobileSDKTarget"])
],
targets: [
.binaryTarget(
name: "CardsSessionMobileSDK",
url: "https://github.com/xendit/cards-session-mobile-sdk/releases/download/1.0.0/CardsSessionMobileSDK-1.0.0.zip",
checksum: "ece9e7e73dffcdec868f7753a58544bb12d157ca4970b6816a9a3721f4e59827"
),
.binaryTarget(
name: "XenditFingerprintSDK",
url: "https://cdn-xenshield.xendit.co/fingerprint-sdk/ios/1.0.1/XenditFingerprintSDK-1.0.1.zip",
checksum: "d8dbb2e00525eb7765972e10aa0cf49d990a7cc40ddff05d0f620a17b487ceb0"
),
.target(
name: "CardsSessionMobileSDKTarget",
dependencies: [
.target(name: "CardsSessionMobileSDK"),
.target(name: "XenditFingerprintSDK")
],
path:"CardsSessionMobileSDKTarget",
linkerSettings: [
.linkedFramework("SystemConfiguration"),
.linkedFramework("CoreTelephony", .when(platforms: [.iOS]))
]
)
]
)
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@ dependencies {
}
```

### iOS - Cocoapod

Add the following to your app's `Podfile`:

```ruby
pod 'CardSessionMobileSDK', '~> 1.0.0'
```

**Important:** Import SDK in your project with CocoaPods integration, you can do as following

```swift
import cardsSdk
```
### iOS - Swift Package Manager

In XCode go to `File` -> `Add Packages...` and provide URL to this repository in the search bar. Choose `Dependency Role` and select apropriate project.

**Important:** Import SDK in your project with Swift Package Manager integration, you can do as following

```swift
import cardsSdk
```

## Usage

### Initialize the SDK
Expand Down
27 changes: 27 additions & 0 deletions cardsSdk/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
</dict>
</plist>
61 changes: 58 additions & 3 deletions cardsSdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFrameworkTask
import java.nio.file.Files

plugins {
alias(libs.plugins.kotlin.multiplatform)
Expand All @@ -12,7 +14,7 @@ kotlin {
iosArm64()
iosSimulatorArm64()

val xcframeworkName = "cardSdk"
val xcframeworkName = "cardsSdk"
val xcFrameworkVersion = "1.0.0"
val xcFrameworkBundleVersion = "1" // Increase it everytime version changed
val xcf = XCFramework(xcframeworkName)
Expand All @@ -36,9 +38,13 @@ kotlin {

cocoapods {
summary = "Cards Session SDK module"
homepage = "Link to the Cards Session Module homepage"
version = "1.0"
homepage = "https://github.com/xendit/cards-session-mobile-sdk"
version = "1.0.0"
license = "{ :type => 'MIT', :text => 'License text'}"
ios.deploymentTarget = "14.0"
source = "{\n" +
" http: 'PUT THE URL Github Asset here'\n" +
" }"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "cardsSdk"
Expand Down Expand Up @@ -136,3 +142,52 @@ android {
dependencies {
coreLibraryDesugaring(libs.android.desugar)
}

interface Injected {
@get:Inject val fs: FileSystemOperations
}

// Define a custom task type to handle the file copying
abstract class CopyPrivacyInfoTask : DefaultTask(), Injected {
@get:InputFiles
abstract val xcframeworkOutputs: ConfigurableFileCollection

@get:InputFile
abstract val privacyFile: RegularFileProperty

@get:OutputDirectory
abstract val outputDir: DirectoryProperty

@TaskAction
fun copy() {
val xcframework = xcframeworkOutputs.first().toPath()
Files.find(xcframework, 2, { path, _ ->
val isFramework = path.fileName.toString().endsWith(".framework")
val destination = path.getName(path.count() - 2).fileName.toString()
val isIOS = destination.startsWith("ios-")
isFramework && isIOS
}).forEach { framework ->
fs.copy {
from(privacyFile)
into(framework)
}
}
}
}

// Register the custom task
tasks.register<CopyPrivacyInfoTask>("copyPrivacyInfoToFrameworks") {
val xcframeworkTask = tasks.named<XCFrameworkTask>("podPublishReleaseXCFramework")
xcframeworkOutputs.from(xcframeworkTask.map { it.outputs.files })
privacyFile.set(project.file("PrivacyInfo.xcprivacy"))
outputDir.set(layout.buildDirectory.dir("xcframework"))

// Make this task run after XCFramework task
dependsOn(xcframeworkTask)
}

// Make XCFramework task finalized by our copy task
tasks.named<XCFrameworkTask>("podPublishReleaseXCFramework") {
finalizedBy("copyPrivacyInfoToFrameworks")
}

6 changes: 3 additions & 3 deletions cardsSdk/cardsSdk.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |spec|
spec.name = 'cardsSdk'
spec.version = '1.0'
spec.homepage = 'Link to the Cards Session Module homepage'
spec.version = '1.0.0'
spec.homepage = 'https://github.com/xendit/cards-session-mobile-sdk'
spec.source = { :http=> ''}
spec.authors = ''
spec.license = ''
spec.license = { :type => 'MIT', :text => 'License text'}
spec.summary = 'Cards Session SDK module'
spec.vendored_frameworks = 'build/cocoapods/framework/cardsSdk.framework'
spec.libraries = 'c++'
Expand Down
4 changes: 2 additions & 2 deletions iosApp/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- cardsSdk (1.0):
- cardsSdk (1.0.0):
- XenditFingerprintSDK (= 1.0.1)
- XenditFingerprintSDK (1.0.1)

Expand All @@ -15,7 +15,7 @@ EXTERNAL SOURCES:
:path: "../cardsSdk"

SPEC CHECKSUMS:
cardsSdk: 9e0b4e91658434b731daf4d2262393018fe4f742
cardsSdk: 6cf53581e3f04db427f8dd0700d1c11e78eac652
XenditFingerprintSDK: 29410a2dcf467fe33d6e0167f590deae47c753ee

PODFILE CHECKSUM: 2d3ff3b1724835dab0bcce0b112c67a9f1440453
Expand Down
Loading

0 comments on commit 609617d

Please sign in to comment.