ioscocoapodsfastlanekotlin-multiplatform

shared module binary of Kotlin Multiplatform App not packaged by fastlane


we are facing an issue with our CI/CD builds using fastlane on iOS for quite some time and I am now trying to resolve this issue.

We are developing a Kotlin Multiplatform app that has the shared module packaged via Cocoapods, which works great during development and even Archiving and releasing via XCode.

The CI/CD build using fastlane also works fine, the app is sucessfully build and published to App Center as ad-hoc release. However when I try to open the App on device it crashes right away. Checking the device logs I see this error:

ASI found [dyld] (sensitive) 'Library not loaded: @rpath/shared.framework/shared
Referenced from: <1BD25F02-DE04-35D4-BE94-37A6A7D3A268> /private/var/containers/Bundle/Application/B78CBDBE-5C0D-45E9-9CE9-E55D1A56166D/iosApp.app/iosApp
Reason: tried: '/usr/lib/swift/shared.framework/shared' (no such file, not in dyld cache), ...

I searched the web for solutions, however until now nothing pointed me into the right direction, so I hope someone can help me out.

Podfile:

target 'iosApp' do
  use_frameworks!
  platform :ios, '16.2'
  pod 'AppCenter'
  pod 'MaterialDesignSymbol'
  pod 'SwiftLint'
  pod 'shared', :path => '../shared'
end

Fastlane lane:

desc "Push a new beta build to App Center"
  lane :appcenter do
    # Fetch the list of all iOS devices your app is distributed to
      appcenter_fetch_devices(
        api_token: ENV["APPCENTER_API_TOKEN"],
        owner_name: ENV["APPCENTER_OWNER_NAME"],
        app_name: ENV["APPCENTER_IOS_APP_NAME"],
        destinations: "*",
        devices_file: "test-devices.txt"
      )

      # Ensure all devices are registered with Apple
      register_devices(devices_file: "test-devices.txt")

      # Provision test devices, download provisioning profile, and download signing certificate
      match(
        force_for_new_devices: true,
        type: "adhoc"
      )

      update_code_signing_settings(
        path: 'iosApp.xcodeproj',
        use_automatic_signing: false,
        team_id: ENV["sigh_com.example.myapp_adhoc_team-id"],
        profile_name: ENV["sigh_com.example.myapp_adhoc_profile-name"],
        code_sign_identity: ENV["sigh_com.example.myapp_adhoc_certificate-name"],
      )
      update_project_provisioning(
        xcodeproj: 'iosApp.xcodeproj',
        target_filter: "iosApp",
        profile: ENV["sigh_com.example.myapp_adhoc_profile-path"],
        code_signing_identity: ENV["sigh_com.example.myapp_adhoc_certificate-name"],
      )

      # Build the app
      gym(
        configuration: "Release",
        clean: true,
        include_symbols: false,
        include_bitcode: false,
      )

      # Upload the app
      appcenter_upload(
        release_notes: ENV["APPCENTER_CHANGELOG"],
      )
  end

Solution

  • The solution provided in this answer was the solution. In our case fastlane and Cocoapods did not have any issues during build time, however there seemed to be something missing that got resolved by building the dummy framework.

    Just call

    ./gradlew generateDummyFramework
    

    from your projects root directory before navigating into the iosApp folder and calling pod install.