Skip to content

Commit

Permalink
l1-s18 integrate mpp library to ios by cocoapods
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Sep 5, 2019
1 parent a9ab479 commit 1d6150d
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 8 deletions.
15 changes: 15 additions & 0 deletions ios-app/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ignore all warnings from all pods
inhibit_all_warnings!

use_frameworks!
platform :ios, '11.0'

# workaround for https://github.com/CocoaPods/CocoaPods/issues/8073
# нужно чтобы кеш development pods корректно инвалидировался
install! 'cocoapods', :disable_input_output_paths => true

target 'ios-app' do
# MultiPlatformLibrary
# для корректной установки фреймворка нужно сначала скомпилировать котлин библиотеку - compile-kotlin-framework.sh (в корневой директории репозитория)
pod 'MultiPlatformLibrary', :path => '../mpp-library'
end
16 changes: 16 additions & 0 deletions ios-app/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- MultiPlatformLibrary (0.1.0)

DEPENDENCIES:
- MultiPlatformLibrary (from `../mpp-library`)

EXTERNAL SOURCES:
MultiPlatformLibrary:
:path: "../mpp-library"

SPEC CHECKSUMS:
MultiPlatformLibrary: 176fb8ade516666cd47e93de1b71ba0441a541bb

PODFILE CHECKSUM: 81e02d8384876fe1d7c70c092cd2db353208c9c8

COCOAPODS: 1.7.5
68 changes: 60 additions & 8 deletions ios-app/ios-app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
451E788823210A77000B4CF6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 451E788623210A77000B4CF6 /* Main.storyboard */; };
451E788A23210A78000B4CF6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 451E788923210A78000B4CF6 /* Assets.xcassets */; };
451E788D23210A78000B4CF6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 451E788B23210A78000B4CF6 /* LaunchScreen.storyboard */; };
451E7897232111EE000B4CF6 /* MultiPlatformLibrary.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
451E789A23211237000B4CF6 /* MultiPlatformLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */; };
6B5B4D285228E7F0059305C3 /* Pods_ios_app.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -23,7 +22,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
451E7897232111EE000B4CF6 /* MultiPlatformLibrary.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -38,15 +36,17 @@
451E788923210A78000B4CF6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
451E788C23210A78000B4CF6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
451E788E23210A78000B4CF6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MultiPlatformLibrary.framework; path = "../../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/MultiPlatformLibrary.framework"; sourceTree = "<group>"; };
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>"; };
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>"; };
E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_app.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
451E787C23210A77000B4CF6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
451E789A23211237000B4CF6 /* MultiPlatformLibrary.framework in Frameworks */,
6B5B4D285228E7F0059305C3 /* Pods_ios_app.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -59,6 +59,7 @@
451E788123210A77000B4CF6 /* ios-app */,
451E788023210A77000B4CF6 /* Products */,
451E789923211237000B4CF6 /* Frameworks */,
567AC85FC79EA62EADD3E916 /* Pods */,
);
sourceTree = "<group>";
};
Expand All @@ -79,29 +80,40 @@
451E788923210A78000B4CF6 /* Assets.xcassets */,
451E788B23210A78000B4CF6 /* LaunchScreen.storyboard */,
451E788E23210A78000B4CF6 /* Info.plist */,
451E7894232111BD000B4CF6 /* MultiPlatformLibrary.framework */,
);
path = "ios-app";
sourceTree = "<group>";
};
451E789923211237000B4CF6 /* Frameworks */ = {
isa = PBXGroup;
children = (
E0B339EB48D758BA5C1D29E7 /* Pods_ios_app.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
567AC85FC79EA62EADD3E916 /* Pods */ = {
isa = PBXGroup;
children = (
949200E103F6B5AFEFE7452A /* Pods-ios-app.debug.xcconfig */,
4DA1693661AF153E67051E6E /* Pods-ios-app.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
451E787E23210A77000B4CF6 /* ios-app */ = {
isa = PBXNativeTarget;
buildConfigurationList = 451E789123210A78000B4CF6 /* Build configuration list for PBXNativeTarget "ios-app" */;
buildPhases = (
035C9481D6D87FEB7C2E80A2 /* [CP] Check Pods Manifest.lock */,
451E787B23210A77000B4CF6 /* Sources */,
451E787C23210A77000B4CF6 /* Frameworks */,
451E787D23210A77000B4CF6 /* Resources */,
451E7898232111EE000B4CF6 /* Embed Frameworks */,
BDD7FEDFC1B5F8712A00F639 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -158,6 +170,46 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
035C9481D6D87FEB7C2E80A2 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-ios-app-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
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";
showEnvVarsInLog = 0;
};
BDD7FEDFC1B5F8712A00F639 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ios-app/Pods-ios-app-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
451E787B23210A77000B4CF6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -308,10 +360,10 @@
};
451E789223210A78000B4CF6 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 949200E103F6B5AFEFE7452A /* Pods-ios-app.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
FRAMEWORK_SEARCH_PATHS = "../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/**";
INFOPLIST_FILE = "ios-app/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -326,10 +378,10 @@
};
451E789323210A78000B4CF6 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4DA1693661AF153E67051E6E /* Pods-ios-app.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
FRAMEWORK_SEARCH_PATHS = "../mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/**";
INFOPLIST_FILE = "ios-app/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
10 changes: 10 additions & 0 deletions ios-app/ios-app.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions mpp-library/MultiPlatformLibrary.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Pod::Spec.new do |spec|
spec.name = 'MultiPlatformLibrary'
spec.version = '0.1.0'
spec.homepage = 'Link to a Kotlin/Native module homepage'
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
spec.authors = 'IceRock Development'
spec.license = ''
spec.summary = 'Shared code between iOS and Android'

spec.vendored_frameworks = "build/cocoapods/framework/#{spec.name}.framework"
spec.libraries = "c++"
spec.module_name = "#{spec.name}_umbrella"

spec.pod_target_xcconfig = {
'MPP_LIBRARY_NAME' => 'MultiPlatformLibrary',
'GRADLE_TASK[sdk=iphonesimulator*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosX64',
'GRADLE_TASK[sdk=iphonesimulator*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosX64',
'GRADLE_TASK[sdk=iphoneos*][config=*ebug]' => 'syncMultiPlatformLibraryDebugFrameworkIosArm64',
'GRADLE_TASK[sdk=iphoneos*][config=*elease]' => 'syncMultiPlatformLibraryReleaseFrameworkIosArm64'
}

spec.script_phases = [
{
:name => 'Compile Kotlin/Native',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
#:output_files => ['$TARGET_BUILD_DIR/$PRODUCT_NAME.framework/$PRODUCT_NAME'],
:script => <<-SCRIPT
MPP_PROJECT_ROOT="$SRCROOT/../../mpp-library"
MPP_OUTPUT_DIR="$MPP_PROJECT_ROOT/build/cocoapods/framework"
MPP_OUTPUT_NAME="$MPP_OUTPUT_DIR/#{spec.name}.framework"
"$MPP_PROJECT_ROOT/../gradlew" -p "$MPP_PROJECT_ROOT" "$GRADLE_TASK"
SCRIPT
}
]
end
19 changes: 19 additions & 0 deletions mpp-library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink

apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.multiplatform'

Expand Down Expand Up @@ -53,3 +56,19 @@ kotlin {
}
}
}

tasks.toList().forEach { task ->
if(!(task instanceof KotlinNativeLink)) return
def framework = task.binary
if(!(framework instanceof Framework)) return
def linkTask = framework.linkTask

def syncTaskName = linkTask.name.replaceFirst("link", "sync")
def syncFramework = tasks.create(syncTaskName, Sync.class) {
group = "cocoapods"

from(framework.outputDirectory)
into(file("build/cocoapods/framework"))
}
syncFramework.dependsOn(linkTask)
}

0 comments on commit 1d6150d

Please sign in to comment.