What's the equivalent of “development pods” under Carthage?

后端 未结 3 1119
谎友^
谎友^ 2020-12-15 11:43

The teams developing frameworks for our iOS app are migrating from Cocoapods to Carthage.

Under Cocoapods, I could set up dependencies as \"development pods\". For e

相关标签:
3条回答
  • 2020-12-15 11:57

    This works just as well as development pods for me, as of Xcode 8.3.3 and Carthage 0.24.0:

    1. In app path, rm -rf Carthage
    2. Point at the appropriate branch or tag in Cartfile
    3. carthage update --use-submodules (generates .gitmodules and clones repo into Carthage/Checkouts)
    4. In Xcode under project -> Build Phases -> Run Script, comment out the line that ends with carthage update --cache-builds if present.
    5. Change to the General tab and remove the lib from Embedded Binaries
    6. Right-click project, Add Files to app..., add lib from Carthage/Checkouts
    7. Under project -> General, re-add the library, choosing the one you added in the previous step.

    App should now build with the local lib. Make sure that your .gitignore has Carthage/{Build,Checkouts} and .gitmodules.

    0 讨论(0)
  • 2020-12-15 12:08

    This answer is a summary of a successful implementation of the solution introduced here.

    A cleaner solution is using local paths for dependencies in Cartfile.

    Environment

    • Xcode 10.1
    • macOS 10.13.6

    Step 1. Symbolic linking

    1.1   Change $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) directory to a symbolic link pointing to source root directory of your developing framework $(SRCROOT_DEVELOPING_FRAMEWORK), where $(SRCROOT_MAIN) is source root directory of your main app. Backup existing directories before this change.

    This linking enables version-controlled changes in your developing framework.

    Syntax when using ln utility,

    $ ln -s "$SRCROOT_DEVELOPING_FRAMEWORK" "$SRCROOT_MAIN/Carthage/Checkouts/$DEVELOPING_FRAMEWORK_NAME"
    

    1.2   Change $(SRCROOT_DEVELOPING_FRAMEWORK)/Carthage/Build directory in your framework to a symbolic link pointing to $(SRCROOT_MAIN)/Carthage/Build directory. Backup existing directories before this change.

    This linking enables access to all frameworks built by Carthage from both your developing framework and your main app.

    Syntax when using ln utility,

    $ ln -s "$SRCROOT_MAIN/Carthage/Build" "$SRCROOT_DEVELOPING_FRAMEWORK/Carthage/Build"
    

    Step 2. Framework Replacement

    2.1   Remove your developing framework in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries (that is, the one located in $(SRCROOT_MAIN)/Carthage/Build/iOS).

    2.2   Add $(DEVELOPING_FRAMEWORK_NAME).xcodeproj (found in directory pointed by $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) symbolic link) into your main app

    2.3   Build the developing framework product for device and simulator

    2.4   Add the new developing framework auto-detected by Xcode in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries.

    2.5   Add $(DEVELOPING_FRAMEWORK_NAME).framework as a target dependency by adding $(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Target Dependencies.

    2.6   Copy $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework to $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework by adding a new input file $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework and a new output file $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Run Script of Carthage Embed Framework.

    Reference

    Debugging Carthage Dependencies
    https://allocinit.io/ios/debugging-carthage-dependencies/
    
    Build Setting Reference
    https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html
    
    0 讨论(0)
  • 2020-12-15 12:17

    I believe Carthage doesn't have something similar to "development pods" yet.

    But you could simulate "development pods" just following these steps:

    Steps:

    1. Add the .xcodeproj to your workspace
    2. Remove all the dependencies you have in your project of the framework you added in step 1. (probably you may need to remove it from Build Phases -> Run Script -> Input Files too )
    3. Go to General tab of the target you want to run, add the framework under Linked Frameworks and Libraries (it is going to take the one added from the .xcoproj)
    4. (optional) you may need to run carthage bootstrap in the framework's repo you want to add locally.

    That's it.

    After that you will be able to run your project and update framework's code in the same workspace.

    0 讨论(0)
提交回复
热议问题