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

Crash when use different plist file #327

Open
MattePozzy opened this issue Aug 2, 2024 · 0 comments
Open

Crash when use different plist file #327

MattePozzy opened this issue Aug 2, 2024 · 0 comments

Comments

@MattePozzy
Copy link

MattePozzy commented Aug 2, 2024

Hi,
I have the same app code that produce two different apps with different bundle id.
I have created tow plist file and put inside the folder Platform iOS.

I load the plist file based on the app package name, but when I try to pass the plist path at the CrossFirebase.Initialize function the app crashes with this error:

System.Exception: 'Could not initialize an instance of the type 'Firebase.Core.Options': the native 'initWithContentsOfFile:' method returned nil.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.'

this is the code used to load the plist file:

events.AddiOS(iOS => iOS.WillFinishLaunching((_, __) =>
{
	string plistName = "", plistPath = @"\Platforms\iOS\";
	switch (AppInfo.PackageName)
	{
		case "bundle.id.one":
			plistName = "ONE_GoogleService-Info.plist";
			break;
		case "bundle.id.two":
			plistName = "TWO_GoogleService-Info.plist";
			break;
	}

	plistPath = @$"{plistPath}{plistName}";

	Firebase.Core.Options opt = new(plistPath);
	CrossFirebase.Initialize("myName", opt);
	CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true);
	return false;
}));

inside the csproj file:

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
	<BundleResource Include="Platforms\iOS\PST_GoogleService-Info.plist" Link="PST_GoogleService-Info.plist" />
	<BundleResource Include="Platforms\iOS\SGAT_GoogleService-Info.plist" Link="SGAT_GoogleService-Info.plist" />
</ItemGroup>
@MattePozzy MattePozzy changed the title Crash on use different plist file Crash when use different plist file Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant