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

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.

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.

'warning: directory not found for option' error on build

All of a sudden my app has started giving me an error when I try to build it. This is the error I'm getting:
ld: warning: directory not found for option '-L/Users/user/Documents/Developer/Alton-Towers-Times/build/Debug-iphoneos'
ld: file too small (length=0) file '/Users/user/Library/Developer/Xcode/DerivedData/Mouse_Times_Florida-eqhrhnbxmmkxtahdghmnvehbzbgt/Build/Intermediates/Mouse Times Florida.build/Debug-iphonesimulator/Mouse Times Florida WatchKit Extension.build/Objects-normal/x86_64/SecondInterfaceController.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Only thing I've really done since I last managed to get it to run was changing the bundle IDs and I also changed the app name. I've tried a few things including deleting the derived data, but nothing seems to have helped.
Anyone have any ideas?
I solved this warning removing the following setting: "$(SDKROOT)/Developer/Library/Frameworks"
This options is located in Settings -> Build Settings -> Search Paths -> Framework Search Paths
Setting location
My project continues compiling and working fine, after removing this option.
Veladan answer helped me to sort out that issue on an iOS8 project freshly migrated to iOS9.
This worked fine on the main target of my project, but the warning lasted on the unit tests target, so in the end I edited directly the project.pbxproj file and modified the entries :
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
to :
FRAMEWORK_SEARCH_PATHS = "";

Xcode5: Failed to register "/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MobileDevices.bundle

My library has some type converters. I'm registering some OSX and iOS type converters, like so:
When I compile for iOS, I'm getting some errors related to not being able to find UIKit. Here's how I compile for iOS:
xcodebuild -destination OS=${module.sdk.version},name=iPhone -workspace ${workspace} -scheme '${library.ios.scheme}'
The ${} tokens are patched in by my build system.
When building I get:
__build.library.ios.simulator:
[exec] Details: Failed to register "/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MobileDevices.bundle" with Launch Services, error code: -10811.
[exec] Function: __RegisterUTIsIfNeeded_block_invoke
[exec] Thread: <NSThread: 0x7faca140e5c0>{name = (null), num = 1}
[exec] Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can
How can I fix this?
This appears to be an compiler bug, and there's not much that can be done about it.
Here is oficial answer on JetBrains Tracker:
Anton Makeev 17 Sep 2013, 19:36
build error doesn't affect compilation results - it's just a log message from xcodebuild.
Simulator should work correctly after you run it at least once in Xcode 5.
and:
We will handle this output in AppCode (show it as a warning, not a n error) but we recommend filing the error to Apple as the message suggests - unfortunately we can't fix it (only hide)
and:
Build error won't go away until we implement 'hide-it-fix' or until Apple fixes it. It is harmless, though and doesn't affect build result.

Duplicate symbol error when linking AdMob SDK in RubyMotion

My RubyMotion project builds fine, but fails at the linking stage, specifically when linking against GoogleAdMobAds, with a "duplicate symbol" error:
Compile ./app/controllers/blahblah_view_controller.rb
# compiling here, everything is awesome, until...
Create ./build/iPhoneOS-6.1-Development/App.app
Link ./build/iPhoneOS-6.1-Development/App.app/APP
duplicate symbol _GAD_MD5 in:
/Users/edd/Projects/ProjectName/vendor/GoogleAdMobAdsSDK/libGoogleAdMobAds.a(md5.o)
/Users/edd/Projects/ProjectName/vendor/GoogleAdMobAdsSDK/libGoogleAdMobAds.a(gad_md5.o)
ld: 1 duplicate symbol for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!
Command failed with status (1): [/Applications/Xcode.app/Contents/Developer...]
/Library/RubyMotion/lib/motion/project/builder.rb:393:in `build'
/Library/RubyMotion/lib/motion/project/app.rb:72:in `build'
/Library/RubyMotion/lib/motion/project.rb:56:in `block (2 levels) in <top (required)>'
Tasks: TOP => build:device
(See full trace by running task with --trace)
It's worth noting this occurs only when building for device. It works fine running in the simulator. Relevant Rakefile line:
app.vendor_project('vendor/GoogleAdMobAdsSDK', :static)
This problem also occurs when including the SDK via CocoaPods.
Any suggestions?
After perusing support forums for Google's AdMob, I found this thread basically saying issues have been observed when linking against the AdMob SDK when passing the -force_load flag to ld. Nobody goes into any more detail than that, but whatever.
Browsing the source, I also found an undocumented config option for RubyMotion's vendor_project that can make its invocation of ld use simply -ObjC instead of -force_load for your vendored code, and apparently that's what was needed to make this compile for me:
app.vendor_project('vendor/GoogleAdMobAdsSDK', :static, force_load: false)
Voila. I unfortunately can't explain why this is only happening when building for a device (probably something to do with -force_load combining with arch flags somewhere deep in RubyMotion), so if anyone can offer any wisdom, please leave a comment here.
If you really need to use -force_load (too much conflicts on the project with -ObjC for example) you can do the following.
Get a hexa editor (0xED for example)
Open the static lib with it
Go to the last line
Change the name of the constant to something else
save
done!

fail to build Opencv in windows using code:block

Following this link. I am stuck in the last two steps during setting up my workstation.
As a compiler I use Code:Block MinGW; I have already generated the compiled opencv files, now I need to build the sln file in Windows. I use Code Block to build this OpenCV Project File in the path D:\OpenCV\Build\Opencv, where I put the generated bin file after using Cmake.
During the building, it stopped at 40%, saying;
Linking CXX executable ....\bin\opencv_perf_core.exe
c:/codeblock/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe:
warning: auto-importing has been activated without
--enable-auto-import specified on the command line. This should work unless it involves constant data structures referencing symbols from
auto-imported DLLs. Cannot export _ZN12_GLOBAL__N_13ROp3allEv: symbol
not found Cannot export _ZN12_GLOBAL__N_17CmpType3allEv: symbol not
found collect2: ld returned 1 exit status mingw32-make.exe[2]: *
[bin/opencv_perf_core.exe] Error 1 mingw32-make.exe1: *
[modules/core/CMakeFiles/opencv_perf_core.dir/all] Error 2
mingw32-make.exe: * [all] Error 2 Info: resolving vtable for
cv::_OutputArray by linking to imp_ZTVN2cv12_OutputArrayE
(auto-import) Info: resolving vtable for cv::_InputArray by linking to
imp_ZTVN2cv11_InputArrayE (auto-import) Info: resolving vtable for cv::Exception by linking to imp_ZTVN2cv9ExceptionE (auto-import)
Creating library file: ....\bin\libopencv_perf_core.dll.a Process
terminated with status 2 (14 minutes, 29 seconds) 0 errors, 3 warnings
How can I solve this problem?
Unfortunately, there's not much you can do, according to http://code.opencv.org/issues/2523.
You will have to use a recent version of MinGW. It builds fine using the latest MinGW shipping with GCC 4.7.2.
This issue seems to have been introduced in OpenCV 2.4.3 as it is said version 2.4.2 builds fine.

Resources