anybody have pointers how to get CI build for KMP ...
# multiplatform
j
anybody have pointers how to get CI build for KMP iOS project working with Azure pipeline? Xcode works fine running this task.
./gradlew :shared:embedAndSignAppleFrameworkForXcode
but the error on CI build server shows 2 errors: (I already added KOTLIN_FRAMEWORK_BUILD_TYPE btw, same error)
* What went wrong:
Execution failed for task ':shared:embedAndSignAppleFrameworkForXcode'.
> Unable to detect Kotlin framework build type for CONFIGURATION=QA automatically. Specify 'KOTLIN_FRAMEWORK_BUILD_TYPE' to 'debug' or 'release'
1 problem was found storing the configuration cache.
`- Task
:shared:embedAndSignAppleFrameworkForXcode
of type `org.gradle.api.DefaultTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.`
See <https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
Do you have to have this build phase run as a separate Gradle Task or as long as gradlew is available in the repo it should work just like a local build?
c
Dumb question, Azure supports Apple Runners?
j
@chrisjenx yea they have a few different built-in tasks for running Xcode specific things like provisioning/cert installation and building workspaces/projects using Xcodebuild. I was able to resolve this issue btw, thanks.
👍 1
s
You might try running with the configuration cache disabled:
--no-configuration-cache
I had to do the same when using a github actions macos runner to sign and publish a KMP library https://github.com/schott12521/compose-cupertino/blob/main/.github/workflows/buildAndPush.yml#L79C32-L79C56
Not sure about the KOTLIN_FRAMEWORK_BUILD_TYPE error, though..
d
@Jason do you mind sharing what the problem was and how you solved it? we have a similar error on an iOS project when we tried to include KMP in it
j
@Daniele Segato well for me I initially could only build iOS w/ direct linking to KMP framework locally using the
embedAndSignAppleFrameworkForXcode
gradle task. I had added
KOTLIN_FRAMEWORK_BUILD_TYPE
user defined build setting and set the appropriate value for each configuration. For CI, I am using exact same gradle task now as it uses xcodebuild and both CI and local builds work exactly the same. I did not have to disable gradle configuration cache either, I think that error was caused by the first error which is now resolved. If you post your error here, I may be able to help you out. If your using direct framework linking like I am, make sure the builds phase on your target which invokes this gradlew task is above Compile phase, so the iOS Shared Framework is built and linked to the project prior to compiling any other code that depends on it.
d
Hey @Jason thanks for your reply! To be honest with you I've very little knowledge of iOS! I'll check with my iOS colleague tomorrow to give you the specific error!
@Jason this is the error:
Copy code
> Task :shared:common:multiplatform:embedAndSignAppleFrameworkForXcode FAILED
* What went wrong:

Execution failed for task ':shared:common:multiplatform:embedAndSignAppleFrameworkForXcode'.

> Unable to detect Kotlin framework build type for CONFIGURATION=Development automatically. Specify 'KOTLIN_FRAMEWORK_BUILD_TYPE' to 'debug' or 'release'

 XcodeEnvironment:

  buildType=null

  targets=[ios_simulator_arm64]

  frameworkSearchDir=Development/iphonesimulator18.0

  builtProductDir=/Users/username/Library/Developer/Xcode/DerivedData/ProjectName-ios-gtbmmzdloluwhwbyqnlxrmxnbdhz/Build/Products/Development-iphonesimulator

  embeddedFrameworksDir=/Users/username/Library/Developer/Xcode/DerivedData/ProjectName-ios-gtbmmzdloluwhwbyqnlxrmxnbdhz/Build/Products/Development-iphonesimulator/Vivisol-it.app/Frameworks

  sign=-

  userScriptSandboxingEnabled=false
sharedcommon:multiplatform is a dependency of a dependency, meaning in the XCode build phase script module A is added, which depends on module B, which depend on module C (this one) EDIT: nevermind it’s a direct dependency as well
we’ve build a test project that had the same configuration but we didn’t need to specify them… And we tried to specify the CONFIGURATION manually, we managed to make it all compile but afterwards we get no autocompletion in XCode
j
hmmm...so you added the User Defined Setting '`KOTLIN_FRAMEWORK_BUILD_TYPE`' in the build settings correct? That
embedAndSignAppleFrameworkForXcode
gradle task will read the value from that setting when it executes. Sounds like you did that. Sometimes autocompletion is slow in Xcode for KMP types you have exported, mine sometimes also doesn't work, its possibly a caching issue which re-indexing may help with. But in general Xcode Auto-completion has always been a hit or miss for me, even before I started using KMP.
d
The thing is, we created a new iOS project before doing this: we didn't need to specify the build type with that project, same KMP project, and auto completion worked perfectly. So this is kind of a bummer and my iOS colleague isn't thrilled to work like this. And I can relate, I wouldn't be happy to work with something that didn't auto complete anything.