How to create simulator xcarchive when x86_64 and arm64 archs are excluded.

I've managed to build this locally via xcode but when trying to create xcframeworks of this, I am unable to create a simulator archive to add to the xcframework.

Framework B has Excluded Architectures = [x86_64, arm64] for 'Any iOS Simulator SDK'

Framework A imports Framework B but has Exclude Source File Names = FrameworkB.framework, FrameworkB.xcframework] for Any iOS Simulator SDK'

So when using xcodebuild command

/usr/bin/xcodebuild clean archive \
  -scheme FrameworkB \
  -archivePath PATH/FrameworkB-iphoneos.xcarchive \
  -configuration Release \
  -sdk iphoneos \
  SKIP_INSTALL=NO \
  BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
  BUILD_DIR=PATH/build \
  DEVELOPMENT_TEAM=TEAMID \
  GCC_PREPROCESSOR_DEFINITIONS=""\
  SWIFT_ACTIVE_COMPILATION_CONDITIONS=""
   
/usr/bin/xcodebuild clean archive \
	-scheme FrameworkB \
	-archivePath PATH/FrameworkB-iphonesimulator.xcarchive \
  -configuration Release \
	-sdk iphonesimulator \
	-destination='generic/platform=iOS Simulator' \
	SKIP_INSTALL=NO \
	BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
  BUILD_DIR=PATH/build \
  DEVELOPMENT_TEAM=TEAMID \
  GCC_PREPROCESSOR_DEFINITIONS=""\
 	SWIFT_ACTIVE_COMPILATION_CONDITIONS=""

/usr/bin/xcodebuild -create-xcframework \
  -framework PATH/FrameworkB-iphoneos.xcarchive/Products/Library/Frameworks/FrameworkB.framework \
	-framework PATH/FrameworkB-iphonesimulator.xcarchive/Products/Library/Frameworks/FrameworkB.framework \
  -output PATH/FrameworkB.xcframework

In the clean archive step for iOS Simulator I get

warning: None of the architectures in ARCHS (arm64, x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, i386, x86_64) which is not in EXCLUDED_ARCHS (arm64, x86_64).

As I've excluded both them archs. This fails to produce a binary inside the xcarchive though. Which leads to

error: unable to read the file at 'PATH/FrameworkB-iphonesimulator.xcarchive/Products/Library/Frameworks/FrameworkB.framework/FrameworkB'

I would like to avoid all of this but this is the only way I've managed to get the project to build for arm64 simulator with the new M1 Macs.

Before FrameworkB built using x86_64 but contains libraries which don't support arm64. I have to exclude both archs though since Exclude Source File Names you can only specify Any iOS Simulator SDK rather than Only ARM64 iOS Simulator.

I've tried Excluding FrameworkB when importing the xcframework but I get While building for iOS Simulator, no library for this platform was found

Answered by DTS Engineer in 714080022

As I've excluded both them archs. This fails to produce a binary inside the xcarchive though

Right -- you excluded all of the architectures that would be in the binary, so there's nothing left. What lead you to needing to exclude architectures at all? That is nearly always wrong. Technote 3117 goes into depth on the details.

Accepted Answer

As I've excluded both them archs. This fails to produce a binary inside the xcarchive though

Right -- you excluded all of the architectures that would be in the binary, so there's nothing left. What lead you to needing to exclude architectures at all? That is nearly always wrong. Technote 3117 goes into depth on the details.

What lead you to needing to exclude architectures at all? 

The framework used libpcre and libpcre_arm for Simulator and Device with the other added to exclude for that output. With simulator now using both archs and no way exclude based on arch as well as simulator.

 Technote 3117 goes into depth on the details.

Thank you this is super useful. I've been on this for a week and not found this article! This morning I've managed to allow x86_64 for simulator (to get an xcarchive) but add !targetEnvironment(simulator) when importing the framework which seems to make everything happy when making xcframeworks.

I'll close this off as the problem has been solved.

How to create simulator xcarchive when x86_64 and arm64 archs are excluded.
 
 
Q