Skip to content
xindongPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

XDSDK Binary SPM

XDSDK iOS SDK distributed through Swift Package Manager.

Requirements

  • iOS 13.0+ for XDSDKCN and XDSDKDouYinGame
  • iOS 15.0+ for XDSDKGlobal and XDSDKGlobalCrashlytics
  • Real device only. Simulator is not supported.

Add the Dependency

1. Add the Git repository

In Xcode, choose File → Add Package Dependencies..., then enter the XDSDK SPM repository URL:

https://github.com/xindong/XDSDK-SPM.git

If GitHub is not accessible from your network, use the GitCode URL instead:

https://gitcode.com/XDSDK/XDSDK-SPM.git

Choose the dependency rule based on the release stage:

  • Stable releases: use Up to Next Major Version, with the current stable version, for example 7.9.0
  • RC / beta validation: use Exact Version, with the full prerelease version, for example 7.9.0-rc.1

2. Choose a Product

On the Add Package product selection page, add the Product you need to the App target. Main Products include payment support.

Use case Product
China mainland XDSDKCN
Global XDSDKGlobal
Global + Firebase Crashlytics XDSDKGlobalCrashlytics
Douyin mini-game add-on (optional) XDSDKDouYinGame

Usually choose only one of XDSDKCN, XDSDKGlobal, and XDSDKGlobalCrashlytics. XDSDKDouYinGame is an optional add-on and should only be added when needed.

Configure the App Target

After adding the Product, the App target needs two Run Script Build Phases: one to copy resources, one to auto-configure Info.plist.

Both scripts are invoked directly from the SPM checkout. Do not copy them into your repo — this way they stay in sync when you upgrade the package.

1. Copy resources

In your App target → Build Phases, add a Run Script Phase named Copy XDSDK Resources with this body:

SCRIPT_PATH="${BUILD_DIR%/Build/*}/SourcePackages/checkouts/XDSDK-SPM/Scripts/copy_xdsdk_resources.sh"
if [[ -f "$SCRIPT_PATH" ]]; then
    bash "$SCRIPT_PATH"
else
    echo "warning: XDSDK SPM resource script not found at $SCRIPT_PATH"
fi

The script reads region_type from XDConfig.json: CN copies the common TapSDK4 plus CN resources, while Global copies the common TapSDK4 plus Oversea resources. Resources for the other region are no longer bundled into the .app.

Requirements:

  • Move this phase to the end of Build Phases (after Embed Frameworks / [CP] Embed Pods Frameworks)
  • Uncheck Based on dependency analysis
  • In Build Settings, set User Script Sandboxing (ENABLE_USER_SCRIPT_SANDBOXING) to NO
  • The script looks for ${SRCROOT}/${PRODUCT_NAME}/XDConfig.json by default. If the config lives elsewhere, set XDSDK_CONFIG_PATH=/absolute/path/XDConfig.json in this Run Script

2. Auto-configure Info.plist

Reads XDConfig.json from the App project and uses region_type to write only the current region's CFBundleURLTypes / LSApplicationQueriesSchemes, plus the required Facebook top-level keys for Global configs. Common XDSDK / TapTap entries are generated for both regions; CN configs generate only domestic platform entries such as WeChat, QQ, Weibo, XiaoHongShu, DouYin, and KuaiShou, while Global configs generate only Facebook, Line, Twitter, Google, and TikTok entries.

Add a second Run Script Phase named Configure XDSDK Info.plist:

SCRIPT_PATH="${BUILD_DIR%/Build/*}/SourcePackages/checkouts/XDSDK-SPM/Scripts/configure_xdsdk_info_plist.py"
if [[ -f "$SCRIPT_PATH" ]]; then
    /usr/bin/env python3 "$SCRIPT_PATH"
else
    echo "warning: XDSDK SPM info-plist script not found at $SCRIPT_PATH"
fi

Requirements:

  • Place this phase before Compile Sources
  • Uncheck Based on dependency analysis
  • Set User Script Sandboxing to NO
  • The script looks for the config at ${SRCROOT}/${PRODUCT_NAME}/XDConfig.json by default. If it lives elsewhere, set XDSDK_CONFIG_PATH=/absolute/path/XDConfig.json in the Run Script env

If one App explicitly ships multiple CN / Global configs, set the same colon-separated XDSDK_EXTRA_CONFIG_PATHS value in both Run Script Phases. The scripts will merge the plist entries and regional resources required by those configs. Facebook top-level keys are resolved across all Global configs; the build fails if different configs provide conflicting FacebookAppID or FacebookClientToken values instead of silently choosing one.

3. Verify

Product → Clean Build Folder, then build. The build log should show Copied <BundleName>.bundle lines, and the produced .app (right-click → Show Package Contents) should contain the corresponding .bundle directories at its root.

Optional: Firebase Crashlytics symbols

If you use XDSDKGlobalCrashlytics, add a Run Script Phase named Upload Crashlytics Symbols:

SCRIPT_PATH="${BUILD_DIR%/Build/*}/SourcePackages/checkouts/XDSDK-SPM/Scripts/FirebaseCrashlytics/run"
if [[ -f "$SCRIPT_PATH" ]]; then
    "$SCRIPT_PATH"
else
    echo "warning: Firebase Crashlytics script not found at $SCRIPT_PATH"
fi

Requirements:

  • Place this phase after Embed Frameworks / [CP] Embed Pods Frameworks (the script needs the dSYM produced by linking)
  • Uncheck Based on dependency analysis
  • Set User Script Sandboxing to NO
  • Add $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) and $(DWARF_DSYM_FOLDER_PATH)/$(DWARF_DSYM_FILE_NAME) to the script's Input Files so it picks up the dSYM correctly

Notes

  • Multi-target apps (App + App Clip + Extensions): every target that needs the resources / schemes must add its own copy of both Run Script Phases
  • CI / Xcode Cloud need the same sandbox settings
  • CFBundleURLName entries prefixed with xdsdk. are managed by the script and will be overwritten on every build — edit XDConfig.json instead
  • Binary distribution: the .xcframework.zip files are downloaded from URLs declared in Package.swift

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages