icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1.02k stars 95 forks source link

adding MultiPlatformLibrary podspec #108

Closed hlnstepanova closed 3 years ago

hlnstepanova commented 3 years ago

Hi Alex,

I'm facing problems adding mvvm library to iOS project. I added all necessary dependencies. My project is based on KampKit, the shared library is named "shared" and is in /shared folder. The shared.podspec is:

    spec.name                     = 'shared'
    spec.version                  = '1.1'
    spec.homepage                 = 'https://'
    spec.source                   = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
    spec.authors                  = ''
    spec.license                  = ''
    spec.summary                  = 'ActiVacation traveller app'

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

    spec.pod_target_xcconfig = {
        'KOTLIN_TARGET[sdk=iphonesimulator*]' => 'ios_x64',
        'KOTLIN_TARGET[sdk=watchsimulator*]' => 'watchos_x86',
        'KOTLIN_TARGET[sdk=watchos*]' => 'watchos_arm',
        'KOTLIN_TARGET[sdk=appletvsimulator*]' => 'tvos_x64',
        'KOTLIN_TARGET[sdk=appletvos*]' => 'tvos_arm64',
        'KOTLIN_TARGET[sdk=macosx*]' => 'macos_x64',
        'KOTLIN_TARGET[sdk=iphoneos*]' => 'ios_arm64'
    }

    spec.script_phases = [
        {
            :name => 'Build shared',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
                set -ev
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" :shared:syncFramework \
                    -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET \
                    -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
                    -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
                    -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
                    -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT/../" :shared:copyFrameworkResourcesToApp \
                                    -Pmoko.resources.PLATFORM_NAME=$PLATFORM_NAME \
                                    -Pmoko.resources.CONFIGURATION=$CONFIGURATION \
                                    -Pmoko.resources.BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR \
                                    -Pmoko.resources.CONTENTS_FOLDER_PATH=$CONTENTS_FOLDER_PATH \
                                    -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET \
                                    -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
                                    -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
                                    -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
                                    -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"

            SCRIPT
        },
        {
            :name => 'Touch shared.framework',
            :execution_position => :after_compile,
            :shell_path =>  '/bin/sh',
            :script => 'find "${SRCROOT}" -type f -name *frameworks.sh -exec bash -c "touch \"{}\"" \;'
        }
    ]
end

How can I merge this podspec with this? https://github.com/icerockdev/moko-mvvm/blob/master/sample/mpp-library/MultiPlatformLibrary.podspec

I also tried doing necessary changes to Podfile

 inhibit_all_warnings!

 use_frameworks!
 platform :ios, '11.0'

 # workaround for https://github.com/CocoaPods/CocoaPods/issues/8073
 # need for correct invalidate of cache MultiPlatformLibrary.framework
 install! 'cocoapods', :disable_input_output_paths => true

 target 'actiVacation' do
     pod 'MultiPlatformLibrary', :path => '../shared/'
     pod 'MultiPlatformLibraryMvvm', :git => 'https://github.com/icerockdev/moko-mvvm.git', :tag => 'release/0.9.1'
 end

But then I get Task 'syncMultiPlatformLibraryDebugFrameworkIosX64' not found in project ':shared'.

What else do I have to rename or change? Here is the link to the project https://github.com/hlnstepanova/vamos

Dorofeev commented 3 years ago

Since Moko-mvvm version 0.9.0 adding MultiPlatformLibraryMvvm pod is unnecessary. All bindings available without using cocoa pod, here https://github.com/icerockdev/moko-mvvm/tree/master/mvvm-livedata/src/iosMain/kotlin/dev/icerock/moko/mvvm/binding

If you still want to use old bindings from MultiPlatformLibraryMvvm pod, you need to: rename shared.podspec to MultiPlatformLibrary.podspec spec.name change to MultiPlatformLibrary That should be enough

hlnstepanova commented 3 years ago

Thanks for the info!