Xcode 12.3 Mac Catalyst code signing fails (code object is not signed at all) - ios

When I try to submit my app to AppStore for Mac Catalyst I get code signing error below. I have no idea how to solve the problem, I have googled everything I found and couldn't find a solution.
Submitting iOS version works without any problems.
(Xcode 12.3 & Big Sur 11.1.)
Any ideas?
Archives/2020-12-16/Textures 16-12-2020, 14.06.xcarchive/Products/Applications/Textures.app/Contents/Frameworks/BBMetalImage.framework/Versions/A/BBMetalImage'>', hardenedRuntime='0'>'> to: /var/folders/r5/t3j64v0j6td4g8018lfnk0gw0000gn/T/XcodeDistPipeline.~~~FGW2X1/entitlements~~~so4QjB
2020-12-16 13:22:05 +0000 Running /usr/bin/codesign '-vvv' '--force' '--sign' '4B7469E3C743F234A6E463B68C9AC62674F2EFD8' '--entitlements' '/var/folders/r5/t3j64v0j6td4g8018lfnk0gw0000gn/T/XcodeDistPipeline.~~~FGW2X1/entitlements~~~so4QjB' '--preserve-metadata=identifier,flags,runtime' '/var/folders/r5/t3j64v0j6td4g8018lfnk0gw0000gn/T/XcodeDistPipeline.~~~FGW2X1/Root/Applications/Textures.app/Contents/Frameworks/BBMetalImage.framework/Versions/A'
2020-12-16 13:22:05 +0000 /var/folders/r5/t3j64v0j6td4g8018lfnk0gw0000gn/T/XcodeDistPipeline.~~~FGW2X1/Root/Applications/Textures.app/Contents/Frameworks/BBMetalImage.framework/Versions/A: replacing existing signature
2020-12-16 13:22:05 +0000 /var/folders/r5/t3j64v0j6td4g8018lfnk0gw0000gn/T/XcodeDistPipeline.~~~FGW2X1/Root/Applications/Textures.app/Contents/Frameworks/BBMetalImage.framework/Versions/A: code object is not signed at all
2020-12-16 13:22:05 +0000 /usr/bin/codesign exited with 1

Stripping the bitcode from the catalyst slices of the framework fixed the error.
So in this case:
xcrun bitcode_strip -r BBMetalImage -o BBMetalImage
inside the ios-arm64_x86_64-maccatalyst directory of the .xcframework that the project includes.
This q/a on the same topic helped: https://developer.apple.com/forums/thread/666269

Related

IPA Processing Failed: Could not resolve #executable_path

I am stuck with this error when exporting IPA.
I did refer similar questions and none of them worked for me.
I am migrating my project from carthage to SPM, most of the frameworks which I use support SPM and only two had XCFrameworks.
Have added XCFrameworks with Embed & Sign, and earlier I used to have the simulator architectures removal script, with XCFrameworks I have removed that from my build phase step now.
When looked in the standard log I could not spot any error when searched with "fail"
Is there anything in the standard log which would indicate an error which I should be looking for ?
EDIT: Before you close as Duplicate of How to fix "IPA processing failed" error in xcode 11?
Please check this is for Xcode 12 with SPM & XCFrameworks !
The only errors I can spot in the logs are below:
2021-02-10 09:37:47 +0000 Scanning IPA...
2021-02-10 09:37:50 +0000 warning: Failed to resolve rpath for **SDK: Could not resolve #executable_path for #executable_path/Frameworks from **SDK
2021-02-10 09:37:50 +0000 warning: Failed to resolve rpath for ***: Could not resolve #executable_path for #executable_path/Frameworks from ***
But when I compared with the logs from another project with similar set up, I can see the same set of "warnings" and I am able to generate IPA on the another project.

iOS/macOS app distribution failed while using framework after upgrading Xcode12 and macOS BigSur

We are unable to distribute our sample app which uses our framework as well as our users can't.
While archiving and distributing to AppStore, the app is rejected with the following message:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path. If your app contains bitcode, bitcode processing may have failed. Because of these errors, this build of your app will not be able to be submitted for review or placed on the App Store.
The framework contain the bitcode, or at least there's a BITCODE_GENERATION_MODE = bitcode build setting in our .xcconfig, which basically means, the Xcode will add -fembed-bitcode build flag to any clang invocation.
From here, we've started testing using Ad-Hoc builds, to speed up our trial and error attempts, which also fails while Rebuild from bitcode option is selected. Organiser shows the popup with the following contents:
ipatool failed with an exception: #<CmdSpec::NonZeroExitException: $ /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Applications/Xcode.app/Contents/Developer/usr/bin/bitcode-build-tool -v -t /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.2.sdk -o /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-out/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart --generate-dsym /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-out/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart.dSYM --strip-swift-symbols /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/ipatool20201130-52097-13rj9hy/thinned-in/arm64/Payload/iosTest.app/Frameworks/SciChart.framework/SciChart
Status: pid 52150 exit 1
Stdout:
SDK path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
Logs provided isn't very informative, here is the snippet from IDEDistributionPipeline.log
-= 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#25821_ in 0832.o
__hidden#25821_ in 0833.o
__hidden#25821_ in 0834.o
__hidden#25821_ in 0835.o
__hid
2020-11-30 16:19:17 +0000 den#25821_ in 0836.o
__hidden#25821_ in 0837.o
__hidden#25821_ in 0838.o
...
ld: symbol(s) not found for architecture arm64
Exited with 1z
Failed to compile bundle: /var/folders/vz/b0jj0dms4014y5htfv93svfc0000gn/T/SciChart6aun_sfs/SciChart.arm64.xar
Stderr:
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2808:in `block in CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `CompileOrStripBitcodeInBundle'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3016:in `block in ProcessIPA'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `each'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `ProcessIPA'
from /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3928:in `<main>'
2020-11-30 16:19:17 +0000 /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1
which after bunch of warnings shows the actual error at the end of file (I can't include full log, since it's too much of a raw text):
code = 1061;
description = "ipatool failed with an exception: #<CmdSpec::NonZeroExitException: ...
info = {
};
level = ERROR;
type = exception;
Not sure what to to do with this, I've tried different build settings options, nothing helped... Already contacted apple, but no feedback yet, and knowing them, we can wait far too long...
The strange part here, is if we include our .framework directly as a source code and then archive the app - everything works as expected. If we include it as XCFramework or just .framework, which is pre-built - it fails as described above.
I might miss something simple or obvious here, so please let me know if somebody have some insights on that matter.
Some system info:
macOS BigSur 11.0.1
XCode Version 12.2 (12B45b)
We've tried different combinations of macOS and Xcode, e.g.:
Catalina with Xcode 12
BigSur with Xcode 11
etc.
Any help is greatly appreciated.
Thanks.
Long story short, there were LLVM instrumentation included, which prevents AppStore processing. I've written a whole blog post about it here - https://blog.scichart.com/xcframework-xcode-12-and-bigsur-issues/
To sum up, here is a few required steps to make sure while creating XCFramework for distribution:
Using archive builds is a MUST, release build isn't enough
BUILD_LIBRARY_FOR_DISTRIBUTION must be set to YES
SKIP_INSTALL must be set to NO
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO to turn off GCC instrumentation and remove them from the binary
CLANG_ENABLE_CODE_COVERAGE = NO to turn off code coverage tools from the binary
Having all of the above helped to solve our preparing and distribution problem and hopefully save you some time if you happened to face same issues as we did.

xcodebuild hangs on Xcode 11 beta, succeeds on Xcode 10

As the name of this post implies, I'm facing build-system issues with the Xcode 11 Beta. I worked since June on an update to my app, but only just recently attemped to archive it for TestFlight. Upon doing so, I found an issue where the archive never succeeds, but it also never fails. Instead it indefinitely hangs, never throwing an error or any hints as to why it's not conntinuing.
I've been able to isolate this issue to Xcode 11, as the identical codebase archives without a hitch in Xcode 10 (latest version as of writing).
I've submitted a radar with number FB7172492.
While I wait for a response to my radar, does any one here have any tricks as how I could either a) Get it to archive, or b) Get it to tell me what its stuck on.
It's worth noting, the build hang only occurs for the Release builds, any Debug build builds and runs without a problem.
xcodebuild
When I run xcodebuild in the terminal, like Xcode it hangs, and its file logs look like this:
INFO [2019-09-02 16:39:07.57]: ▸ [35m2019-09-02 16:39:07.577 xcodebuild[20349:464120] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7fbfe8cbc1a0), Will’s iPhone, iPhone, 13.1 (17A5821e), 00008020-001131943A04002E> == Underlying device preparation errors ==[0m
INFO [2019-09-02 16:39:07.57]: ▸ [35m2019-09-02 16:39:07.577 xcodebuild[20349:464120] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7fbfe8cbc1a0), Will’s iPhone, iPhone, 13.1 (17A5821e), 00008020-001131943A04002E> -- Failed _shouldMakeReadyForDevelopment check even though device is not locked by passcode.[0m
INFO [2019-09-02 16:39:07.57]: ▸ [35mDomain: com.apple.platform.iphoneos[0m
INFO [2019-09-02 16:39:07.58]: ▸ [35mCode: 5[0m
INFO [2019-09-02 16:39:07.58]: ▸ [35mFailure Reason: allowsSecureServices: 1. isConnected: 0. Platform: <DVTPlatform:0x7fbfe8a3f120:'com.apple.platform.iphoneos':<DVTFilePath:0x7fbfe8a3ef90:'/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform'>>. DTDKDeviceIdentifierIsIDID: 0[0m
INFO [2019-09-02 16:39:07.58]: ▸ [35m--[0m
INFO [2019-09-02 16:39:07.58]: ▸ [35m2019-09-02 16:39:07.577 xcodebuild[20349:464120] [MT] iPhoneConnect: 📱<DVTiOSDevice (0x7fbfe8cbc1a0), Will’s iPhone, iPhone, 13.1 (17A5821e), 00008020-001131943A04002E> == END: Underlying device preparation errors ==[0m
It says can't connect to my device, but it really shouldn't be trying to do that, since I'm just building, not installing.
Any ideas?
This ended up being an issue with a framework called SwiftSoup, the library has been patched and archiving succeeds.

Xcode 10 Signing Error: Frameworks/libswiftsimd.dylib: code object is not signed at all

I've recently upgraded to Xcode 10.2.1 - clients have updated their devices to iOS 12.2 which caused features of mobile app to stop working (camera / qr scanner). So rebuilt my app in new Xcode (it's an ionic app). I can build and run in the simulator via Xcode but can't archive for distribution. Looks like a code signing error which I can't get around.
Have already tried re-assigning profiles, cleaning build, deleting derived data.
Log output
probing signature of /Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib
/usr/bin/codesign -r- --display /Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib
/Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib: code object is not signed at all
Codesigning /Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib
/usr/bin/codesign --force --sign E53B3573B6BABE35C4A71D789E5E5058D1895105 --verbose /Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib
/Users/sam/Library/Developer/Xcode/DerivedData/Bootcamp_Admin-ajntpyeonsdorvblemqwhyetkmpr/Build/Intermediates.noindex/ArchiveIntermediates/Bootcamp Admin/InstallationBuildProductsLocation/Applications/Bootcamp Admin.app/Frameworks/libswiftsimd.dylib: errSecInternalComponent
error: Failed with exit code 1
In Xcode Menu - File -> Project Settings
Change Build System - to Legacy Build System and try
Let me know if it works

Codesigning fails during IPA validation with nested frameworks

I am trying to archive an app and prepare it for distribution in the App Store.
During the validation of the archive (which can be triggered from XCode's Organizer) the following error pops up:
From what I can tell some of my frameworks which contain nested frameworks cannot be codesigned. If I remove all frameworks which contain nested frameworks then it starts working again.
As an example the following framework causes such an error:
Frameworks are build using Carthage
Here is the log output I am seeing:
2016-12-02 10:16:53 +0000 Processing step: IDEDistributionCodesignStep
2016-12-02 10:16:53 +0000 Applying entitlements delta for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'> from <IDEiCloudEntitlementsProcessor: 0x7fbc6e036e70>: {
}
2016-12-02 10:16:53 +0000 Combining entitlements for <DVTFilePath:0x7fbc525ceb00:'/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>
bundleIdentifier = com.hearst.ObjectMapper
profileEntitlements = {
}
storedEntitlements = {
}
extraEntitlements = {
}
2016-12-02 10:16:53 +0000 Entitlements for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'>: {
}
2016-12-02 10:16:53 +0000 Writing entitlements for <IDEDistributionItem: 0x7fbc6f6e2a00 'com.hearst.ObjectMapper' '<DVTFilePath:0x7fbc530bde70:'/Users/gruener/Library/Developer/Xcode/Archives/2016-12-02/TestSubmitApp 02-12-16 11.16.xcarchive/Products/Applications/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'>'> to: /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/entitlementsuaGdWl
2016-12-02 10:16:53 +0000 Running /usr/bin/codesign '-vvv' '--force' '--sign' 'A54D9A9C895E402713C0528523674342C777C825' '--preserve-metadata=identifier,resource-rules' '--entitlements' '/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/entitlementsuaGdWl' '/var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework'
2016-12-02 10:16:53 +0000 Warning: usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!
2016-12-02 10:16:53 +0000 /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework: replacing existing signature
2016-12-02 10:16:53 +0000 /var/folders/3r/_6fw2smn4vj099_d7j2jtt0cg18svh/T/XcodeDistPipeline.bXb/Root/Payload/TestSubmitApp.app/Frameworks/Dto.framework/Frameworks/ObjectMapper.framework: invalid resource directory (directory or signature have been modified)
2016-12-02 10:16:53 +0000 /usr/bin/codesign exited with 1
I also tried building the IPA file with Fastlane's GYM. In this it works, however when I try to submit the App I receive this error:
WARNING ITMS-90686: "The binary you uploaded was invalid. (1102)"
Googling the error code 1102 yielded no results;
I finally figured out what the problem was.
I ran lipo info /path/to/Dto.framework/Dto in a terminal and everything seemed fine - unnecessary architectures were correctly stripped away. But taking a closer look at the nested frameworks I realized that this was not the case for them.
Instead I found out that when working with Carthage you have to link all frameworks at app level and must not encapsulate them in your own frameworks.
So to solve this I removed the Copy files Phase (which copies all frameworks to the frameworks directory). Carthage is smart enough to recognize this and also checks out the nested dependencies and builds them for you. The only thing you have to do then, is to add it to your Link Libraries Build Phase in XCode.
Can you check what kind of architectures are in the Dto.framework and ObjectMapper.framework?
You can do this with
$ file /path/to/Dto.framework/Dto
It seems similar to the issue I had with some embedded frameworks built for device and simulator. Simulator archs are built with debug, and they cannot be submitted to the AppStore (archiving for ad-hoc worked well). If they contain simulator archs (x86_64, and i386), you can use the script described in this blog to strip simulator archs during release builds of application: https://gkbrown.org/2015/12/17/creating-a-universal-ios-framework-in-xcode-7/

Resources