xcodebuild -create-xcframework - BCSymbolMaps missing - on M1 Xcode 14.0 - ios

I use the same bash script for building the XCFramework for at least 2 years and everything worked successfully until the moment I switched my Mac to M1 and my Xcode is 14.0.
The script is pretty standard (see below).
On MacPro M1, Xcode 14.0 I get the following error (the same script works just fine on Xcode 13.1).
error: the path does not point to a valid debug symbols file: /Users/*******/build/Release-iphoneos.xcarchive/BCSymbolMaps/*
Indeed when I look at build/Release-iphoneos.xcarchive folder - the BCSymbolMaps is not there. I verified that the Xcode setting "debug information format" is dwarf with dsym file.
Can someone please help me understand what is this error? and why it started happening on M1, Xcode 14.0 ?
Thank you
See my bash build script below.
# Build the framework for device and for simulator (using
# all needed architectures).
xcodebuild archive -scheme "${TARGET_NAME}" -destination="iOS" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES -archivePath "${SRCROOT}/build/Release-iphonesimulator"
xcodebuild archive -scheme "${TARGET_NAME}" -destination="iOS" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES -archivePath "${SRCROOT}/build/Release-iphoneos"
ls -l "${SRCROOT}/build/"
# https://developer.apple.com/forums/thread/655768
# First, get all the UUID filepaths for BCSymbolMaps, because these are randomly generated and need to be individually added as the `-debug-symbols` parameter. The dSYM path is always the same so that one is manually added
echo "XCFramework: Generating IPHONE BCSymbolMap paths..."
IPHONE_BCSYMBOLMAP_PATHS=(${SRCROOT}/build/Release-iphoneos.xcarchive/BCSymbolMaps/*)
IPHONE_BCSYMBOLMAP_COMMANDS=""
for path in "${IPHONE_BCSYMBOLMAP_PATHS[#]}"; do
IPHONE_BCSYMBOLMAP_COMMANDS="$IPHONE_BCSYMBOLMAP_COMMANDS -debug-symbols $path "
echo $IPHONE_BCSYMBOLMAP_COMMANDS
done
echo "XCFramework: Generating IPHONE BCSymbolMap paths... --> Done"
# XCFramework with debug symbols - see https://pspdfkit.com/blog/2021/advances-in-xcframeworks/#built-in-support-for-bcsymbolmaps-and-dsyms
xcodebuild -create-xcframework -allow-internal-distribution \
-framework "${SRCROOT}/build/Release-iphoneos.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \
-debug-symbols "${SRCROOT}/build/Release-iphoneos.xcarchive/dSYMs/${FRAMEWORK_NAME}.framework.dSYM" \
$IPHONE_BCSYMBOLMAP_COMMANDS \
-framework "${SRCROOT}/build/Release-iphonesimulator.xcarchive/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework" \
-debug-symbols "${SRCROOT}/build/Release-iphonesimulator.xcarchive/dSYMs/${FRAMEWORK_NAME}.framework.dSYM" \
-output "${SF_RELEASE_DIR}/${FRAMEWORK_NAME}.xcframework"

bit code is not supported by xcode14 so bcsymbolmaps are no more relevant for xcode14

Related

How to load framework at runtime in Xcode?

I have a third party framework customx.framework (iOS) customx.framework (Simulator).
To run project on simulator customx.framework (Simulator) to be imported & for device
customx.framework (iOS) to be imported
simultaneously importing is not supported by xcode
At present i am manually importing framework, so i am looking for runtime scrip changes or combined (iOS+Simulator) framework to import in xcode project.
For that
I have tried lipo & libtool but seems didn't worked.
I used validate workspace but it fails when importing modules.
tried links -
iOS merge several framework into one
Building for iOS Simulator, but the linked framework '****.framework' was built for iOS
simultaneously importing is not supported by Xcode
Supported. It is named XCFramework.
So assuming each variant of frameworks have been built correctly (pay attention that BUILD_LIBRARY_FOR_DISTRIBUTION=YES, just in case - Xcode set it to YES automatically), join them in terminal or Xcode script phase with next command:
$ xcodebuild -create-xcframework
-framework "/full_path_to_iOS_variant/customx.framework"
-framework "/full_path_to_Simulator_variant/customx.framework"
-output "/full_path_to_result/customx.xcframework"
and then add it once in target dependency
and that's it.
You can archive for iOS device and iOS simulator and merge them to one xcframework. This is my current project xcodebuild command for it.
- Archive for iOS devices
xcodebuild archive \
-scheme Framework-scheme \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/native/Framework-Name.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
- Archive for iOS simulator
xcodebuild archive \
-scheme Framework-scheme \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/native/Framework-Name.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
- build framework from archives
xcodebuild -create-xcframework \
-framework './build/native/AdTrue-Native.framework-iphoneos.xcarchive/Products/Library/Frameworks/Framework-Name.framework' \
-framework './build/native/AdTrue-Native.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/Framework-Name.framework' \
-output './build/native/Framework-Name.xcframework'

xcodebuild archive failure: picking the wrong SDK?

I'm using fastlane to release an app. The simplified version of xcodebuild command to build the app is this:
xcodebuild -workspace App.xcworkspace -scheme App
-configuration Release -sdk iphoneos13.6
-destination 'generic/platform=iOS' clean archive
This fails giving (adding a sample):
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
^
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/symbolize.cc:55:
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/utilities.h:73:
In file included from /Users/sudeepkumar/Zendrive/mobile-apps/ios/copilot/Pods/glog/src/base/mutex.h:141:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/pthread.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types.h:33:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
^
I see that it's picking the MacOSX.sdk, I would expect it to pick iPhoneOS sdk present in Xcode directory. Is this the reason for failure? Or something else?
xcrun output:
» xcrun --show-sdk-platform-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
» xcrun --sdk iphoneos --show-sdk-platform-path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
Xcode is using the SDK in /Library/CommandLineTools. Instead, it should be using those inside Xcode app. Run
xcode-select -r
or
xcode-select -s "/Applications/Xcode.app/Contents/Developer"
Verify by
xcode-select -p
Some of them may need sudo.
xcodebuild -workspace App.xcworkspace -scheme App
-configuration Release -sdk iphoneos
-destination 'generic/platform=iOS' clean archive
In the xcodebuild man page
-sdk [<sdkfullpath> | <sdkname>]
Build an Xcode project or workspace against the specified SDK,
using build tools appropriate for that SDK. The argument may be an
absolute path to an SDK, or the canonical name of an SDK.
Use xcrun --sdk iphoneos --show-sdk-path to check the SDK path.
Check the SDK you have in your Mac. In my Mac, there are iPhoneOS.sdk and iPhoneOS13.7.sdk
iPhoneOS13.7.sdk is a symbolic link and its origin is iPhoneOS.sdk .
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.7.sdk
Besides,
you can also use xcodebuild -showsdks to see all the sdks
Different parameter for different devices
iOS: -sdk iphoneos
Simulator: -sdk iphonesimulator
watchOS: -sdk watchos
macOS: -sdk macosx

Error invalid architecture 'arm' when app from command line + iOS

I want to build an iOS app from command line with iOS simulator.
The build settings are:
1. Architectures - armv7
2. Base SDK - Latest IOS(6.1)
3. Build Active Architecture only - yes
4. Valid architectures - armv7 (also tried adding i386)
5. IOS deployment target - IOS 4.3
I am executing the following command:
xcodebuild -target splistapp2 -sdk iphonesimulator6.1 -configuration Release (also tried with -arch "i836")
But this command gives following error:
invalid architecture 'arm' for deployment target '-mios-simulator-version-min=4.2'
What could be the problem?
In case anyone running into the same annoying problem again, I will share my script here: Remember to run this command under the directory that has the xcodeproj file.
xcodebuild \
-project "full-path-to-your-xcodeproj-file" \
-target YOUR_TARGET \
-sdk iphonesimulator6.1 \
-arch i386 \
-configuration Debug \
VALID_ARCHS="armv6 armv7 i386" \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY="1" \
clean install
I modified the TARGETED_DEVICE_FAMILY because I only build for iPhone. If you want to build for both iPhone and iPad, delete this line or replace with TARGETED_DEVICE_FAMILY="1, 2".
The device uses ARM; while the simulator uses i386. Pick one or the other:
iphonesimulator6.1 and arch i386
iphoneos and arch armv7 (or armv7s)
Implement using arch1386 architecture.
xcodebuild -project splistapp2 -target TEST_TARGET -sdk iphonesimulator -configuration "Debug" -arch i386

Xcodebuild's .app crashes immediately? But Xcode's .app runs successfully

I'm using xcodebuild to build and install my app on the simulator (by copying the .app to ~/Library/Application Support/iPhone Simulator/6.1/Applications/UUID/) from the command line. I use:
xcodebuild -target MyApp
-configuration Debug
CPU_ARCHITECTURE=iphonesimulator6.1
install DSTROOT=Products
The .app is produced in /project_root/Products/Applications/MyApp.app However, every time I run the .app on my simulator, it crashes immediately.
I compared the .app that is created from Xcode's Run to xcodebuild's output from above. The two MyApp.apps are pretty much identical, but the MyApp binary inside of MyApp.app differ (the Xcode one is almost twice the memory footprint). I even tried copying the binary from Xcode's MyApp.app to xcodebuild's, and that worked too.
Any ideas why xcodebuild's .app is crashing?
Though there was no explicit "answer" to my question that I can mark as correct, here's my solution just in case anybody else has the same problem. Props to Richard for pointing me in the right direction. I played around with different settings for VALID_ARCHS and set it to "i386" (the simulator's architecture). Additionally, the syntax was wrong for CPU_ARCHITECTURE. xcodebuild uses the -sdk option instead. The following worked for me:
xcodebuild -target MyApp
-configuration Debug
-sdk iphonesimulator6.1
VALID_ARCHS="i386"
install DSTROOT=Products
This is my script that makes .app for simulator :
(Replace "MyApp" with your app name)
XCODE_WORKSPACE=/Users/MacBook/iOS/MyApp.xcworkspace
xcrun xcodebuild \
-scheme MyApp \
-workspace $XCODE_WORKSPACE \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 8,OS=11.2' \
-derivedDataPath \
build

xcodebuild test command for using with jenkins doesn´t work

I am having one problem that is killing me. Here it is: I have and app project in xCode that goes perfect when I tried to do everything in xCode UI. Which that I mean build, run, test or whatever in all the different targets that I have (3), 2 of the App and one for the tests.
THe problem comes when I tried to install a continous integration to my system in Jenkins. I need to execute some commands in shell for it. Command like this one:
xcodebuild -project MYPROJECT -sdk iphonesimulator -scheme TESTS_SCHEME TEST_AFTER_BUILD=YES
I also have tried with this other one that in the end it does the same:
xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug"
Then is when the problems cames out, the terminal says the following:
....PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.d
clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=4.3'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
** BUILD FAILED **
The following build commands failed:
ProcessPCH /Users/nicoyuste/Library/Developer/Xcode/DerivedData/MY_APP-bxpgsdbefuawmiexyikbtvsatlsf/Build/Intermediates/PrecompiledHeaders/MYLIBRARY-Prefix-hhjuztynfruquodlgqxroyfibfkh/MYLIBRARY-Prefix.pch.pth MYLIBRARY-Prefix.pch normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
I´ve been looking in the Internet (almost in here) but everything what I found with same problem didn´t work for me. The xCode version is 4.5 and if you do xcodebuild -version is what I get so that´s fine.
I also have tried changing headers files and everything what I have found around but nothing fixes my problem...
any suggestions...
If you're using a custom build script, you can pass -arch i386 to xcodebuild
For instance:
xcodebuild -project MY_PROJECT -target TEST_TARGET -sdk iphonesimulator -configuration "Debug" -arch i386
(Scroll all the way to the right in the code sample above. The relevant flag is -arch i386)
Should force it to build against i386. However, you need to make sure i386 is in your VALID_ARCHS settings for the target.
In case anyone running into the same annoying problem again, I will share my script here:
Remember to run this command under the directory that has the xcodeproj file.
xcodebuild \
-project "full-path-to-your-xcodeproj-file" \
-target YOUR_TARGET \
-sdk iphonesimulator6.1 \
-arch i386 \
-configuration Debug \
VALID_ARCHS="armv6 armv7 i386" \
ONLY_ACTIVE_ARCH=NO \
TARGETED_DEVICE_FAMILY="1" \
clean install
I modified the TARGETED_DEVICE_FAMILY because I only build for iPhone. If you want to build for both iPhone and iPad, delete this line or replace with TARGETED_DEVICE_FAMILY="1, 2".
I am seeing people who is still wondering about this. I posted this question a long time ago. I stopped using xcodebuild and I am using xctool now, it works much better. This tool is developed by Facebook.
I think that the problem reside in that your are building for the simulator specifying arm as the architecture, try changing it to i386
I ran into a similar problem after upgrading to Xcode 4.5 on my build machine. In my case, I have a third-party library that can't be built for armv7s (yet) and so, I set the Architectures build setting to armv7. Worked fine for unit tests, simulator builds, and the like inside of Xcode. However, when I did the command-line build, it failed with the same message.
I changed my Architectures to armv7 i386 and now it seems to build fine at the command line for the simulator.
Despite the GUI indicating that Architectures of Standard (armv7,armv7s) includes just those two, I'm pretty sure there's an i386 hiding there when you build for the simulator.
In the end, that setting works fine now with Jenkins.
I tried below command:
xcodebuild -arch i386 -sdk iphonesimulator7.1
But failed with similar error as clang: error: invalid architecture 'arm' for deployment target '-mios-simulator-version-min=6.0'
Here is how I solved :
xcodebuild -arch i386 VALID_ARCHS="i386 armv7 armv7s" ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator7.1
U need to make u set VALID_ARCHS and ONLY_ACTIVE_ARCH correctly and it will work. You can make these settings on Xcode directly too.

Resources