Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources Missing After Publishing Pod to Artifactory #4954

Closed
faliinitse opened this issue Jun 11, 2024 · 2 comments
Closed

Resources Missing After Publishing Pod to Artifactory #4954

faliinitse opened this issue Jun 11, 2024 · 2 comments
Assignees
Labels
bug Something isn't working resources

Comments

@faliinitse
Copy link

Description
We have started using Kotlin Multiplatform (KMP) as an external library for our project. Everything works fine locally, and resources are accessible when using CocoaPods and referencing the local KMP project. However, when we publish the pod to Artifactory using the podPublishReleaseXCFramework command, the resources (e.g., localized strings) are not available in the iOS code.

Steps to Reproduce

  1. Add localized strings as resources to be shared across all platforms.
  2. Use CocoaPods to reference the local KMP project in the Podfile:

pod 'shared', :path => '../shared'

  1. Run pod install and verify that the resources are available and accessible in the iOS code.
  2. Publish the pod to Artifactory using the following process:
val versionName: String = "0.1.1"
println("Version name: $versionName")
val cocoapodDir: String = project.layout.buildDirectory.dir("cocoapods/publish").get().toString()
val artifactApiKey: String = artifactoryCocoapodsApiKey
val artifactUrl = "${artifactoryCocoapodsUrl}ios-libs-releases-local/Shared/$versionName/"
val tarFileName = "shared.tar.gz"

// Instructions
val changeToDirectory = "cd $cocoapodDir"
val listDirectoryContent = "ls"
val archiveReleaseDirectoryContent = "tar -czvf $tarFileName -C release \$(ls release)"
val printUploadMessage = "echo 'Now, upload the file to the artifact $artifactUrl'"
val uploadFileToRepo =
    "curl  -H 'X-JFrog-Art-Api:$artifactApiKey' -XPUT $artifactUrl -T $tarFileName"
val printRemoveMessage = "echo 'now, remove the file from local'"
val removeArchive = "rm $tarFileName"

exec {
    commandLine("sh", "-c", "" +
            "$changeToDirectory && " +
            "$listDirectoryContent && " +
            "$archiveReleaseDirectoryContent && " +
            "$printUploadMessage && " +
            "$uploadFileToRepo && " +
            "$printRemoveMessage && " +
            "$removeArchive"
    )
}

Generated Podspec

Pod::Spec.new do |spec|
    spec.name                     = 'shared'
    spec.version                  = '0.1.1'
    spec.homepage                 = ''
    spec.source                   = { :http => '' }
    spec.authors                  = ''
    spec.license                  = { :type => 'MIT', :text => 'License text' }
    spec.summary                  = 'Some description for a Kotlin/Native module'
    spec.vendored_frameworks      = 'build/cocoapods/framework/shared.framework'
    spec.libraries                = 'c++'
    spec.ios.deployment_target    = '13.0'

    if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework')
        raise "
        Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated.
        'pod install' should be executed after running ':generateDummyFramework' Gradle task:
            ./gradlew :shared:generateDummyFramework
        Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
    end

    spec.pod_target_xcconfig = {
        'KOTLIN_PROJECT_PATH' => ':shared',
        'PRODUCT_MODULE_NAME' => 'shared',
    }

    spec.script_phases = [
        {
            :name => 'Build shared',
            :execution_position => :before_compile,
            :shell_path => '/bin/sh',
            :script => <<-SCRIPT
                if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
                  echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
                  exit 0
                fi
                set -ev
                REPO_ROOT="$PODS_TARGET_SRCROOT"
                "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
                    -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
                    -Pkotlin.native.cocoapods.archs="$ARCHS" \
                    -Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
            SCRIPT
        }
    ]

    spec.resources = ['build/compose/cocoapods/compose-resources']
end

Expected Behavior
The resources, such as localized strings, should be available and accessible in the iOS project both when using the local KMP project and when using the published version from Artifactory.

Actual Behavior
The resources are available and accessible when using the local KMP project. However, after publishing the pod to Artifactory and using the published version, the resources are not available in the iOS project.

Additional Information
Any insights or solutions to ensure the resources are included and accessible when the pod is published to Artifactory would be greatly appreciated.

@faliinitse faliinitse added bug Something isn't working submitted labels Jun 11, 2024
@Schahen Schahen removed the submitted label Jun 11, 2024
@terrakok
Copy link
Collaborator

Duplicates #4643

More info here: https://youtrack.jetbrains.com/issue/KT-66790

@okushnikov
Copy link

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resources
Projects
None yet
Development

No branches or pull requests

4 participants