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

iOS app crash at startup #688

Open
SaariTech opened this issue May 28, 2023 · 13 comments
Open

iOS app crash at startup #688

SaariTech opened this issue May 28, 2023 · 13 comments
Labels

Comments

@SaariTech
Copy link

Checklist

Environment

  • Unity Editor Version: 2022.2.19
  • Unity Editor Version in Cloud Build: 2022.X
  • Unity SDK Version: 16.0.0
  • xcode in Unity build cloud Version: 14.2.0 (Have tried 14.1.0 too)
  • Installation Platform & Verison: iOS version 15.2

Goals

I want to build the project with Facebook SDK using Unity Cloud Build.

Expected Results

The app project don't crash on startup in iOS device.

Actual Results

The project built successively, uploaded to TestFlight but the app with Facebook SDK keep crashing at startup.
I have removed Facebook SDK and tried again, it doesn't crash on startup, later I added latest Facebook SDK, it crashed again at startup.

Steps to Reproduce

  1. Add Facebook SDK v16.0 to your Unity project, add everything data as needed in Facebook Setting page.
  2. Upload the project to Unity Cloud Build using Unity Version Control
  3. Build the app, once built, download the .IPA file
  4. Upload the .IPA file to Apple App Store Connect using Transporter
  5. Download the app using TestFlight
  6. Start the app, this is where the app crash before Splash Screen

Code Samples & Details

For xcode 14.2 (experimental) in cloud build, no extra steps needed.

For xcode 14.1 in cloud build, I added this code (iOSBuild.cs) to make the build don't fail and to pass Apple Store Connect verifier:

#if UNITY_IOS && UNITY_EDITOR
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;

public class iOSBuild
{
	[PostProcessBuild]
	public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
	{
		// Performs any post build processes that we need done
		if (buildTarget == BuildTarget.iOS)
		{
			// xCode workspace modifications
			{
				string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
				PBXProject proj = new PBXProject();
				proj.ReadFromFile(projPath);
				string main = proj.GetUnityMainTargetGuid();
				string framework = proj.GetUnityFrameworkTargetGuid();

				proj.SetBuildProperty(main, "EMBEDDED_CONTENT_CONTAINS_SWIFT", "YES");
				proj.SetBuildProperty(main, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
                                //proj.SetBuildProperty(main, "SWIFT_VERSION", "5.0");

                                proj.SetBuildProperty(framework, "EMBEDDED_CONTENT_CONTAINS_SWIFT", "NO");
				proj.SetBuildProperty(framework, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
                                //proj.SetBuildProperty(framework, "SWIFT_VERSION", "5.0");
                
				//proj.AddBuildProperty(main, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
                                //proj.AddBuildProperty(framework, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");
                                proj.WriteToFile(projPath);
			}
		}
	}
}
#endif
@SaariTech SaariTech added the bug label May 28, 2023
@SaariTech
Copy link
Author

This is the crash log from iPhone simulator, seems like FBAEMKit wasn't included in the final product. Tested with SDK 16.0.1.

2023-06-03 13:34:40.519121+0200 My App[9209:106057] [general] Error loading /Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework (238): dlopen(/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit Referenced from: <0F7CEFEA-027B-3BA7-B1D3-E981DFD46333> /Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/UnityFramework Reason: tried: '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file) 2023-06-03 13:34:40.700404+0200 My App[9209:106057] [general] Error loading /Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework (238): dlopen(/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/FBAEMKit.framework/FBAEMKit Referenced from: <0F7CEFEA-027B-3BA7-B1D3-E981DFD46333> /Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/UnityFramework Reason: tried: '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file), '/usr/lib/swift/FBAEMKit.framework/FBAEMKit' (no such file, no dyld cache), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/Xcode/DerivedData/Unity-iPhone-ffvdbyfnpuaetdhbusuxcqfzwxdn/Build/Products/ReleaseForRunning-iphonesimulator/UnityFramework.framework/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Users/jonatan/Library/Developer/CoreSimulator/Devices/0050B98B-017D-4FF6-AC6A-B8B8318E95C3/data/Containers/Bundle/Application/DE855322-5A70-4469-B666-CB6AD5532E0B/ My App.app/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/FBAEMKit.framework/FBAEMKit' (no such file)

@HanzaRu
Copy link

HanzaRu commented Jun 17, 2023

Same issue on our side, it's exploding by not including the FBAEMKit as expected.

@eranroza
Copy link

Same issue here

@DaveMariner
Copy link

It's crashing in the same way for me, for local builds. Doesn't seem to matter which version of the SDK I use either.

@DaveMariner
Copy link

@SaariTech, @HanzaRu, @eranroza

FWIW - I think this might be a dupe/reoccurrence of this issue: #659

@vg-swift
Copy link

vg-swift commented Aug 2, 2023

@SaariTech, @HanzaRu, @eranroza

FWIW - I think this might be a dupe/reoccurrence of this issue: #659

The fix from that thread didn't work for me.
I think it also needs one of these, or all of them:

  • CocoaPods to 1.12.1
  • XCode 14.3.1

@vg-swift
Copy link

vg-swift commented Aug 2, 2023

Removing removing ":linkage => :static" fixed it in UCB at least for ad hoc profile.
You can do it in Unity as well:
image

@vg-swift
Copy link

vg-swift commented Aug 3, 2023

I tried multiple permutations of the fixes, and I can say that on Unity Build Automation the only thing needed is to disable Link frameworks statically. (Add use_frameworks! to Podfile is already enabled by default in Google External Dependency Manager)
This is also NOT necessary: addToAllTargets="true"
I use xcode 14.2.0 and Unity mentioned that Cocoapods are either 1.12.0 or 1.12.1 on their machines.

Can confirm that Cocoapods version matters, the build crashes on Cocoapods 1.11.x

@vg-swift
Copy link

vg-swift commented Aug 3, 2023

Thank you for coming to my Ted Talk, it works for release builds as well, they get uploaded to AppStore and no crashes. I also tested it on a Jenkins CI.
I spend 3-4 full working days testing this, would be nice if someone could confirm that these changes work for them too.

@dcosmin-97
Copy link

@vg-swift Thank you for your post! So you solve it by unchecking the Link frameworks statically ? I am trying to see if 16.0.2 will solve the issue by itself, but I don't think so!

@santiagomartinJC
Copy link

I could fix this by adding the addToAllTargets parameter in dependecies.xml
./Assets/FacebookSDK/Plugins/Editor/Dependencies.xml


    <iosPods>
        <iosPod name="FBSDKCoreKit_Basics" version="~> 15.1" **addToAllTargets="true"** />
        <iosPod name="FBSDKCoreKit" version="~> 15.1" **addToAllTargets="true"**/>
        <iosPod name="FBSDKLoginKit" version="~> 15.1" **addToAllTargets="true"**/>
        <iosPod name="FBSDKShareKit" version="~> 15.1" **addToAllTargets="true"**/>
        <iosPod name="FBSDKGamingServicesKit" version="~> 15.1" **addToAllTargets="true"**/>
    </iosPods>

#659 (comment)

@Spud6703
Copy link

My app crashes at launch after adding the Facebook 16.0.2 SDK with the same problem. When I unchecked "Link frameworks statically" I get errors building in XCode "DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead" for various SDKs such as AppLovin and Unity Ads mediation.

@femoreti
Copy link

femoreti commented May 9, 2024

Same error with 17.0.2 SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants