iOS SDK Support Carthage

This article is after iOS SDK Deploy Github XCFramework.

If you want to know CocoaPods, please check iOS SDK Support CocoaPods.

Now, we deployed XCFramework on github.

Let’s prepare Carthage support.

スポンサーリンク

Carthage

Carthage is intended to be the simplest way to add frameworks to your Cocoa application (from Carthage page)

This is popular to manage framework in swift and iOS app.

Let’s support Carthage import for our iOS SDK

CarthageSpec.json

This file is to identify version and target binary. Carthage use this file.

{ 
  "1.0.0":"https://github.com/DJ110/iOS-Mobile-SDK/releases/download/1.0/iOSMobileSDK-1.0.0.xcframework.zip"
}

Now, ready to use it.

This file is same project as CocoaPods.

You can see this in iOS-Mobile-SDK.

json file is in Github repository.

Now it’s ready to import XCFramework using Carthage.

Use XCFramework via carthage

To use Carthage in Mac, you need to install carthage via brew

brew install carthage

Once we installed carthage, we need to prepare Carthage file in the target project.

Cartfile

Cartfile is the target file to prepare.

This file should be under project.

Cartfile

binary "https://raw.githubusercontent.com/DJ110/iOS-Mobile-SDK/main/CarthageSpec.json" ~> 1.0.0

binary is target type, and set CarthageSpec.json file (need raw file URL, not github repository page)

If you access above URL, you can see json contents without HTML contents.

Resolve dependency and import

Let’s download using Carthage.

We need to run following command.

carthage update --platform iOS --use-xcframeworks

Download and save XCFramework(Carthage/Build/iOSMobileSDK.xcframework).

In Carthage case, we need to import framework by myself.

Open Project file, and add import.

Select TARGET and Build Phases and Link Binary with Libraries.

Select Add Files.

We can choose above Framework installed by Carthage.

Now, we can import Framework and can build app code same pods.

Import is completed.

We can use XCFramework from your app.

If you want to see app code, please check this article. iOS SDK Sample App import XCFramework. Application repository is iOSMobileSDKApp (branch feature/carthage)

iOS
スポンサーリンク
Professional Programmer2

コメント