Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish a Mac Catalyst app to the App Store #938

Closed
davidbritch opened this issue Sep 30, 2022 · 46 comments · Fixed by #1362
Closed

Publish a Mac Catalyst app to the App Store #938

davidbritch opened this issue Sep 30, 2022 · 46 comments · Fixed by #1362
Assignees
Labels
doc-idea Indicates issues that are suggestions for new topics [org] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest. vsmac VSMac content

Comments

@davidbritch
Copy link
Contributor

davidbritch commented Sep 30, 2022

At the moment the publish a Mac app doc is CLI only, for unsigned apps.

The story for Mac Catalyst publishing is that it's not possible on Windows, but it is possible on a Mac. However, it's not currently possible as an end-to-end scenario in VSMac. The solution is:

  1. Create certs in your Apple Developer Account.
  2. Use the Apple developer portal to create the App ID and provisioning profile.
  3. Set entitlements, depending on your distribution channel.
  4. Edit your .csproj to add the required build properties (which are different depending on how you're distributing your app).
  5. Use the CLI to publish the app.

This approach requires an Apple Distribution certificate, and a Mac Installer certificate.

Create a doc that covers distribution to the App Store using this approach.

Note: this distribution channel is only an option for individual Apple accounts.


Associated WorkItem - 66534

@davidbritch davidbritch added the vsmac VSMac content label Sep 30, 2022
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Sep 30, 2022
@davidbritch davidbritch removed the ⌚ Not Triaged Not triaged label Sep 30, 2022
@davidbritch davidbritch added Pri1 High priority, do before Pri2 and Pri3 and removed Pri3 labels Feb 23, 2023
@davidbritch davidbritch self-assigned this Feb 23, 2023
@davidbritch davidbritch added the doc-idea Indicates issues that are suggestions for new topics [org] label Feb 23, 2023
@davidbritch davidbritch changed the title VSMac: Publish a Mac app VSMac: Publish a Mac Catalyst app Feb 28, 2023
@davidbritch davidbritch changed the title VSMac: Publish a Mac Catalyst app Publish a Mac Catalyst app Feb 28, 2023
@davidbritch davidbritch changed the title Publish a Mac Catalyst app Publish a Mac Catalyst app to the App Store Feb 28, 2023
@davidbritch davidbritch added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Feb 28, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Feb 28, 2023
@cdavidyoung
Copy link

@davidbritch, I have done the steps outlined here except that in step 5 I am using Transporter. My .pkg file uploads successfully to the AppStore.

However, I get an email that says I need to correct issues. Below is one and the others are basically the same. BTW, I am using the Publish/Publish to Folder in VSMac to create the .pkg. So far I have been unable to create and Archive for Publishing that will upload to the AppStore either in VS or XCode.

Could you give me a pointer as to what to try next?

ITMS-90238: Invalid Signature - The executable at path CacheAll.app/Contents/MonoBundle/libSystem.IO.Compression.Native.dylib has following signing error(s): valid on disk /Volumes/workspace/app_data/SWValidationService/mz_9428053241116182122dir/mz_11292165874503355173dir/com.CacheAll.pkg/Payload/CacheAll.app/Contents/MonoBundle/libSystem.IO.Compression.Native.dylib: satisfies its Designated Requirement test-requirement: code failed to satisfy specified code requirement(s) . Refer to the Code Signing and Application Sandboxing Guide at http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/AboutCS/AboutCS.html and Technical Note 2206 at https://developer.apple.com/library/mac/technotes/tn2206/_index.html for more information.

@davidbritch
Copy link
Contributor Author

Hi @cdavidyoung

I'd recommend trying again without using VSMac to do the publish. The whole reason the docs don't use VSMac is that, AFAIK, it hasn't been updated to publish MacCat apps. It's Mac publishing functionality is for Xamarin.Mac/.NET for Mac rather than MacCat.

So I'd recommend trying again using the CLI (make sure you start with a clean solution - delete your bin/obj folders). Then see if you get the same outcome. You may well do, but at least we'll know that it's not a problem caused by VSMac doing the publish.

@cdavidyoung
Copy link

Hi @davidbritch

Thanks for the suggestion. I am getting the same response email from the AppStore. Below is my CLI output.

charlesyoung@Mac-mini-M1-CDY jiffyLog2 % dotnet publish -f:net7.0-maccatalyst -c:Release
MSBuild version 17.5.0+6f08c67f3 for .NET
Determining projects to restore...
All projects are up-to-date for restore.
Detected signing identity:

Code Signing Key: "Apple Distribution: Charles Young (**********)" (ED3D7B75076148A331F7BAE7619953BE8DB5B0CF)
Provisioning Profile: "CacheAll CacheAll Mac App Store" (9967907e-e767-4d6b-a577-e5412e7120da)
Bundle Id: com.CacheAll
App Id: **********.com.CacheAll

Detected signing identity:

Code Signing Key: "Apple Distribution: Charles Young (**********)" (ED3D7B75076148A331F7BAE7619953BE8DB5B0CF)
Provisioning Profile: "CacheAll CacheAll Mac App Store" (9967907e-e767-4d6b-a577-e5412e7120da)
Bundle Id: com.CacheAll
App Id: **********.com.CacheAll

jiffyLog -> /Users/charlesyoung/Projects/jiffyLog2/bin/Release/net7.0-maccatalyst/maccatalyst-x64/CacheAll.dll
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Detected signing identity:

Code Signing Key: "Apple Distribution: Charles Young (**********)" (ED3D7B75076148A331F7BAE7619953BE8DB5B0CF)
Provisioning Profile: "CacheAll CacheAll Mac App Store" (9967907e-e767-4d6b-a577-e5412e7120da)
Bundle Id: com.CacheAll
App Id: **********.com.CacheAll

jiffyLog -> /Users/charlesyoung/Projects/jiffyLog2/bin/Release/net7.0-maccatalyst/maccatalyst-arm64/CacheAll.dll
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
Created the package: /Users/charlesyoung/Projects/jiffyLog2/bin/Release/net7.0-maccatalyst/publish/CacheAll-0.0.321.pkg

Workload updates are available. Run dotnet workload list for more information.
charlesyoung@Mac-mini-M1-CDY jiffyLog2 %

@davidbritch
Copy link
Contributor Author

@cdavidyoung

Have you tried running the published app locally? Run the .pkg, install the app and launch it. I'd be interested to know if it works.

@cdavidyoung
Copy link

@davidbritch, partial success! In looking back at your email I realize that I had forgotten to clean solution - delete bin/obj folders. I did that, increased the bundle number, did the publish command, and delivered it to the store with Transporter. Now the build is sitting in TestFlight Ready to Submit.

However, when I install it with TestFlight on my Mac it will not run and instead gives me a crash report log. I try to run the app directly from the release folder and it says it cannot be run. The installation of the .pkg gives the same result.

When I go back to the Debug version it runs fine in the debugger. However, when I build with the Release configuration the option to run without debugging does not start the app.

So it seems there is something wrong with the Release build that prevents it from running. I think that once we get it to run from VS the actual delivery to the AppStore should result in a successful deployment.

Do you think it would make a difference to build it from CLI as well as publish from CLI?

@davidbritch
Copy link
Contributor Author

@cdavidyoung dotnet publish incorporates does a full build so that shouldn't make a difference.

Which linking mode are you using? None, SdkOnly, or Full?

@cdavidyoung
Copy link

Image 3-28-23 at 6 54 AM

@davidbritch
Copy link
Contributor Author

That shows it for the debug configuration. What about the release config?

@cdavidyoung
Copy link

It is exactly the same for Release. Link Framework SDKs Only.

@davidbritch
Copy link
Contributor Author

So just confirming: you have <MtouchLink>SdkOnly</MtouchLink> in your .csproj?

@cdavidyoung
Copy link

No. I assumed this is the default because there is no such line in the .csproj file. If you want me to add it can you give me the context so I can put it in the right place?

@davidbritch
Copy link
Contributor Author

You should have something in your .csproj like:

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-maccatalyst|AnyCPU'">
  <MtouchLink>SdkOnly</MtouchLink>
  <EnableCodeSigning>True</EnableCodeSigning>
  <EnablePackageSigning>true</EnablePackageSigning>
  <CreatePackage>true</CreatePackage>
  <CodesignKey>Apple Distribution: John Smith (AY2GDE9QM7)</CodesignKey>
  <CodesignProvision>MyMauiApp</CodesignProvision>
  <CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
  <PackageSigningKey>3rd Party Mac Developer Installer: John Smith (AY2GDE9QM7)</PackageSigningKey>
</PropertyGroup>

@cdavidyoung
Copy link

cdavidyoung commented Mar 28, 2023

My line was <MtouchLink>Full</MtouchLink>

Now my Release configuration is

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>SdkOnly</MtouchLink>
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<EnableCodeSigning>True</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>true</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: Charles Young (**********)</CodesignKey>
		<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>

I did a clean Release build in VSMac and it still won't run when I double click on the app. I did not try to publish it because I assume it will crash in FlightTest as well.

@cdavidyoung
Copy link

cdavidyoung commented Mar 28, 2023 via email

@cdavidyoung
Copy link

cdavidyoung commented Mar 28, 2023 via email

@cdavidyoung
Copy link

@davidbritch , just to be clear, you can run the Release version of your app either from the local .pkg or after installing from FlightTest? Or have you yet to overcome this hurdle?

@davidbritch
Copy link
Contributor Author

I did a clean Release build in VSMac and it still won't run when I double click on the app. I did not try to publish it because I assume it will crash in FlightTest as well.

I completely forgot that you're doing an App Store publish. The issue is that you can't launch an executable that's code-signed with a distribution cert (Apple Distribution: ...). All you can do is upload it to the App Store/TestFlight. Then, Apple will re-sign it, and when you download it the app will be signed with a key that allows local execution. You'd need to use an Apple Development: ... cert to execute an app locally after code-signing.

@davidbritch
Copy link
Contributor Author

@davidbritch , just to be clear, you can run the Release version of your app either from the local .pkg or after installing from FlightTest? Or have you yet to overcome this hurdle?

Yes, I've uploaded an app to App Store Connect, pulled it down via TestFlight and been able to run it.

@cdavidyoung
Copy link

@davidbritch, I am really confused.

Do you want me to create a cert that is Apple Development that requires that I upload a Certificate Signing Request (CSR) file from my Mac? I would be able to run the resulting .pkg on my Mac? I would then upload it to the App Store/TestFlight, Apple would sign it, and then I could download from TestFlight and run it?

@davidbritch
Copy link
Contributor Author

@cdavidyoung No. You're signing the app correctly, using an Apple Distribution certificate, for Mac App Store deployment. The point is that once you sign the app with that certificate, you won't be able to run it locally. Instead, when you upload it to App Store Connect, Apple will re-sign it to enable local execution. So then when you download it from TestFlight you should be able to run it locally (provided there aren't other issues).

@cdavidyoung
Copy link

@davidbritch. Hmm, so you are using an Apple Distribution certificate and after uploading it to the Mac App Store you can download it from TestFlight and it runs? Mine doesn't but runs fine under debug config. So I am uncertain how to discover why it is crashing under release.

<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Debug'">
	<MtouchLink>none</MtouchLink>
	<EnableCodeSigning>false</EnableCodeSigning>
	<ProvisionType>Manual</ProvisionType>
	<CreatePackage>false</CreatePackage>
	<EnablePackageSigning>true</EnablePackageSigning>
	<CodesignKey>Apple Distribution: Charles Young (**********)</CodesignKey>
	<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
	<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
	<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
	<UseHardenedRuntime>false</UseHardenedRuntime>
</PropertyGroup>

@davidbritch
Copy link
Contributor Author

When you try to run your release build, that you've pulled down from Test Flight, do you get a dialog like this:

Screenshot 2023-03-29 at 16 58 45

If so, clicking the Report button should provide a stack trace that can yield clues.

@cdavidyoung
Copy link

@davidbritch, that is what I get. I can study the report but should I not get a crash under debug config if there was really something I could fix? I'll post the report if you like.

@cdavidyoung
Copy link

@davidbritch Here is the crashed thread. It is some sort of privacy violation. I can't image why this would only happen in the release config.

Thread 5 Crashed:: Dispatch queue: com.apple.root.default-qos
0 libsystem_kernel.dylib 0x19cc8a868 __pthread_kill + 8
1 libsystem_pthread.dylib 0x19ccc1cec pthread_kill + 288
2 libsystem_c.dylib 0x19cbfa2c8 abort + 180
3 libmonosgen-2.0.dylib 0x10a4301e8 sigabrt_signal_handler.cold.1 + 48
4 libmonosgen-2.0.dylib 0x10a251fa8 sigabrt_signal_handler + 168
5 libsystem_platform.dylib 0x19ccf02a4 _sigtramp + 56
6 libsystem_kernel.dylib 0x19ccb3e44 abort_with_payload_wrapper_internal + 104
7 libsystem_kernel.dylib 0x19ccb3e78 abort_with_payload + 16
8 TCC 0x1a19ad830 TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION + 172
9 TCC 0x1a19bb954 ___tcc_server_send_request_authorization_block_invoke_2 + 124
10 TCC 0x1a19ab5e8 __tccd_send_message_block_invoke + 632
11 libxpc.dylib 0x19ca3242c _xpc_connection_reply_callout + 124
12 libxpc.dylib 0x19ca3231c _xpc_connection_call_reply_async + 88
13 libdispatch.dylib 0x19cb3a584 _dispatch_client_callout3 + 20
14 libdispatch.dylib 0x19cb58710 _dispatch_mach_msg_async_reply_invoke + 344
15 libdispatch.dylib 0x19cb4cd08 _dispatch_kevent_worker_thread + 1280
16 libsystem_pthread.dylib 0x19ccbe138 _pthread_wqthread + 344
17 libsystem_pthread.dylib 0x19ccbce20 start_wqthread + 8

@cdavidyoung
Copy link

In looking at the app output when I run in debug mode I see something suspicious when thread #5 starts. I wonder if this is what could be causing the "privacy violation" from FlightTest.

Thread started: #3
Thread started: #4
Thread started: #5
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'MyTitleVisible' property not found on 'jiffyLog.ViewModels.RecordsViewModel', target property: 'Microsoft.Maui.Controls.Frame.IsVisible'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'Color [Empty]' cannot be converted to type 'Microsoft.Maui.Graphics.Color'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'MyTitleVisible' property not found on 'jiffyLog.ViewModels.RecordsViewModel', target property: 'Microsoft.Maui.Controls.Frame.IsVisible'
Microsoft.Maui.Controls.Xaml.Diagnostics.BindingDiagnostics: Warning: 'Color [Empty]' cannot be converted to type 'Microsoft.Maui.Graphics.Color'
Thread started: .NET Timer #6
Thread started: #7
Thread started: .NET ThreadPool Gate #8
Thread started: #9
Thread started: #10
Thread started: #11
Thread started: #12
Thread started: #13
Thread started: #14
Thread finished: #12
Thread finished: #11
Thread finished: #9
Thread finished: #7
Thread finished: #13

@davidbritch
Copy link
Contributor Author

Provided the app launches in debug mode, you don't need to worry about debug mode. Looking at the stack trace for release mode, we can see TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION. This often indicates a description missing from your Info.plist. Then these lines are also suspicious:

9 TCC 0x1a19bb954 ___tcc_server_send_request_authorization_block_invoke_2 + 124
10 TCC 0x1a19ab5e8 __tccd_send_message_block_invoke + 632

What's in your Entitlements.plist file?

@cdavidyoung
Copy link

cdavidyoung commented Mar 29, 2023

@davidbritch Here is my Entitlements.plist. Also, I got rid of the runtime warnings in debug when thread #5 ran. Still, when I build in release and upload to FlightTest and install that on my Mac it now quietly quits. I don't even get the crash report.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
	<dict>
		<key>com.apple.security.app-sandbox</key>
		<true/>
		<key>com.apple.security.network.client</key>
		<true/>
	</dict>
</plist>

@cdavidyoung
Copy link

@davidbritch I have studied https://learn.microsoft.com/en-us/dotnet/maui/ios/entitlements?view=net-maui-7.0 but don't see any additional entitlement that I might need.

I am also wondering why I am not getting a crash report, or at least I can't find it.

Are you working with others that are having similar problems with the MacCatalyst deployment to the App Store?

@davidbritch
Copy link
Contributor Author

Your entitlements look good. I was just checking you had <key>com.apple.security.network.client</key>. So the next area to look at is your Info.plist file. Is your app doing anything like using maps, getting location, accessing the file system?

@davidbritch
Copy link
Contributor Author

Here's my thinking, so you know where I'm coming from. TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION usually occurs because the app is attempting to access privacy-sensitive data without a usage description for it in Info.plist. So depending on what you're app is actually doing (maps, location, file system, photos, camera etc.) you may well be missing an Info.plist entry. It's often the case that they aren't required for debug builds, but are for release builds.

@davidbritch
Copy link
Contributor Author

Something else to try is to comment out the PropertyGroup in your .csproj for your release config, to stop the code-signing etc. Then run a freshly built release build (having deleted bin/obj first) and see if you get anything that indicates a missing Info.plist key/description.

@cdavidyoung
Copy link

@davidbritch Here is my Info.plist file. It has the same list of access that my iOS app has that is currently live on the App Store.

Thanks for all your help, BTW! This stuff is so confusing.

As far as maps, location, file system, photos, camera, etc, yes I do them all in this app. I also record and play audio.

Looking at your last recommendation, after I do the release build do you mean you want me to try and publish it to the App Store?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>mailto</string>
  </array>
	<key>NSHumanReadableCopyright</key>
	<string>© 2023, ******.</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>

	<key>UIDeviceFamily</key>
	<array>
		<integer>1</integer>
		<integer>2</integer>
	</array>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>arm64</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>XSAppIconAssets</key>
	<string>Assets.xcassets/appicon.appiconset</string>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>The CacheAll app needs your location to create a GPS Catch.  It is only visible within the app.</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>The CacheAll app needs your location to create a GPS Catch.  It is only visible within the app.</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>The CacheAll app needs your location to create a GPS Catch.  It is only visible within the app.</string>
	<key>NSCameraUsageDescription</key>
	<string>The CacheAll app needs access to the camera to add a photo to a Catch.</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>The CacheAll app needs access to the microphone to add audio to a Catch.</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>The CacheAll app needs access to the photo gallery to add a photo to a Catch.</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>The CacheAll app needs access to the photo gallery to add a photo to a Catch.</string>
	<key>CFBundleIdentifier</key>
	<string>com.CacheAll</string>
	<key>CFBundleDisplayName</key>
	<string>CacheAll</string>
	<key>CFBundleShortVersionString</key>
	<string>0.0.31</string>

	<key>ITSAppUsesNonExemptEncryption</key>
	<false/>
	<key>LSApplicationCategoryType</key>
	<string>public.app-category.utilities</string>
</dict>
</plist>

@cdavidyoung
Copy link

@davidbritch So I commented out the PropertyGroup in my .csproj for my release config and I was able to Start Without Debugging. It would not allow me to Start Debugging. This is an improvement, but it runs perfectly normally with no hint of a a missing Info.plist key/description. I was able to take a photo and record audio without a problem. Of course, the GPS does not work on the Mac but the standard Apple map comes up fine and plots markers of photos that I have recorded with my iPhone.

@cdavidyoung
Copy link

@davidbritch Here is the change to the .csproj file with the release commented out. The debug config runs fine in the debugger.

	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Debug'">
		<MtouchLink>none</MtouchLink>
		<EnableCodeSigning>false</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>false</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignKey>Apple Distribution: Charles Young (83Q3M48Y8B)</CodesignKey>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
		<UseHardenedRuntime>false</UseHardenedRuntime>
	</PropertyGroup>
<!--	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>SdkOnly</MtouchLink>
		<RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers>
		<EnableCodeSigning>True</EnableCodeSigning>
		<ProvisionType>Manual</ProvisionType>
		<CreatePackage>true</CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: Charles Young (83Q3M48Y8B)</CodesignKey>
		<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
		<UseHardenedRuntime>true</UseHardenedRuntime>
	</PropertyGroup>-->

@cdavidyoung
Copy link

@davidbritch So I am still trying to figure out why the FlightTest app is quietly quitting without a crash report. I just want to point out that I think I initially addressed the TCC_CRASHING_DUE_TO_PRIVACY_VIOLATION when I fixed the thread #5 crash which was apparently caused by a xaml problem.

As you suggested, commenting out the release configuration allows the app to run fine locally. So it must have something to do with the provisioning, right? Apple is just not signing it in a way that allows it to run from FlightTest.

@davidbritch
Copy link
Contributor Author

The following entries aren't required in your release config:

  • maccatalyst-x64;maccatalyst-arm64 - this is the default for release configs, hence doesn't have to be explicitly enabled.
  • Manual - this is inferred from other settings.
  • true - this isn't required for Mac App Store apps.

I noticed you were using the hardened runtime last week, but didn't think it would be necessarily causing a problem. Then I read this:

"The Hardened Runtime is a collection of system-enforced restrictions that disable a set of functional capabilities, such as loading third-party frameworks, and prohibit access to restricted resources, such as the device’s built-in camera, to prevent certain classes of exploits from compromising the runtime integrity of your macOS app. If your app relies on something the Hardened Runtime restricts, you remove that specific protection by adding an entitlement to your app’s entitlements file. Xcode’s Hardened Runtime capability provides an easy way to manage those entitlements." - from https://developer.apple.com/documentation/xcode/configuring-the-hardened-runtime

So because you've enabled the hardened runtime, you've disabled the ability to access the camera. Your app wants that access which maybe what's causing your privacy violation.

@davidbritch
Copy link
Contributor Author

Also, in your Info.plist:

	<key>UIDeviceFamily</key>
	<array>
		<integer>1</integer>
		<integer>2</integer>
	</array>

Should just be:

	<key>UIDeviceFamily</key>
	<array>
		<integer>2</integer>
	</array>

See https://learn.microsoft.com/en-gb/dotnet/maui/mac-catalyst/deployment/publish-app-store?view=net-maui-7.0#specify-the-user-interface-idiom

In fact, the UIDeviceFamily definition in your Info.plist file prevented me from even uploading an app to the App Store with Transporter (at the same time, I don't have the hardened runtime enabled for my app).

@cdavidyoung
Copy link

@davidbritch Thanks for the new things to try. I can report a little bit of progress. At least now when it crashes it gives me a crash report! Of course I did a clean all and deleted obj/bin before doing the publish.

dotnet publish -f:net7.0-maccatalyst -c:Release

It looks like I am missing a library. Here is my config and a snippet from the crash report.


	<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>SdkOnly</MtouchLink>
		<RuntimeIdentifiers></RuntimeIdentifiers>
		<EnableCodeSigning>True</EnableCodeSigning>
		<ProvisionType></ProvisionType>
		<CreatePackage></CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: Charles Young (83Q3M48Y8B)</CodesignKey>
		<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
		<UseHardenedRuntime></UseHardenedRuntime>
	</PropertyGroup>

Crashed Thread: 0

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000

Termination Reason: Namespace DYLD, Code 1 Library missing
Library not loaded: @executable_path/../MonoBundle/libSystem.IO.Compression.Native.dylib
Referenced from: <98C66449-3327-3656-BD30-6FBF749806F7> /Users/USER/*/CacheAll.app/Contents/MacOS/CacheAll
Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@executable_path/../MonoBundle/libSystem.IO.Compression.Native.dylib' (no such file), '/usr/lib/libSystem.IO.Compression.Native.dylib' (no such file, not in dyld cache), (security policy does not allow @ path expansion)
(terminated at launch; ignore backtrace)

Thread 0 Crashed:
0 dyld 0x19d437190 __abort_with_payload + 8
1 dyld 0x19d441a00 abort_with_payload_wrapper_internal + 104
2 dyld 0x19d441a34 abort_with_payload + 16
3 dyld 0x19d3d00a4 dyld4::halt(char const*) + 328
4 dyld 0x19d3cd098 dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) + 4204
5 dyld 0x19d3cbdc4 start + 2404

@cdavidyoung
Copy link

@davidbritch xamarin/xamarin-macios#14686 covers this issue. There seems to be a solution but I am a little unsure how to implement it.

@cdavidyoung
Copy link

cdavidyoung commented Apr 3, 2023

@davidbritch I tried to implement their fix but I am still getting the same error. Perhaps I am not putting the 2 lines in the right place?

<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
		<MtouchLink>SdkOnly</MtouchLink>
        <_LibMonoLinkMode>Static</_LibMonoLinkMode>
        <_LibXamarinLinkMode>Static</_LibXamarinLinkMode>
        <RuntimeIdentifiers></RuntimeIdentifiers>
		<EnableCodeSigning>True</EnableCodeSigning>
		<ProvisionType></ProvisionType>
		<CreatePackage></CreatePackage>
		<EnablePackageSigning>true</EnablePackageSigning>
		<CodesignEntitlements>Platforms\MacCatalyst\Entitlements.plist</CodesignEntitlements>
		<CodesignKey>Apple Distribution: Charles Young (83Q3M48Y8B)</CodesignKey>
		<CodesignProvision>CacheAll CacheAll Mac App Store</CodesignProvision>
		<PackageSigningKey>3rd Party Mac Developer Installer: Charles Young (83Q3M48Y8B)</PackageSigningKey>
		<UseHardenedRuntime></UseHardenedRuntime>
	</PropertyGroup>

@davidbritch
Copy link
Contributor Author

You need to completely remove:

            <RuntimeIdentifiers></RuntimeIdentifiers>
	<ProvisionType></ProvisionType>
	<CreatePackage></CreatePackage>
	<UseHardenedRuntime></UseHardenedRuntime>

@cdavidyoung
Copy link

@davidbritch I tried removing those lines and I also tried using the config recommended in the link below but I am still getting the same "security policy does not allow @ path expansion" error.

https://learn.microsoft.com/en-gb/dotnet/maui/mac-catalyst/deployment/publish-app-store?view=net-maui-7.0#specify-the-user-interface-idiom

I think I am going to start over at the beginning of this doc and go through the whole process again. Perhaps I made a mistake the first time.

@cdavidyoung
Copy link

@davidbritch So I spent all day yesterday following the instructions in your doc but I am still getting the same error. There are some confusing parts to the doc where I may be making the wrong decisions. I'll describe them as a new issue on the doc page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-idea Indicates issues that are suggestions for new topics [org] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest. vsmac VSMac content
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants