Skip to content

Commit 1d6150d

Browse files
committed
l1-s18 integrate mpp library to ios by cocoapods
1 parent a9ab479 commit 1d6150d

6 files changed

Lines changed: 158 additions & 8 deletions

File tree

ios-app/Podfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ignore all warnings from all pods
2+
inhibit_all_warnings!
3+
4+
use_frameworks!
5+
platform :ios, '11.0'
6+
7+
# workaround for https://github.com/CocoaPods/CocoaPods/issues/8073
8+
# нужно чтобы кеш development pods корректно инвалидировался
9+
install! 'cocoapods', :disable_input_output_paths => true
10+
11+
target 'ios-app' do
12+
# MultiPlatformLibrary
13+
# для корректной установки фреймворка нужно сначала скомпилировать котлин библиотеку - compile-kotlin-framework.sh (в корневой директории репозитория)
14+
pod 'MultiPlatformLibrary', :path => '../mpp-library'
15+
end

ios-app/Podfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- MultiPlatformLibrary (0.1.0)
3+
4+
DEPENDENCIES:
5+
- MultiPlatformLibrary (from `../mpp-library`)
6+
7+
EXTERNAL SOURCES:
8+
MultiPlatformLibrary:
9+
:path: "../mpp-library"
10+
11+
SPEC CHECKSUMS:
12+
MultiPlatformLibrary: 176fb8ade516666cd47e93de1b71ba0441a541bb
13+
14+
PODFILE CHECKSUM: 81e02d8384876fe1d7c70c092cd2db353208c9c8
15+
16+
COCOAPODS: 1.7.5

ios-app/ios-app.xcodeproj/project.pbxproj

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
451E788823210A77000B4CF6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 451E788623210A77000B4CF6 /* Main.storyboard */; };
1313
451E788A23210A78000B4CF6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 451E788923210A78000B4CF6 /* Assets.xcassets */; };
1414
451E788D23210A78000B4CF6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 451E788B23210A78000B4CF6 /* LaunchScreen.storyboard */; };
15-
451E7897232111EE000B4CF6 /* MultiPlatformLibrary.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
16-
451E789A23211237000B4CF6 /* MultiPlatformLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */; };
15+
6B5B4D285228E7F0059305C3 /* Pods_ios_app.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */; };
1716
/* End PBXBuildFile section */
1817

1918
/* Begin PBXCopyFilesBuildPhase section */
@@ -23,7 +22,6 @@
2322
dstPath = "";
2423
dstSubfolderSpec = 10;
2524
files = (
26-
451E7897232111EE000B4CF6 /* MultiPlatformLibrary.framework in Embed Frameworks */,
2725
);
2826
name = "Embed Frameworks";
2927
runOnlyForDeploymentPostprocessing = 0;
@@ -38,15 +36,17 @@
3836
451E788923210A78000B4CF6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3937
451E788C23210A78000B4CF6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4038
451E788E23210A78000B4CF6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
41-
451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultiPlatformLibrary.framework; path = "../../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/MultiPlatformLibrary.framework"; sourceTree = "<group>"; };
39+
4DA1693661AF153E67051E6E /* Pods-ios-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-app.release.xcconfig"; path = "Target Support Files/Pods-ios-app/Pods-ios-app.release.xcconfig"; sourceTree = "<group>"; };
40+
949200E103F6B5AFEFE7452A /* Pods-ios-app.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-app.debug.xcconfig"; path = "Target Support Files/Pods-ios-app/Pods-ios-app.debug.xcconfig"; sourceTree = "<group>"; };
41+
E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_app.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4242
/* End PBXFileReference section */
4343

4444
/* Begin PBXFrameworksBuildPhase section */
4545
451E787C23210A77000B4CF6 /* Frameworks */ = {
4646
isa = PBXFrameworksBuildPhase;
4747
buildActionMask = 2147483647;
4848
files = (
49-
451E789A23211237000B4CF6 /* MultiPlatformLibrary.framework in Frameworks */,
49+
6B5B4D285228E7F0059305C3 /* Pods_ios_app.framework in Frameworks */,
5050
);
5151
runOnlyForDeploymentPostprocessing = 0;
5252
};
@@ -59,6 +59,7 @@
5959
451E788123210A77000B4CF6 /* ios-app */,
6060
451E788023210A77000B4CF6 /* Products */,
6161
451E789923211237000B4CF6 /* Frameworks */,
62+
567AC85FC79EA62EADD3E916 /* Pods */,
6263
);
6364
sourceTree = "<group>";
6465
};
@@ -79,29 +80,40 @@
7980
451E788923210A78000B4CF6 /* Assets.xcassets */,
8081
451E788B23210A78000B4CF6 /* LaunchScreen.storyboard */,
8182
451E788E23210A78000B4CF6 /* Info.plist */,
82-
451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */,
8383
);
8484
path = "ios-app";
8585
sourceTree = "<group>";
8686
};
8787
451E789923211237000B4CF6 /* Frameworks */ = {
8888
isa = PBXGroup;
8989
children = (
90+
E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */,
9091
);
9192
name = Frameworks;
9293
sourceTree = "<group>";
9394
};
95+
567AC85FC79EA62EADD3E916 /* Pods */ = {
96+
isa = PBXGroup;
97+
children = (
98+
949200E103F6B5AFEFE7452A /* Pods-ios-app.debug.xcconfig */,
99+
4DA1693661AF153E67051E6E /* Pods-ios-app.release.xcconfig */,
100+
);
101+
path = Pods;
102+
sourceTree = "<group>";
103+
};
94104
/* End PBXGroup section */
95105

96106
/* Begin PBXNativeTarget section */
97107
451E787E23210A77000B4CF6 /* ios-app */ = {
98108
isa = PBXNativeTarget;
99109
buildConfigurationList = 451E789123210A78000B4CF6 /* Build configuration list for PBXNativeTarget "ios-app" */;
100110
buildPhases = (
111+
035C9481D6D87FEB7C2E80A2 /* [CP] Check Pods Manifest.lock */,
101112
451E787B23210A77000B4CF6 /* Sources */,
102113
451E787C23210A77000B4CF6 /* Frameworks */,
103114
451E787D23210A77000B4CF6 /* Resources */,
104115
451E7898232111EE000B4CF6 /* Embed Frameworks */,
116+
BDD7FEDFC1B5F8712A00F639 /* [CP] Embed Pods Frameworks */,
105117
);
106118
buildRules = (
107119
);
@@ -158,6 +170,46 @@
158170
};
159171
/* End PBXResourcesBuildPhase section */
160172

173+
/* Begin PBXShellScriptBuildPhase section */
174+
035C9481D6D87FEB7C2E80A2 /* [CP] Check Pods Manifest.lock */ = {
175+
isa = PBXShellScriptBuildPhase;
176+
buildActionMask = 2147483647;
177+
files = (
178+
);
179+
inputFileListPaths = (
180+
);
181+
inputPaths = (
182+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
183+
"${PODS_ROOT}/Manifest.lock",
184+
);
185+
name = "[CP] Check Pods Manifest.lock";
186+
outputFileListPaths = (
187+
);
188+
outputPaths = (
189+
"$(DERIVED_FILE_DIR)/Pods-ios-app-checkManifestLockResult.txt",
190+
);
191+
runOnlyForDeploymentPostprocessing = 0;
192+
shellPath = /bin/sh;
193+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
194+
showEnvVarsInLog = 0;
195+
};
196+
BDD7FEDFC1B5F8712A00F639 /* [CP] Embed Pods Frameworks */ = {
197+
isa = PBXShellScriptBuildPhase;
198+
buildActionMask = 2147483647;
199+
files = (
200+
);
201+
inputFileListPaths = (
202+
);
203+
name = "[CP] Embed Pods Frameworks";
204+
outputFileListPaths = (
205+
);
206+
runOnlyForDeploymentPostprocessing = 0;
207+
shellPath = /bin/sh;
208+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ios-app/Pods-ios-app-frameworks.sh\"\n";
209+
showEnvVarsInLog = 0;
210+
};
211+
/* End PBXShellScriptBuildPhase section */
212+
161213
/* Begin PBXSourcesBuildPhase section */
162214
451E787B23210A77000B4CF6 /* Sources */ = {
163215
isa = PBXSourcesBuildPhase;
@@ -308,10 +360,10 @@
308360
};
309361
451E789223210A78000B4CF6 /* Debug */ = {
310362
isa = XCBuildConfiguration;
363+
baseConfigurationReference = 949200E103F6B5AFEFE7452A /* Pods-ios-app.debug.xcconfig */;
311364
buildSettings = {
312365
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
313366
CODE_SIGN_STYLE = Automatic;
314-
FRAMEWORK_SEARCH_PATHS = "../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/**";
315367
INFOPLIST_FILE = "ios-app/Info.plist";
316368
LD_RUNPATH_SEARCH_PATHS = (
317369
"$(inherited)",
@@ -326,10 +378,10 @@
326378
};
327379
451E789323210A78000B4CF6 /* Release */ = {
328380
isa = XCBuildConfiguration;
381+
baseConfigurationReference = 4DA1693661AF153E67051E6E /* Pods-ios-app.release.xcconfig */;
329382
buildSettings = {
330383
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
331384
CODE_SIGN_STYLE = Automatic;
332-
FRAMEWORK_SEARCH_PATHS = "../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/**";
333385
INFOPLIST_FILE = "ios-app/Info.plist";
334386
LD_RUNPATH_SEARCH_PATHS = (
335387
"$(inherited)",

ios-app/ios-app.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Pod::Spec.new do |spec|
2+
spec.name = 'MultiPlatformLibrary'
3+
spec.version = '0.1.0'
4+
spec.homepage = 'Link to a Kotlin/Native module homepage'
5+
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
6+
spec.authors = 'IceRock Development'
7+
spec.license = ''
8+
spec.summary = 'Shared code between iOS and Android'
9+
10+
spec.vendored_frameworks = "build/cocoapods/framework/#{spec.name}.framework"
11+
spec.libraries = "c++"
12+
spec.module_name = "#{spec.name}_umbrella"
13+
14+
spec.pod_target_xcconfig = {
15+
'MPP_LIBRARY_NAME' => 'MultiPlatformLibrary',
16+
'GRADLE_TASK[sdk=iphonesimulator*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosX64',
17+
'GRADLE_TASK[sdk=iphonesimulator*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosX64',
18+
'GRADLE_TASK[sdk=iphoneos*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosArm64',
19+
'GRADLE_TASK[sdk=iphoneos*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosArm64'
20+
}
21+
22+
spec.script_phases = [
23+
{
24+
:name => 'Compile Kotlin/Native',
25+
:execution_position => :before_compile,
26+
:shell_path => '/bin/sh',
27+
#:output_files => ['$TARGET_BUILD_DIR/$PRODUCT_NAME.framework/$PRODUCT_NAME'],
28+
:script => <<-SCRIPT
29+
MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
30+
31+
MPP_OUTPUT_DIR="$MPP_PROJECT_ROOT/build/cocoapods/framework"
32+
MPP_OUTPUT_NAME="$MPP_OUTPUT_DIR/#{spec.name}.framework"
33+
34+
"$MPP_PROJECT_ROOT/../gradlew" -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK"
35+
SCRIPT
36+
}
37+
]
38+
end

mpp-library/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
3+
14
apply plugin: 'com.android.library'
25
apply plugin: 'org.jetbrains.kotlin.multiplatform'
36

@@ -53,3 +56,19 @@ kotlin {
5356
}
5457
}
5558
}
59+
60+
tasks.toList().forEach { task ->
61+
if(!(task instanceof KotlinNativeLink)) return
62+
def framework = task.binary
63+
if(!(framework instanceof Framework)) return
64+
def linkTask = framework.linkTask
65+
66+
def syncTaskName = linkTask.name.replaceFirst("link", "sync")
67+
def syncFramework = tasks.create(syncTaskName, Sync.class) {
68+
group = "cocoapods"
69+
70+
from(framework.outputDirectory)
71+
into(file("build/cocoapods/framework"))
72+
}
73+
syncFramework.dependsOn(linkTask)
74+
}

0 commit comments

Comments
 (0)