diff --git a/samples/cocoapods/.gitignore b/samples/cocoapods/.gitignore new file mode 100644 index 00000000000..cb31971741e --- /dev/null +++ b/samples/cocoapods/.gitignore @@ -0,0 +1,2 @@ +ios-app/Pods +kotlin-library/kotlin_library.podspec \ No newline at end of file diff --git a/samples/cocoapods/README.md b/samples/cocoapods/README.md new file mode 100644 index 00000000000..1ca3519956f --- /dev/null +++ b/samples/cocoapods/README.md @@ -0,0 +1,24 @@ +# Using CocoaPods + +This sample demonstrates how to use a CocoaPods library from Kotlin/Native. It uses the the +[AFNetworking](https://cocoapods.org/pods/AFNetworking) library to retrieve a web-page by a +given URL. + +## Configuring the project +1. [Install](https://guides.cocoapods.org/using/getting-started.html#installation) CocoaPods. + It's recommended to use CocoaPods 1.6.1 or higher. + +2. Navigate to the [kotlin-library](kotlin-library) directory and run + ``` + ./gradlew podspec + ``` + A [podspec](https://guides.cocoapods.org/syntax/podspec.html#specification) file for the + Kotlin/Native library will be generated. + +3. Navigate to the [ios-app](ios-app) directory and install the dependencies. The generated + podspec is already added in the Podfile, so just run + ``` + pod install + ``` + +4. Open [ios-app.xcworkspace](ios-app/ios-app.xcworkspace) in Xcode and run the build. \ No newline at end of file diff --git a/samples/cocoapods/build.sh b/samples/cocoapods/build.sh new file mode 100755 index 00000000000..b0a74aece2f --- /dev/null +++ b/samples/cocoapods/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd ) + +KOTLIN_DIR="$DIR/kotlin-library" +IOS_DIR="$DIR/ios-app" + +# Prepare Kotlin/Native project to be consumed by CocoaPods. +"$KOTLIN_DIR/gradlew" -p "$KOTLIN_DIR" podspec + +# Run CocoaPods to configure the Xcode project. +pod --project-directory="$IOS_DIR" install + +# Run Xcode to build the app. +xcodebuild -sdk iphonesimulator12.1 -configuration Release -workspace "$IOS_DIR/ios-app.xcworkspace" -scheme ios-app + diff --git a/samples/cocoapods/ios-app/Podfile b/samples/cocoapods/ios-app/Podfile new file mode 100644 index 00000000000..b192a93bd6a --- /dev/null +++ b/samples/cocoapods/ios-app/Podfile @@ -0,0 +1,6 @@ +# Either use_frameworks! or use_modular_headers! must be specified. +use_frameworks! + +target 'ios-app' do + pod 'kotlin_library', :path => '../kotlin-library' +end \ No newline at end of file diff --git a/samples/cocoapods/ios-app/Podfile.lock b/samples/cocoapods/ios-app/Podfile.lock new file mode 100644 index 00000000000..0b33d6c5ee6 --- /dev/null +++ b/samples/cocoapods/ios-app/Podfile.lock @@ -0,0 +1,37 @@ +PODS: + - AFNetworking (3.2.1): + - AFNetworking/NSURLSession (= 3.2.1) + - AFNetworking/Reachability (= 3.2.1) + - AFNetworking/Security (= 3.2.1) + - AFNetworking/Serialization (= 3.2.1) + - AFNetworking/UIKit (= 3.2.1) + - AFNetworking/NSURLSession (3.2.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (3.2.1) + - AFNetworking/Security (3.2.1) + - AFNetworking/Serialization (3.2.1) + - AFNetworking/UIKit (3.2.1): + - AFNetworking/NSURLSession + - kotlin_library (1.0): + - AFNetworking (~> 3.2.0) + +DEPENDENCIES: + - kotlin_library (from `../kotlin-library`) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - AFNetworking + +EXTERNAL SOURCES: + kotlin_library: + :path: "../kotlin-library" + +SPEC CHECKSUMS: + AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 + kotlin_library: 8f1a944f60ef52dc0300d95269701846baaf153f + +PODFILE CHECKSUM: 6d9fe10c2c0a5a7ce332795392e81cfa991627a6 + +COCOAPODS: 1.6.1 diff --git a/samples/cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj new file mode 100644 index 00000000000..a26d413bfd4 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.pbxproj @@ -0,0 +1,417 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 2C11BACF224B4DCB00D1CC3C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C11BACE224B4DCB00D1CC3C /* AppDelegate.swift */; }; + 2C11BAD1224B4DCB00D1CC3C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C11BAD0224B4DCB00D1CC3C /* ViewController.swift */; }; + 2C11BAD4224B4DCB00D1CC3C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C11BAD2224B4DCB00D1CC3C /* Main.storyboard */; }; + 2C11BAD6224B4DCD00D1CC3C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2C11BAD5224B4DCD00D1CC3C /* Assets.xcassets */; }; + 2C11BAD9224B4DCD00D1CC3C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2C11BAD7224B4DCD00D1CC3C /* LaunchScreen.storyboard */; }; + 7AEB35573DF5ECC0B96C877C /* Pods_ios_app.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06FDB564DA981DADB5693C07 /* Pods_ios_app.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 06FDB564DA981DADB5693C07 /* Pods_ios_app.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_app.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2C11BACB224B4DCB00D1CC3C /* ios-app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-app.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 2C11BACE224B4DCB00D1CC3C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 2C11BAD0224B4DCB00D1CC3C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 2C11BAD3224B4DCB00D1CC3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 2C11BAD5224B4DCD00D1CC3C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 2C11BAD8224B4DCD00D1CC3C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 2C11BADA224B4DCD00D1CC3C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2C11BAE0224B65DE00D1CC3C /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + 44888DA7148EA4EB17DF765D /* 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 = ""; }; + A063F818143EBBCD07EA19D4 /* 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 = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2C11BAC8224B4DCB00D1CC3C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 7AEB35573DF5ECC0B96C877C /* Pods_ios_app.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 2C11BAC2224B4DCB00D1CC3C = { + isa = PBXGroup; + children = ( + 2C11BACD224B4DCB00D1CC3C /* ios-app */, + 2C11BACC224B4DCB00D1CC3C /* Products */, + 9C1A5E5C1B80F794B7154EE0 /* Pods */, + B404E0DEAC80D8DB556F0E49 /* Frameworks */, + ); + sourceTree = ""; + }; + 2C11BACC224B4DCB00D1CC3C /* Products */ = { + isa = PBXGroup; + children = ( + 2C11BACB224B4DCB00D1CC3C /* ios-app.app */, + ); + name = Products; + sourceTree = ""; + }; + 2C11BACD224B4DCB00D1CC3C /* ios-app */ = { + isa = PBXGroup; + children = ( + 2C11BACE224B4DCB00D1CC3C /* AppDelegate.swift */, + 2C11BAD0224B4DCB00D1CC3C /* ViewController.swift */, + 2C11BAD2224B4DCB00D1CC3C /* Main.storyboard */, + 2C11BAD5224B4DCD00D1CC3C /* Assets.xcassets */, + 2C11BAD7224B4DCD00D1CC3C /* LaunchScreen.storyboard */, + 2C11BADA224B4DCD00D1CC3C /* Info.plist */, + ); + path = "ios-app"; + sourceTree = ""; + }; + 9C1A5E5C1B80F794B7154EE0 /* Pods */ = { + isa = PBXGroup; + children = ( + 44888DA7148EA4EB17DF765D /* Pods-ios-app.debug.xcconfig */, + A063F818143EBBCD07EA19D4 /* Pods-ios-app.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + B404E0DEAC80D8DB556F0E49 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 2C11BAE0224B65DE00D1CC3C /* WebKit.framework */, + 06FDB564DA981DADB5693C07 /* Pods_ios_app.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2C11BACA224B4DCB00D1CC3C /* ios-app */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2C11BADD224B4DCD00D1CC3C /* Build configuration list for PBXNativeTarget "ios-app" */; + buildPhases = ( + F305A4DC70C8B21755898707 /* [CP] Check Pods Manifest.lock */, + 2C11BAC7224B4DCB00D1CC3C /* Sources */, + 2C11BAC8224B4DCB00D1CC3C /* Frameworks */, + 2C11BAC9224B4DCB00D1CC3C /* Resources */, + 042B85E17AFECF20FF11D591 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-app"; + productName = "ios-app"; + productReference = 2C11BACB224B4DCB00D1CC3C /* ios-app.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2C11BAC3224B4DCB00D1CC3C /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1010; + LastUpgradeCheck = 1010; + TargetAttributes = { + 2C11BACA224B4DCB00D1CC3C = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = 2C11BAC6224B4DCB00D1CC3C /* Build configuration list for PBXProject "ios-app" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2C11BAC2224B4DCB00D1CC3C; + productRefGroup = 2C11BACC224B4DCB00D1CC3C /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2C11BACA224B4DCB00D1CC3C /* ios-app */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2C11BAC9224B4DCB00D1CC3C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C11BAD9224B4DCD00D1CC3C /* LaunchScreen.storyboard in Resources */, + 2C11BAD6224B4DCD00D1CC3C /* Assets.xcassets in Resources */, + 2C11BAD4224B4DCB00D1CC3C /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 042B85E17AFECF20FF11D591 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-ios-app/Pods-ios-app-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-ios-app/Pods-ios-app-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + F305A4DC70C8B21755898707 /* [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; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2C11BAC7224B4DCB00D1CC3C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2C11BAD1224B4DCB00D1CC3C /* ViewController.swift in Sources */, + 2C11BACF224B4DCB00D1CC3C /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 2C11BAD2224B4DCB00D1CC3C /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2C11BAD3224B4DCB00D1CC3C /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 2C11BAD7224B4DCD00D1CC3C /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2C11BAD8224B4DCD00D1CC3C /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2C11BADB224B4DCD00D1CC3C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 2C11BADC224B4DCD00D1CC3C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2C11BADE224B4DCD00D1CC3C /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 44888DA7148EA4EB17DF765D /* Pods-ios-app.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "ios-app/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.konan.ios-app"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 2C11BADF224B4DCD00D1CC3C /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A063F818143EBBCD07EA19D4 /* Pods-ios-app.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "ios-app/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.konan.ios-app"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2C11BAC6224B4DCB00D1CC3C /* Build configuration list for PBXProject "ios-app" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C11BADB224B4DCD00D1CC3C /* Debug */, + 2C11BADC224B4DCD00D1CC3C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2C11BADD224B4DCD00D1CC3C /* Build configuration list for PBXNativeTarget "ios-app" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2C11BADE224B4DCD00D1CC3C /* Debug */, + 2C11BADF224B4DCD00D1CC3C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2C11BAC3224B4DCB00D1CC3C /* Project object */; +} diff --git a/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..136ada05267 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000000..18d981003d6 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000000..89d760be5f5 Binary files /dev/null and b/samples/cocoapods/ios-app/ios-app.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/samples/cocoapods/ios-app/ios-app.xcodeproj/xcuserdata/jetbrains.xcuserdatad/xcschemes/xcschememanagement.plist b/samples/cocoapods/ios-app/ios-app.xcodeproj/xcuserdata/jetbrains.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000000..ef8586899ae --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcodeproj/xcuserdata/jetbrains.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + ios-app.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/samples/cocoapods/ios-app/ios-app.xcworkspace/contents.xcworkspacedata b/samples/cocoapods/ios-app/ios-app.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..1068335b31c --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/samples/cocoapods/ios-app/ios-app.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/samples/cocoapods/ios-app/ios-app.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000000..18d981003d6 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/samples/cocoapods/ios-app/ios-app.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate b/samples/cocoapods/ios-app/ios-app.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000000..c8005bff1c7 Binary files /dev/null and b/samples/cocoapods/ios-app/ios-app.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/samples/cocoapods/ios-app/ios-app/AppDelegate.swift b/samples/cocoapods/ios-app/ios-app/AppDelegate.swift new file mode 100644 index 00000000000..849f883d23e --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/AppDelegate.swift @@ -0,0 +1,38 @@ +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/samples/cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000000..d8db8d65fd7 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/samples/cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json b/samples/cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json new file mode 100644 index 00000000000..da4a164c918 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/samples/cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard b/samples/cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000000..bfa36129419 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard b/samples/cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard new file mode 100644 index 00000000000..29d14b9fb3a --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/Base.lproj/Main.storyboard @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/cocoapods/ios-app/ios-app/Info.plist b/samples/cocoapods/ios-app/ios-app/Info.plist new file mode 100644 index 00000000000..16be3b68112 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/samples/cocoapods/ios-app/ios-app/ViewController.swift b/samples/cocoapods/ios-app/ios-app/ViewController.swift new file mode 100644 index 00000000000..7325dd25b40 --- /dev/null +++ b/samples/cocoapods/ios-app/ios-app/ViewController.swift @@ -0,0 +1,21 @@ +import UIKit +import kotlin_library + +class ViewController: UIViewController { + + @IBOutlet weak var goButton: UIButton! + @IBOutlet weak var urlField: UITextField! + @IBOutlet weak var contentTextView: UITextView! + + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + @IBAction func onGoTouch(_ sender: Any) { + let url = urlField.text! + KotlinLibKt.getAndShow(url: url, contentView: contentTextView) + } +} + diff --git a/samples/cocoapods/kotlin-library/build.gradle.kts b/samples/cocoapods/kotlin-library/build.gradle.kts new file mode 100644 index 00000000000..9f98b1cee62 --- /dev/null +++ b/samples/cocoapods/kotlin-library/build.gradle.kts @@ -0,0 +1,32 @@ +plugins { + id("org.jetbrains.kotlin.multiplatform") + id("org.jetbrains.kotlin.native.cocoapods") +} + +repositories { + jcenter() + maven { setUrl("https://dl.bintray.com/kotlin/kotlin-dev") } + maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") } +} + +group = "org.jetbrains.kotlin.sample.native" +version = "1.0" + +kotlin { + // Add a platform switching to have an IDE support. + val buildForDevice = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false + if (buildForDevice) { + iosArm64("iOS") + } else { + iosX64("iOS") + } + + cocoapods { + // Configure fields required by CocoaPods. + summary = "Working with AFNetworking from Kotlin/Native using CocoaPods" + homepage = "https://github.com/JetBrains/kotlin-native" + + // Configure a dependency on AFNetworking. It will be added in all macOS and iOS targets. + pod("AFNetworking", "~> 3.2.0") + } +} diff --git a/samples/cocoapods/kotlin-library/gradle.properties b/samples/cocoapods/kotlin-library/gradle.properties new file mode 100644 index 00000000000..270d6aecf68 --- /dev/null +++ b/samples/cocoapods/kotlin-library/gradle.properties @@ -0,0 +1 @@ +org.jetbrains.kotlin.native.home=../../../dist \ No newline at end of file diff --git a/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.jar b/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..91ca28c8b80 Binary files /dev/null and b/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.properties b/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..6b3851a8ad2 --- /dev/null +++ b/samples/cocoapods/kotlin-library/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/samples/cocoapods/kotlin-library/gradlew b/samples/cocoapods/kotlin-library/gradlew new file mode 100755 index 00000000000..cccdd3d517f --- /dev/null +++ b/samples/cocoapods/kotlin-library/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/samples/cocoapods/kotlin-library/gradlew.bat b/samples/cocoapods/kotlin-library/gradlew.bat new file mode 100644 index 00000000000..e95643d6a2c --- /dev/null +++ b/samples/cocoapods/kotlin-library/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/cocoapods/kotlin-library/settings.gradle.kts b/samples/cocoapods/kotlin-library/settings.gradle.kts new file mode 100644 index 00000000000..a00d777ee3f --- /dev/null +++ b/samples/cocoapods/kotlin-library/settings.gradle.kts @@ -0,0 +1,41 @@ +pluginManagement { + repositories { + jcenter() + maven { setUrl("https://dl.bintray.com/kotlin/kotlin-dev") } + maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") } + } + + resolutionStrategy { + // Workaround to be able to read plugin version from the properties file. + // See: https://stackoverflow.com/questions/52800536/how-to-use-plugin-version-from-gradle-properties-in-gradle-kotlin-dsl. + val kotlinVersion = getRootProperties().getValue("kotlin_version") as String + eachPlugin { + when { + requested.id.id == "org.jetbrains.kotlin.native.cocoapods" || + requested.id.id == "kotlin-native-cocoapods" -> + useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + requested.id.id.startsWith("org.jetbrains.kotlin") -> + useVersion(kotlinVersion) + } + } + } +} + +// Reuse Kotlin version and other properties from the root samples project. +fun getRootProperties() = java.util.Properties().apply { + val rootProjectGradlePropertiesFile = file("${rootProject.projectDir}/../../gradle.properties") + if (!rootProjectGradlePropertiesFile.isFile) { + throw Exception("File $rootProjectGradlePropertiesFile does not exist or is not a file") + } + + rootProjectGradlePropertiesFile.inputStream().use { inputStream -> + load(inputStream) + } +} + +gradle.beforeProject { + getRootProperties().forEach { key, value -> + if (!project.hasProperty(key as String)) + project.extra[key] = value + } +} diff --git a/samples/cocoapods/kotlin-library/src/iosMain/kotlin/KotlinLib.kt b/samples/cocoapods/kotlin-library/src/iosMain/kotlin/KotlinLib.kt new file mode 100644 index 00000000000..3c35250e9b9 --- /dev/null +++ b/samples/cocoapods/kotlin-library/src/iosMain/kotlin/KotlinLib.kt @@ -0,0 +1,34 @@ +import cocoapods.AFNetworking.AFHTTPResponseSerializer +import cocoapods.AFNetworking.AFHTTPSessionManager +import platform.Foundation.* +import platform.UIKit.NSDocumentTypeDocumentAttribute +import platform.UIKit.NSHTMLTextDocumentType +import platform.UIKit.UITextView +import platform.UIKit.create +import kotlin.Any +import kotlin.String +import kotlin.to +import kotlin.toString + +/** + * Retrieves the content by the given URL and shows it at the given WebKitView + */ +fun getAndShow(url: String, contentView: UITextView) { + val manager = AFHTTPSessionManager() + manager.responseSerializer = AFHTTPResponseSerializer() + val onSuccess = { _: NSURLSessionDataTask?, response: Any? -> + val html = NSAttributedString.create( + data = response as NSData, + options = mapOf(NSDocumentTypeDocumentAttribute as Any? to NSHTMLTextDocumentType), + documentAttributes = null, + error = null + )!! + contentView.attributedText = html + } + val onError = { _: NSURLSessionDataTask?, error: NSError? -> + NSLog("Cannot get ${url}.") + NSLog(error.toString()) + } + + manager.GET(url, null, onSuccess, onError) +} \ No newline at end of file diff --git a/samples/gradle.properties b/samples/gradle.properties index 7eac8dd49ac..c258c3de2e0 100644 --- a/samples/gradle.properties +++ b/samples/gradle.properties @@ -2,7 +2,7 @@ org.gradle.parallel=true # Pin Kotlin version: -kotlin_version=1.3.21 +kotlin_version=1.3.30-eap-113 # Use custom Kotlin/Native home: org.jetbrains.kotlin.native.home=../../dist