I. Background:
-
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.
-
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
-
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.
-
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:
-
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 run
carthage update
, will be directly correctCartfile
To upgrade to the highest level. - If you want to limit the version, you can
Cartfile.resolved
Set the version number in the file and use it againcarthage bootstrap
, you can limit the version number (or leave it unchanged)Cartfile.resolved
File, directly inCartfile
Write the version number in the file to Carthage update). --platform ios
In order to specify that the iOS platform is used, the library of TV, Watch and other systems will not be pulled.--use-xcframeworks
Specify that you want to generate.xcframeworks
Type of library. Otherwise it will generate.frameworks
In the library.
- If you run
-
After running, Branch. Xcframework appears in the Build folder and version records in the Cartfile. Resolved file have changed.
-
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.
-
Carthage update –platform ios –use-xcframeworks segment-branch-ios
-
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 here
carthage update
But with thescripts/carthage-build.sh update
The 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-builds
In 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/
- It’s not used here
-
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/
-
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:
-
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:
-
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.