https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
v

Vivek Modi

03/03/2022, 12:15 AM
Hey I am learning Kmm with cocoapods integration. My studio is generated podfile automatically when I added the KMM module. Sometag I understand but some are not. Can someone guide me use case of attributes and also did I miss any attributes for my ios project. Podile
Copy code
​Pod​::​Spec​.​new​ ​do​ |​spec​| 
 ​    ​spec​.​name​                     ​=​ ​'kotlinmultiplatformsharedmodule' 
 ​    ​spec​.​version​                  ​=​ ​'1.0' 
 ​    ​spec​.​homepage​                 ​=​ ​'<https://github.com/vivek-modi/MultiplatformProject|https://github.com/vivek-modi/MultiplatformProject>' 
 ​    ​spec​.​source​                   ​=​ ​{​ ​:git​ ​=>​ ​"Not Published"​,​ ​:tag​ ​=>​ ​"Cocoapods/​#{​spec​.​name​}​/​#{​spec​.​version​}​"​ ​} 
 ​    ​spec​.​authors​                  ​=​ ​'<mailto:vivekmodi456@gmail.com|vivekmodi456@gmail.com>' 
 ​    ​spec​.​license​                  ​=​ ​'' 
 ​    ​spec​.​summary​                  ​=​ ​'Some description for the Shared Module' 
  
 ​    ​spec​.​vendored_frameworks​      ​=​ ​"build/cocoapods/framework/kotlinmultiplatformsharedmodule.framework" 
 ​    ​spec​.​libraries​                ​=​ ​"c++" 
 ​    ​spec​.​module_name​              ​=​ ​"​#{​spec​.​name​}​_umbrella" 
  
 ​    ​spec​.​ios​.​deployment_target​ ​=​ ​'14.1' 
  
 ​    ​spec​.​pod_target_xcconfig​ ​=​ ​{ 
 ​        ​'KOTLIN_PROJECT_PATH'​ ​=>​ ​':app:kotlinmultiplatformsharedmodule'​, 
 ​        ​'PRODUCT_MODULE_NAME'​ ​=>​ ​'kotlinmultiplatformsharedmodule'​, 
 ​    ​} 
  
 ​    ​spec​.​script_phases​ ​=​ ​[ 
 ​        ​{ 
 ​            ​:name​ ​=>​ ​'Build kotlinmultiplatformsharedmodule'​, 
 ​            ​:execution_position​ ​=>​ ​:before_compile​, 
 ​            ​:shell_path​ ​=>​ ​'/bin/sh'​, 
 ​            ​:script​ ​=>​ ​<<-SCRIPT 
 ​                if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then 
 ​                  echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to ​\"​YES​\"​" 
 ​                  exit 0 
 ​                fi 
 ​                set -ev 
 ​                REPO_ROOT="$PODS_TARGET_SRCROOT" 
 ​                "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework ​\ 
 ​                    -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME ​\ 
 ​                    -Pkotlin.native.cocoapods.archs="$ARCHS" ​\ 
 ​                    -Pkotlin.native.cocoapods.configuration=$CONFIGURATION 
 ​            SCRIPT 
 ​        ​} 
 ​    ​] 
 ​end
1. I have doubt in source, vendored_framework, libraries, module_name and what is pod_tarvet_xconfig. 2. Did I miss any other attributes for my ios project? 3. Can someone explain me how this pod is know where the framework is? If I add this pod file to different repository so how can I connect them
🧵 1
google 1
a

Artyom Degtyarev [JB]

03/03/2022, 7:40 AM
This is a podspec file, not a Podfile. The main difference is that the latter describes what should the CocoaPods use as a dependency in Xcode project, while the former describes your library as a valid CocoaPods dependency. Podspec it produced by the Kotlin CocoaPods Gradle plugin automatically, so that's why all attributes are already set. In general, there are some settings that can be specified, all from the build.gradle<.kts> file of your Kotlin Multiplatform Mobile module. See this pages of the documentation(1, 2, 3).
Can someone explain me how this pod is know where the framework is? If I add this pod file to different repository so how can I connect them
This question is unclear to me, the podspec should not be relocated away from the project. To add this pod as a dependency, you will write this podspec's file location into the Podfile of your iOS project. It is also described in the documentation
v

Vivek Modi

03/03/2022, 9:54 PM
thanks @Artyom Degtyarev [JB] for your suggestion. i am trying to add file in my ios project. Can you please look into this issue ?https://stackoverflow.com/q/71344095/11560810
a

Artyom Degtyarev [JB]

03/04/2022, 8:58 AM
Consider reading our documentation at https://kotlinlang.org/docs/native-cocoapods-xcode.html#xcode-project-with-one-target. This source will be definitely more relevant to your case than a YouTube video about CocoaPods in general.
v

Vivek Modi

03/04/2022, 9:19 AM
@Artyom Degtyarev [JB] I just take a look from youtube how can I integrate podspec file in xcode project. The above link is give example of how we can connect through local storage, but I want to do through repository. Sorry my English is not too good if I understand wrong.
a

Artyom Degtyarev [JB]

03/04/2022, 10:34 AM
In general, right now we do not suggest this scenario(pod located in a remote repository). See, the problem is that the CocoaPods as a tool can use as a dependency either pre-built artifacts or sources to build library from. The latter case is not so easy to use by Kotlin as our build system and compilers are different from the most popular use-case of CocoaPods with delivering Objective-C or Swift libs. The former one, with adding a pre-built framework or XCFramework might work. In that case there should be not much of a difference from adding a framework built from Objective-/Swift sources. Could you please clarify, why would you need to use a git repository to deliver framework built from KMM sources remotely?
v

Vivek Modi

03/04/2022, 11:13 AM
@Artyom Degtyarev [JB] I have two teams one is android and other is ios. Using a repository so that the iso team can download it from there. I want to use KMM to connect both platforms. I know that when KMM build and generates framework and podspec cannot be separated from the project (I am not sure). We don't share our code among the teams. I spoked with ios team, they said use cocopods as dependency manager. That why I more inclined to use cocoapod as KMM provides. I am trying to find a way where I can share the framework or podspec file with the ios team and maintain our policy.
a

Artyom Degtyarev [JB]

03/04/2022, 12:35 PM
Well, I would like to recommend you to try the following approach then. Put .podspec file and a prebuilt framework to the git repository, make sure that the .podspec can be found in the repo's root directory and the framework is where your
vendored_framework
option points to, and depend on this repo from your iOS project. The error message in your stackoverflow clearly states that the CocoaPods was unable to locate the podspec(its three folders deep into the repository right now, so this might be expected).
v

Vivek Modi

03/04/2022, 3:51 PM
@Artyom Degtyarev [JB] Ok got it. Do you know, how can I change configuration of creating the framework and .podspec file. So I can point him directly in root directory.
a

Artyom Degtyarev [JB]

03/05/2022, 9:21 AM
I'm afraid you misunderstood my suggestion. What I wanted you to do is to create a separate git repository and just put there copies of your framework and its .podspec. If you don't want to share the source code between teams, I see no reason to use whole KMM module as a dependency. By the way, the GitHub project you're sharing in this question(https://stackoverflow.com/questions/71356986/change-store-location-in-kotlin-multiplatform-gradle) does not seem to have a correct layout. There you have an Android application with KMM module inside. And this inner module is the one you're trying to get by CocoaPods machinery. Please consider not mixing everything into a single repository.
v

Vivek Modi

03/05/2022, 9:28 AM
Sure now understand properly. Now I'll ask team to share code of Project between them. And also try to copy of framwork and podspec file. Thanks for suggestion.
5 Views