klarna / klarna-mobile-sdk

Klarna Mobile SDK for iOS
https://docs.klarna.com/mobile-sdk/ios/
Apache License 2.0
29 stars 12 forks source link

iOS App will not build on Xcode 11.3 with KlarnaMobileSDK imported #10

Closed stickmanlechu closed 4 years ago

stickmanlechu commented 4 years ago

Hi! The app I'm currently developing will not build with KlarnaMobileSDK imported with the following error: Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.3 compiler: (...)/Pods/KlarnaMobileSDK/ios/xcode-swift51-fat/KlarnaMobileSDK.framework/Modules/KlarnaMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftmodule

Steps to reproduce the behavior:

  1. Add pod 'KlarnaMobileSDK/xcode-swift51-fat', '~> 2.0.8' to the pod file
  2. Add import KlarnaMobileSDK in any of the Swift files
  3. Build

Expected behavior The whole workspace is expected to build successfully.

Device and version:

Additional context Supposedly adding: BUILD_LIBRARY_FOR_DISTRIBUTION = YES; to project file ensures module stability needed for the binary to be properly imported within the app.

omarbh commented 4 years ago

Hi @stickmanlechu, thanks for reporting this, we will look into it and get back to you.

Ladret commented 4 years ago

Hi @stickmanlechu, thanks for reporting this, we will look into it and get back to you.

Hi @omarbh how long do you estimate this could take to fix, days, weeks, months?

ghost commented 4 years ago

Hey @Ladret @stickmanlechu! Have you tried running having pod "KlarnaMobileSDK/xcode112beta1-swift51-fat" in your podfile? That might help!

stickmanlechu commented 4 years ago

Hi @ekaterina-dvuzhilova-klarna. Although xcode112beta1-swift51-fat works, I'm not sure whether our app could be accepted in the App Store with a component built with a beta Xcode. So it's feasible for us to use the library from beta subspec for development, but we would prefer to have a stable build for release.

ghost commented 4 years ago

Hey @stickmanlechu. Thank you for your answer. We don't think it should be an issue for you however we will make a new build ASAP and let you know when it's done.

Thanks!

stickmanlechu commented 4 years ago

Hi! After updating your library via CocoaPods everything works fine when debugging, but the app won't upload to App Store Connect with bitcode enabled:

error-screen

Steps to reproduce the behavior:

  1. Add pod 'KlarnaMobileSDK/xcode-11.3.1-fat' to Podfile
  2. Add import KlarnaMobileSDK in any of the Swift files
  3. Archive for App Store/Ad Hoc distribution

Device and version:

Additional context Compiler output regarding Klarna:

Output =-
    ld: warning: -sdk_version and -platform_version are not compatible, ignoring -sdk_version
    Undefined symbols for architecture arm64:
      "___llvm_profile_runtime", referenced from:
          __hidden#62_ in 001.o
          __hidden#62_ in 002.o
          __hidden#62_ in 005.o
          __hidden#62_ in 006.o
          __hidden#62_ in 007.o
          __hidden#62_ in 008.o
          __hidden#62_ in 010.o
          ...
    ld: symbol(s) not found for architecture arm64
    Exited with 1
    error: Failed to compile bundle: /var/folders/sf/vbvrw4bd3wl0n7zkc_bt15fh0000gn/T/KlarnaMobileSDKW1E7_h/KlarnaMobileSDK.arm64.xar

Stderr:
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:297:in 'run'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2703:in 'block in CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2642:in 'each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2642:in 'CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2902:in 'block in ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2864:in 'each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2864:in 'ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3811:in '<main>'";

Workaround Disable bitcode

AmyNgithub commented 4 years ago

I've experienced a similar (possibly the same?) issue after updating to 2.0.9 and have not been able to solve it. However I did not receive any error messages in xCode instead got the error via email from App Store Connect:

Dear Developer,

We identified one or more issues with a recent delivery for your app, "MyApp". Please correct the following issues, then upload again.

ITMS-90562: Invalid Bundle - The app submission can not be successfully recompiled from bitcode due to missing symbols during linking. You can try to reproduce and diagnose such issues locally by following the instructions from: https://developer.apple.com/library/archive/technotes/tn2432/_index.html

ITMS-90562: Invalid Bundle - Disallowed LLVM instrumentation. Do not submit apps with LLVM profiling instrumentation or coverage collection enabled. Turn off LLVM profiling or code coverage, rebuild your app and resubmit the app.

Best regards,

The App Store Team

Perhaps this added information can help in some way.

polar133 commented 4 years ago

Hi @AmyNgithub and @stickmanlechu We're looking into the issue and will update here once we know more, thanks for the info shared.

polar133 commented 4 years ago

Update: We found the problem and we are rolling a new version.

polar133 commented 4 years ago

@AmyNgithub @stickmanlechu please, try with the version 2.0.10 and let us know if that works.

AmyNgithub commented 4 years ago

@AmyNgithub @stickmanlechu please, try with the version 2.0.10 and let us know if that works.

@polar133 Version 2.0.10 seems to have solved the issue for me at least! I'm no longer receiving an error message from App Store Connect when I upload a new version of my app.

stickmanlechu commented 4 years ago

@AmyNgithub @stickmanlechu please, try with the version 2.0.10 and let us know if that works.

@polar133 Version 2.0.10 seems to have solved the issue for me at least! I'm no longer receiving an error message from App Store Connect when I upload a new version of my app.

It also works for me. I think we can close the issue.

shepting commented 4 years ago

@polar133 Can you share what the root issue was? I think I'm seeing a similar issue with a different SDK, but I'd like to investigate further.

PeterStavny commented 4 years ago

Hi! We are trying integrate and publishing your framework with last version 2.0.13. We have similiar or the same problem mentioned above by @stickmanlechu with bitcode . We cannot create the AdHoc distibution with bitcode enabled:

Screenshot 2020-05-19 at 01 36 42

Steps to reproduce the behavior:

  1. Add pod 'KlarnaMobileSDK/xcode-11.3-fat' to Podfile
  2. Add import KlarnaMobileSDK in any of the objective-c files
  3. Archive for Ad Hoc distribution

Device and version:

Workaround

polar133 commented 4 years ago

Hi @PeterStavny, can you try with the prev. version, please ? 2.0.12. It's the same as 2.0.13 regards features and implementation. Please, try and let us know if that works.

polar133 commented 4 years ago

Hi @shepting, it's a bit tricky this error because it could be for different reasons. In our case is related to our test source code still being referenced while building the framework for release. What we do to solve it, was to "disable" the tests code and coverage before building.

PeterStavny commented 4 years ago

Hi polar133! I have been checking 2.0.12. I was able to create a archive with bitcode without any error message.
But the uploaded application crash immmediatly after start. I checked it too on a real device in the Dev mode with the same result. Application crashed with the result:

dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /private/var/containers/Bundle/Application/3CFF5556-B03E-4FF0-B740-D9868CE3E09B/xxx.app/Frameworks/KlarnaMobileSDK.framework/KlarnaMobileSDK Reason: image not found

polar133 commented 4 years ago

@PeterStavny thanks for your feedback. Can you please follow these steps:

Note: If you encounter the build failure error Library not loaded: @rpath/libswiftCore.dylib, then you might need to create a Swift Bridging Header. to do so, please follow the steps below:

PeterStavny commented 4 years ago

Hi @polar133, I followed the recommended steps but it doesn't help. The result is still the same:

dyld: Library not loaded: @rpath/libswiftDispatch.dylib Referenced from: /private/var/containers/Bundle/Application/CD6EDDD9-A2AD-40DB-BD46-457177525F2F/xxx.app/Frameworks/KlarnaMobileSDK.framework/KlarnaMobileSDK Reason: image not found

PeterStavny commented 4 years ago

Hi @polar133,

Maybe it can help you. I tried to compare the application settings and pods with your demo application Fashion Store. I achieved the same result there as in my obj-c project for versions 2.0.10 to 2.0.13.

PeterStavny commented 4 years ago

Hi @polar133,

How I mensioned above I tried to compare the application settings and pods. When I have been looking on Build Settings -> Search Paths -> Framework Search Paths, Klarna was wrong:

"${PODS_ROOT}/KlarnaMobileSDK/ios/xcode-11.3-fat"

should be by Pods structure:

"${PODS_ROOT}/KlarnaMobileSDK/xcode-11.3-fat"

Header Search Paths was empty. I put here path for Klarna too:

"${PODS_CONFIGURATION_BUILD_DIR}/KlarnaMobileSDK/xcode-11.3-fat/KlarnaMobileSDK.framework/Headers"

Than I have been able to run application on a mobile device (I tried version 2.0.10 and last 2.0.14) without error.

Wrong pods/podspec configuration?

polar133 commented 4 years ago

Hi @PeterStavny thanks for the information provided. We will give a look at it and will reply back if we found the issue but good point about the configuration.

PeterStavny commented 4 years ago

Hi @polar133,

Your pods/podspec configuration is right. Problem was with Settings -> Search Paths -> Framework Search Paths.

I have been integrating the Klarna to older project. I overwrited this setting for other frameworks long time ago. And here is problem. When settings is overwited xcode use this settings and ignore pods configurations. I removed custom settings and it works as it is expected.

The 2.0.14 version works fine with bitcode support too. Thanks for help.

polar133 commented 4 years ago

Hi @PeterStavny nice to know that is working! thanks for the info provided during the process of implementing it.

nrudnyk commented 3 years ago

Hello @polar133, could you please share what was the fix? We having similar issues here in our framework, so I'm wondering if that's something quick and easy fixable. Any insights will be greatly appreciated. Thanks in advance.

polar133 commented 3 years ago

Hi @nrudnyk , Sure, i will try to share what we found. There are many reasons why this happens but the main problem is that the framework is not built with the Swift Standard Libraries. Those libraries should be linked in the build process of the host app by reference. In old versions of iOS / xcode , the build option to embed swift libraries (Always Embed Swift Standard Libraries) should be enabled, also, create a bridge file to support swift in case that the host app is objc.

The main problem, at least what i did found, is that in our SDK we use os framework for logging, and in xcode 11.3 should be imported in the host app also by just adding "import os" in any file, that way the host will have the os framework available so the SDK can link it.

Hope that helps.

nrudnyk commented 3 years ago

Hello @polar133, thanks for getting back to me. I'm reading my original message and realise, that I should've been more specific.

Right of the bat, I've already tried using ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES, and it doesn't helped unfortunately, while the framework size increased drastically. It just shows IPA processing failed:

image

Getting back to the original issue and as per specifics, I'm facing issue similar to @stickmanlechu & @PeterStavny. While building framework for deployment using cli, and using that in target test app, it fails like follows (I'm testing using ad-hoc build):

image

with similar logs:

image

What is strange, is that if I reference framework directly as subproject, it works just fine during archiving for the distribution. Issues start happening while it's prebuilt either regular framework or inside XCFramework, outcome is the same. So I'm wondering if that's something missing in cli or some build setting...

We don't using anything special, system frameworks for OpenGL, Metal etc.... At the moment, don't have any ideas where to look to fix this nasty problem