MMKV icon indicating copy to clipboard operation
MMKV copied to clipboard

Can not generate IPA when adding 'MMKVWatchExtension' (ipatool failed with an exception)

Open canhth opened this issue 3 years ago • 13 comments

The language of MMKV

  • Objective-C, Swift

The version of MMKV

  • 1.2.10

The platform of MMKV

  • iOS & WatchOS

The installation of MMKV

  • Cocoapods 1.10.0

What's the issue?

  • I'm getting this error when trying to create IPA build for my application (iOS and WatchOS targets): ipatool failed with an exception: #<CmdSpec::NonZeroExitException: .... (Full log in Xcode Distribution Logs)
  • Everything working normally with MMKV for iOS, the error just appears when adding MMKVWatchExtension to the Watch Extension target.

What's the log of MMKV when that happened?

Screen Shot 2021-08-30 at 20 15 47 - XCode Distribution Logs: [xcdistributionlogs.zip](https://github.com/Tencent/MMKV/files/7077412/xcdistributionlogs.zip)

Note: I tried to uncheck Rebuild from Bitcode and it can generate the IPA file. But afraid it will be rejected by Apple, because Bitcode is the default for WatchOS.

This is my pod file:

target 'TestingWatch-Tarrget' do
  use_frameworks!
  pod 'MMKV', '1.2.10'
end

target 'Watch-Demo' do
  use_frameworks!
end

target 'Watch-Demo Extension' do
  use_frameworks!
  pod 'MMKVWatchExtension', '1.2.10'
end
  • Here are what I tried but still getting the error:
  • [x] BUILD_LIBRARY_FOR_DISTRIBUTION must be set to YES
  • [x] SKIP_INSTALL must be set to NO
  • [x] GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
  • [x] CLANG_ENABLE_CODE_COVERAGE = NO to turn off code coverage tools from the binary

canhth avatar Aug 30 '21 14:08 canhth

I guess the problem is similar with this: https://github.com/apple/swift-nio-ssl/pull/277/files We also have .S file in our MMKVCore. (openssl_aesv8-armx.S, openssl_aes-armv4.S)

canhth avatar Aug 31 '21 05:08 canhth

Got it.

lingol avatar Aug 31 '21 07:08 lingol

Hi @lingol ,

I've create a temporary fix in this PR: https://github.com/Tencent/MMKV/pull/752 And confirm that it fixes the Rebuild from Bitcode issue.

But my fix is to disable the MMKV_DISABLE_CRYPT for WatchOS which I'm not quite sure it's will causing any bug. So far, my project does not use de/encryption, so it should be okay for my Forked.

Could you please help me to take a look? Thanks a lot.

canhth avatar Aug 31 '21 08:08 canhth

I have tried to archive and export our MMKVDemo App, which contains a  Watch App target, to an IPA. And I have also successfully uploaded it to App Store Connect without facing such errors.

There are two things different from your situation.

  • The MMKVDemo App enables bitcode by default.
  • I use Xcode 12.5.1 which doesn't have the so-called Rebuild from bitcode but with Include bitcode for iOS content instead. This might be as well just a result of enabling bitcode by default. image

lingol avatar Sep 08 '21 15:09 lingol

  • I don't think there is a difference between using the default Bitcode enable when creating a new project and the old project.
    Bitcode is optional as Apple said, and it should be the same in the Distribution option.
  • I'm using Xcode 12.5 and MMKVDemo App in this repo. But the option Rebuild from Bitcode is still available, maybe I will try version 12.5.1 like yours. Screen Shot 2021-09-09 at 02 04 28 Screen Shot 2021-09-09 at 02 04 46

canhth avatar Sep 08 '21 19:09 canhth

What's your exact steps to reproduce this error? Can you describe it step by step?

lingol avatar Sep 09 '21 01:09 lingol

Here are the steps:

  1. Clone the MMKV repo.
  2. Open MMKVDemo project and select MMKVDemo target for iOS.
  3. Archive build.
  4. Archive completed --> Select Distribute App.
  5. Select Development in the popup Method of app Distribution. --> click Next
  6. The Rebuild from Bitcode option is enabled by default. --> click Next
  7. Automatically manage signing as a default --> click Next
  8. The error displayed.

I'm using Xcode 12.5. And you can check the full error logs here: Logs.zip

canhth avatar Sep 09 '21 04:09 canhth

Okay, now I can reproduce your error. May I ask why did you choose Development instead of App Store Connect in step 5?

lingol avatar Sep 09 '21 04:09 lingol

I mean if you want to upload to App Store, why don't you just choose it? It will have no problems about bitcode.

lingol avatar Sep 09 '21 04:09 lingol

Because my CI/CD supports: Develop for internal testing, and Release for submitting the build. And I believed all the companies nowadays doing that as well.

  • For develop: we need to generate the IPA with 'Ad-Hoc', which is failing right now. (Ad-hoc and Development are the same, it has the option "Rebuild from Bitcode".)
  • For Release: Yes, because the rebuild from Bitcode is not available with release mode, so it should be okay though. But I'm not sure if the build will be rejected when Apple processing the build in their side.

canhth avatar Sep 09 '21 06:09 canhth

Why would they reject the build? You should try.

lingol avatar Sep 10 '21 03:09 lingol

It should be no issue when Upload to AppStore. BUT this is blocking us to share the Development build with Testers. (fastlane ad-hoc will failed) We need to generate Ad-hoc build in almost every Pull Request. To let QA team verify the ticket.

TestFlight only is not a good option in my case.

canhth avatar Sep 10 '21 04:09 canhth

Did you solve the problem eventually? I've just learned that starting from Xcode 14, bitcode is no longer supported. So I'm not going to do anything about it in this library.

lingol avatar Jun 07 '22 02:06 lingol