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

aleksey.tomin

09/15/2020, 9:08 AM
I try to create library for macOS and iOS application. 1. I’ve read https://kotlinlang.org/docs/reference/native/cocoapods.html and add
cocoapods
into
build.gradle.kts
2. I’ve called
build
3. I’ve called
podspec
and
library.podspec
was created 4. I’ve called
podBuildDependenciesMacos
podSetupBuildMacos
- was created cocoapods dir with framework 5. I’ve called
podInstall
- but was not pod into list:
$ pod list
returns
0 pods were found
. What do I wrong? How can I create library for use in Xcode?
k

Kurt Renzo Acosta

09/15/2020, 9:10 AM
Have you referenced the generated
podspec
into the
Podfile
?
a

aleksey.tomin

09/15/2020, 10:51 AM
I think
Podfile
created by gradle plugin 😞 What I have to create?
a

aleksey.tomin

09/15/2020, 3:12 PM
@Liliia The article and example - about import libraries into kotlin code. But I haven’t understood how can I import kotlin library into Xcode project
r

romtsn

09/15/2020, 3:38 PM
a

aleksey.tomin

09/16/2020, 10:08 AM
@romtsn I try to use https://github.com/Kotlin/multitarget-xcode-with-kotlin-cocoapods-sample/blob/master/severalTargetsXcodeProject/Podfile 1. I’ve replaced kotlin to 1.4.10 (from dev version). 2. I’ve removed package auto signing (no key for You team) 3.
gradle build
and
gradle podInstall
in
kotlin-library
4.
xcodebuild -scheme MacosCLI
in
severalTargetsXcodeProject
-
Copy code
#import "Headers/dummy.h"
        ^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/kotlin-library/build/cocoapods/framework/kotlin_library.framework/Headers/dummy.h:2:1: error: unknown type name 'FOUNDATION_EXPORT'
FOUNDATION_EXPORT double dummyVersionNumber;
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/dummy.h"
        ^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/kotlin-library/build/cocoapods/framework/kotlin_library.framework/Headers/dummy.h:5:1: error: unknown type name 'FOUNDATION_EXPORT'
FOUNDATION_EXPORT const unsigned char dummyVersionString[];
^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/severalTargetsXcodeProject/MacosCLI/main.swift:2:8: error: could not build Objective-C module 'kotlin_library'
import kotlin_library
       ^
What do I wrong? PS:
Copy code
$ gradle -version
Picked up JAVA_TOOL_OPTIONS: -Djava.awt.headless=true

------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------

Build time:   2020-08-10 22:06:19 UTC
Revision:     d119144684a0c301aea027b79857815659e431b9

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          14 (Oracle Corporation 14+36-1461)
OS:           Mac OS X 10.15.6 x86_64
Copy code
$ xcodebuild -version
Xcode 11.7
Build version 11E801a
r

romtsn

09/16/2020, 10:11 AM
you also need to run
pod install
in the root folder (where the Podfile is located) and then try to build or clean/build (sometimes this works from the 2nd time building for me)
a

aleksey.tomin

09/16/2020, 10:17 AM
pod install
works only in
severalTargetsXcodeProject
Copy code
$ pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] The Podfile contains command line tool target(s) (MacosCLI) which are attempting to integrate dynamic frameworks or libraries.
This may not behave as expected, because command line tools are usually distributed as a single binary and cannot contain their own dynamic dependencies.
But it doesn’t help
r

romtsn

09/16/2020, 10:29 AM
check here for me that worked out pretty well
a

aleksey.tomin

09/16/2020, 10:33 AM
I’ve removed
Pods/
, run
pod install
and
xcodebuild -scheme MacosCLI
The same problem
I haven’t opened Xcode
l

Liliia

09/16/2020, 4:51 PM
@aleksey.tomin, I’m sorry, there is one thing missed: Gradle wrapper is necessary. So when the project is ready, please run
gradle wrapper
command before executing step 4 in your description. Hope it helps.
a

aleksey.tomin

09/17/2020, 5:48 AM
@Liliia No… I’ve changed version of kotlin (to 1.4.10) and remove code signing - https://github.com/Kotlin/multitarget-xcode-with-kotlin-cocoapods-sample/pull/2 Next:
Copy code
$ pwd
.../multitarget-xcode-with-kotlin-cocoapods-sample
$ gradle clean build podInstall wrapper
... BUILD SUCCESSFUL
$ cd severalTargetsXcodeProject/
$ xcodebuild -scheme MacosCLI
...
#import "Headers/dummy.h"
        ^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/kotlin-library/build/cocoapods/framework/kotlin_library.framework/Headers/dummy.h:2:1: error: unknown type name 'FOUNDATION_EXPORT'
FOUNDATION_EXPORT double dummyVersionNumber;
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/dummy.h"
        ^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/kotlin-library/build/cocoapods/framework/kotlin_library.framework/Headers/dummy.h:5:1: error: unknown type name 'FOUNDATION_EXPORT'
FOUNDATION_EXPORT const unsigned char dummyVersionString[];
^
/Users/atomin/Documents/external/multitarget-xcode-with-kotlin-cocoapods-sample/severalTargetsXcodeProject/MacosCLI/main.swift:2:8: error: could not build Objective-C module 'kotlin_library'
import kotlin_library
       ^

** BUILD FAILED **
9 Views