I. Background:

  1. The company’s project uses Carthage for dependency management. Compared to Cocopods, Carthage is more suitable for multi-developer scenarios, so that one person’s changes to dependencies don’t affect everyone.

  2. Company projects use an S3 server to cache built dependencies. When needed, use Fastlane Carthage_install to download the cache to the Carthage file in the project and run the application directly. You don’t have to clone each repository and build each time, because that would be time consuming. If you want to upgrade or modify a dependency later, you only need to upload the built dependency to the S3 server.

Ii. Task Introduction

  1. Recently, I have been working on a task, that is, upgrading Branch SDK to the latest version. Because Branch SDK is embedded into segment-branch-ios, there is no separate Branch SDK in Cartfile, so you cannot directly upgrade Branch SDK. The Branch SDK can only be upgraded indirectly by upgrading the segment-branch-ios SDK.

  2. Update segment-branch-ios to update segment-branch-ios The Branch SDK in the private library must be upgraded first because a colleague connected the private library to the company’s project.

Iii. Practical operation and thinking:

  1. Once you’ve got the big picture figured out, Forked that co-worker’s personal account into your Github account first. Because segment-branch-ios uses Carthage for dependency management, it does not use S3 for server caching.

    Carthage update –platform iOS –use-xcframeworks ios-branch-deep-linking

    • If you runcarthage update, will be directly correctCartfileTo upgrade to the highest level.
    • If you want to limit the version, you canCartfile.resolvedSet the version number in the file and use it againcarthage bootstrap, you can limit the version number (or leave it unchanged)Cartfile.resolvedFile, directly inCartfileWrite the version number in the file to Carthage update).
    • --platform iosIn order to specify that the iOS platform is used, the library of TV, Watch and other systems will not be pulled.
    • --use-xcframeworksSpecify that you want to generate.xcframeworksType of library. Otherwise it will generate.frameworksIn the library.
  2. After running, Branch. Xcframework appears in the Build folder and version records in the Cartfile. Resolved file have changed.

  3. Push this change to segments-branch-ios for Forked, and you’ll get a new COMMIT ID. Copy this COMMIT ID to change the Cartfile from the main project to the dependencies that point to the updated private repository.

  4. Carthage update –platform ios –use-xcframeworks segment-branch-ios

  5. The only way to solve this problem is to delete Carthage/Build and Carthage/Checkouts files, skip the dependent caches of S3 servers, and clone and Build all libraries from start to finish. Run scripts/carthage-build.sh update –platform ios –use-xcframeworks –cache-builds

    • It’s not used herecarthage updateBut with thescripts/carthage-build.sh updateThe reason is that some libraries have issues with iOS 12, so you need to write your own special Carthage script to perform the operation. Carthage update (Carthage update)
    • --cache-buildsIn order to re-execute the command, so that the already built library does not have to rebuild, save time.

    An error occurred and you can open the error log to see that some XCFramework libraries are missing in a path:

    Copy and paste mixpanel. xcframework and Segment. Xcframework from S3 cache into this path: /Users/wwan/Desktop/TKPlanner-iOS/Carthage/Checkouts/analytics-ios-integration-mixpanel/Carthage/Build/

  6. Again: scripts/carthage-build.sh update –platform ios –use-xcframeworks –cache-builds

    XCUIElement+Extensions/swifit: XCUIElement+Extensions/swifit: XCUIElement+Extensions/swifit

    Copy and paste S3 cache XCUIElement+Extensions. Swift to this path: /Users/wwan/Desktop/TKPlanner-iOS/Carthage/Checkouts/UITestUtilities-iOS/Sources/

  7. Again: scripts/carthage-build.sh update –platform ios –use-xcframeworks –cache-builds

    Still error again, open error log found this time difficult to deal with, this -lswiftXCTest I don’t know what library is missing, Google can not find any answer. Uitestutilities-ios is missing something:

  8. Check the github repository of UitestUtilities-ios and find that the latest version of this library is 0.1.4. The Cartfile in the main project uses the 0.1.2 version of this library. Then check the change record of 0.1.3. LswiftXCTest has been modified to lXCTestSwiftSupport:

  9. LswiftXCTest has been replaced. Change the uitestUtilities-ios version in the main project Carfile to 0.1.3 and execute: Scripts /carthage-build.sh update –platform ios –use-xcframeworks –cache-builds will build dependencies with clone and build builds.

(To be continued…)