Hey friends! Is anyone using the Cocoapods Gradle ...
# kotlin-native
a
Hey friends! Is anyone using the Cocoapods Gradle plugin for debugging/iteration, but then a versioned/hosted private pod for "normal" iOS development? If so, how do you toggle between the two? Any tricky bits to watch out for? Context: We're currently only publishing our KMP XCFramework as a private pod, which we've automated through Gradle, but is still slow for iterative work. Our iOS devs are interested in being able to debug faster with the cocoapods gradle plugin when they're iterating in KMP code, but they're also hesitant to link the iOS and KMP projects for everyday work because their build times are already slow enough as it is.
r
If you're using cocoapods, you should be able to check an environment variable in your podfile to toggle between a published and local podspec.
a
Yeah I saw that pop up as an option -- so the flow would be that devs would need to toggle an environment variable when they want to switch between the two (and CI would just always have it set to use published)? I'm not super fluent with iOS dev workflows, so was hoping there was a way to just make an equivalent of an Android Studio "Run Configuration" for "Build iOS with local KMP sources"
r
It's probably possible to do that but I'm not well-versed in what that xcode configuration would look like
Though there's a decent chance I'll be helping put something similar together for a client in the near future so I'd definitely be interested to hear what you end up with
a
happy to share whatever we come up with!
n
If you remember/know that Podfile is just a ruby file it’s quite easy to make this happen. We have developers edit a
config.yml
with their local development path to the multiplatform llibrary (the directory where the podspec can be found) or the versioned library in git (this could also be managed by a podspec repo)
Copy code
MultiplatformConfig:
    local: true
    path: "../mpp/MultiplatformLibrary.podspec"
Copy code
require "yaml" 
config = YAML.load_file("config.yml")["MultiplatformConfig"]
    if config["local"] == true
      pod 'MultiplatformLibrary', :path => config["path"]
    else
      pod 'MultiplatformLibrary', :git => 'git@location-of-multiplatform-library.git', :tag => 'version-tag'
    end
đź‘€ 1
Add a little safety
config = File.exists?("config.yml") ? YAML.load_file("config.yml")["MultiplatformConfig"] : { "local": false }
and it becomes completely optional as well
I’m not super fluent with iOS dev workflows, so was hoping there was a way to just make an equivalent of an Android Studio “Run Configuration” for “Build iOS with local KMP sources”
I wouldn’t recommend attempting to integrate an Xcode run configuration to hot-swap dependencies if your team is using Cocoapods. Cocoapods modifies the Xcode project to get things done and this is best done separately.
If you were not using Cocoapods and were directly integrating the framework with Xcode instead you could swap the library search path at compile time using a build configuration variable and toggle on/off the
embedAndSignAppleFrameworkForXcode
run script.
a
Gotcha, I'll give this a try! Thanks Nico!