Hello everyone! It’s possible that I’m doing somet...
# multiplatform
g
Hello everyone! It’s possible that I’m doing something wrong, but I’d like to ask if, when you delete Derived Data or Build Folders in Xcode, you are then able to compile the project correctly and import the “shared” framework without errors in the iOS project. At the moment, I’ve been encountering several errors because it says it can’t find the “shared” framework, which actually makes sense to me. However, I thought that dependencies (including the “shared” framework) would be compiled first to avoid these resolution errors. This forces me to comment out all the imports to be able to build. Once the build is done, everything returns to normal. I’d like to avoid this use-case because it’s a bad developer experience 😅. Fortunately, on the iOS app side, I have all the code abstracted and use DI, so I end up only commenting out a few files in my “data package.” Is this happening only to me? Is there a configuration I’m getting wrong? I’ve external spm dependencies and local spm dependencies, only the regular framework seems to “break”.
Copy code
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
This is the first setting on Build Phases, looks ok to me 🤷‍♂️
k
I’ve also encountered this issue. In my case, I made several configurations (DebugDev, ReleaseDev, DebugStg, …) and it was building but it ends up not being accessible to xcode. I changed the configuration back to Debug and Release and things ran smoothly from there on my end. This might be specific to my case so check your build settings and check if it’s building on the kotlin side too.
g
Thanks! Will take a look
@Rick Clephas I’ve studied the KT-59751 but in my case I do not have any Xcode configurations besides the “default”: Created by Android Studio
Copy code
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
Created by Kotlin Wizard
Copy code
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
  echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
  exit 0
fi
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
It always fails no matter which I use. I don’t know how to fix this 🤔
r
Hmm and does it make a difference if you both clear the Xcode and Gradle caches instead of just the Xcode caches? Could you share the build logs from Xcode, specifically those of the Kotlin build script step?
g
I’ve deleted
.gradle/cache/
content, cleaned the project on Android Studio and also the iOS Derived Data. Then I’ve built the project in Android Studio with sucess. Next on Xcode I’ve tried the same but it failed:
DomainProtocols
import
SharedSDK
(shared framework) so it will fail with > No such module ‘SharedSDK’
now to work I’ve to comment all theses imports and build. 😞
r
Hmm it looks like the Kotlin build script isn’t being run yet. Is the Kotlin build script configured for your
DataExtensions
target?
g
I only have one target and it’s the “MainApp” target 🤔
could this be the problem?
This target on the General tab has all this framework dependencies added
r
Based on the error message the
DataExtensions
target imports the
DomainProtocols
module, which I am guessing is your Kotlin module?
g
oh no no DomainProtocols is another local spm
I have only one import from Kotlin it’s the SharedSDK
r
Oh, in that case could it be that
DomainProtocols
also fails to build? Resulting in the no such module error?
g
(but DomainProtocols imports SharedSDK)
r
Normally you would need to add the Kotlin build script to the target that is using the shared Kotlin module. But I am not sure how that would be done with a SPM package
g
(must I specify something in their Package.swift regarding shared kotlin lib?)
r
Not 100% sure, but I believe there is no way to specify a custom build script action for a SPM package
g
yeah, I’ve tried to search about it and didn’t find anything about it
Is it possible to force this script to run before the spm dependencies?
maybe here?
r
Yeah but it seems that SPM dependencies are being build before that script is run
g
I also think that’s the case
because when I comment > run > uncomment: it’s ready
so I would say that spm won’t take shared lib into account, then the script runs, then I uncomment, but the lib is cached and created, so spm will be able to see it 🤔
what if I created a dummy spm with the same name 😅 but empty, would it work?
r
Correct. I think this is more of an SPM limitation.
In order for it to work you would need to remove any references to the shared Kotlin module from any SPM dependencies. Including references to SPM dependencies that were removed
But that probably won’t work automatically
I am not sure what the order of dependency building is, but if it first builds other Xcode targets then you could add a dummy Xcode target with the Kotlin build script
g
that’s a good idea, I’ll try it 😉
I found a solution (or a partial)
we can add build scripts for any action of the Scheme
so I’ve added the same script in the Build pre phase, and know the SharedSDK is found and built before 🙂
but for some reason now, one of the SPM are failing. Still looking into it, but maybe am in the right path 🙏
Screenshot 2024-08-07 at 15.33.41.png
👍🏻 1
it worked 😎
kodee happy 1
Thanks for the help 🙌