fermoya/cocoapods-catalyst-support

Building for My Mac using Xcode 12 Beta 3 and macOS 11 Beta

Closed this issue · 10 comments

It seems when building for the my Mac target in Xcode 12 that the ARCHS is arm64 x86_64 instead of just x86_64, this causes the copy resources script to fail.

In your script I changed the following:

  def self.macos
    OSPlatform.new :macos, 'macosx*', ['x86_64']
  end

to

  def self.macos
    OSPlatform.new :macos, 'macosx*', ['arm64 x86_64']
  end

This fixes the issue when using Xcode 12 but breaks Xcode 11.
I’m also hesitant that changing it here is the right approach.

Hi @Brett-Best,

If anything, it should be:

  def self.macos
    OSPlatform.new :macos, 'macosx*', ['arm64', 'x86_64']
  end

as it is an array. What’s the error exactly (both Xcode 11 and 12)? I assumed that pods would compile just fine as they do for iOS, that is, arm64 architecture.

I tried adding it as an array initially but that didn’t work.

The error is (in Xcode 12 if I don’t make the change and if I make the change in Xcode 11):

error: Resource "/Users/brettbest/Library/Developer/Xcode/DerivedData/Bowel_Prep-csirmtnlrczwlwbpugtqzkpfhhnp/Build/Intermediates.noindex/ArchiveIntermediates/Bowel Prep iOS - Development/BuildProductsPath/Release - Development-maccatalyst/AppCenter/AppCenterDistributeResources.bundle" not found. Run 'pod install' to update the copy resources script.

After changing it to my example the script looks like this:

if [[ "$CONFIGURATION" == "Release" ]]; then
	if [ "$ARCHS" != "arm64 x86_64" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Production" ]]; then
	if [ "$ARCHS" != "arm64 x86_64" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Staging" ]]; then
	if [ "$ARCHS" != "arm64 x86_64" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Development" ]]; then
	if [ "$ARCHS" != "arm64 x86_64" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi

The condition is wrong, there should be an OR operation there. This is what the array achieves but still it'd fail because arm64 is shared between iOS and macOS now. There might be another environment value $SDK that would be more suitable, but I’d have to check.

I’ll keep an eye on this, it shouldn’t be very difficult to fix.

Are you compiling with one of the new Silicones?

Compiling with a ‘normal’ machine using Xcode12b3.

if [[ "$CONFIGURATION" == "Release" ]]; then
	if [ "$ARCHS" != "x86_64" ] && [ "$ARCHS" != "arm64 x86_64" ]; then
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Production" ]]; then
	if [ "$ARCHS" != "x86_64" ] && [ "$ARCHS" != "arm64 x86_64" ]; then
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Staging" ]]; then
	if [ "$ARCHS" != "x86_64" ] && [ "$ARCHS" != "arm64 x86_64" ]; then
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release - Development" ]]; then
	if [ "$ARCHS" != "x86_64" ] && [ "$ARCHS" != "arm64 x86_64" ]; then
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi

The above seems to work for both Xcode 11 and 12.

  def self.macos
    OSPlatform.new :macos, 'macosx*', ['x86_64', 'arm64 x86_64']
  end

I had to manually change the || to && in the script after the pod installation

Hey @Brett-Best , I think you're not using the last version of the script, could it be possible? You should have something like this:

if [[ "$CONFIGURATION" == "Debug" ]]; then
	if [ test -f "\$${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi
if [[ "$CONFIGURATION" == "Release" ]]; then
	if [ "$ARCHS" != "x86_64" ]; then 
	  install_resource "${PODS_CONFIGURATION_BUILD_DIR}/AppCenter/AppCenterDistributeResources.bundle"
	fi
fi

For me it's compiling well in both Xcode 11 and Xcode 12. I've tried archiving too. My dummy Podfile defines:

def catalyst_unsupported_pods
  [
    'AppCenter/Distribute',
    'Firebase/Analytics'
  ]
end

@fermoya

Checked that I’m using the latest version of the script. Debug works fine and I do have the code like what you’ve posted for the debug config.

For some reason $ARCHS is arm64 x86_64 for me when I try to archive with a target of My Mac.

Are you running on macOS 11.0 beta?

nope, I'm running this on macOS 10.15.5. So if you add echo $ARCHS in your *resource.sh file, what does it print?

It prints arm64 x86_64, I wonder if you need to be on a higher OS for it to build for arm64. Do you have a target called: “Any Mac (Apple Silicon, Intel)”?

@Brett-Best . I was wondering why I couldn't build for arm64, maybe it's that and you need to update to the beta first...

Can you try something for me? I rather use the SDKROOT instead of $ARCHS and have a bunch of conditions there. I've updated the script, could you try and let me know if it works on macOS 11 and Xcode 12, please?

Just checked and can confirm it works 🎉 thanks!