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

Undefined symbol: swiftCompatibility #450

Closed
5 tasks done
ghost opened this issue Jun 25, 2020 · 21 comments
Closed
5 tasks done

Undefined symbol: swiftCompatibility #450

ghost opened this issue Jun 25, 2020 · 21 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 25, 2020

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Unity Editor Version: 2018.4.23
  • Unity SDK Version: 7.21.0
  • Installation Platform & Verison: iOS

Goals

I want to be able to update Facebook SDK without constant problem solving.

Expected Results

XCode would cleanly build the client after updating the SDK.

Actual Results

XCode fails to build

Steps to Reproduce

Update from 7.20.0 -> 7.21.0 and build on XCode

Code Samples & Details

Showing Recent Messages
Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibilityDynamicReplacements
Undefined symbol: _swift_FORCE_LOAD$_swiftCompatibility50

@ghost ghost added the bug label Jun 25, 2020
@KylinChang
Copy link
Contributor

Current workaround is adding use_framework! to the Podfile in your exported XCode project

@arthuronoszko
Copy link

Current workaround is adding use_framework! to the Podfile in your exported XCode project

Thanks @KylinChang it worked for me!

@eladleb
Copy link

eladleb commented Jun 29, 2020

Thanks @KylinChang ,
It would be helpful if this is added to the release notes of the bugged version in the SDK download page.

@NumaNumaNuma
Copy link

NumaNumaNuma commented Jun 30, 2020

Wow thanks so much, you should definitely add something to the change log.
Also, it's use_frameworks! (plural)👍

@NumaNumaNuma
Copy link

NumaNumaNuma commented Jun 30, 2020

after adding use_frameworks! the project builds, but crashes on start with this error:
[13858:5861271] Error loading /var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework: dlopen(/var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework, 265): Library not loaded: @rpath/FBSDKCoreKit.framework/FBSDKCoreKit Referenced from: /private/var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework Reason: image not found

Adding it to the list of embedded frameworks didn't help.

Anything else I need to do?

@wagenheimer
Copy link

It's not working for me! I added "use_frameworks!" but the build still fails. Do I need something else?

@mgrogin
Copy link

mgrogin commented Jul 1, 2020

after adding use_frameworks! the project builds, but crashes on start with this error:
[13858:5861271] Error loading /var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework: dlopen(/var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework, 265): Library not loaded: @rpath/FBSDKCoreKit.framework/FBSDKCoreKit Referenced from: /private/var/containers/Bundle/Application/59B84CDD-B5F4-4BEB-A75B-44DC54DE13E3/myProject.app/Frameworks/UnityFramework.framework/UnityFramework Reason: image not found

Adding it to the list of embedded frameworks didn't help.

Anything else I need to do?

I get the same thing :/

@KylinChang can you share what your podfile looks like please?

@wagenheimer
Copy link

I was able to build it now, but it fails with the same error when running. Anybody was able to make it work?

@gtino
Copy link

gtino commented Jul 3, 2020

Same problem here with Unity 2019.4.1, Facebook SDK 7.21.1.

Using use_frameworks! will just use the dynamic libraries instead of the static ones. It compiles, of course, but then those frameworks must be embedded somehow. Still looking into this, but in any case I need Unity generated XCode workspace/project to already be setup or our CI system will fail...

Having to manually modify the podfile and then the project is something that we should not have to do for such an easy task as simply integrating the Facebook SDK...

@Khaled-Wolf
Copy link

Khaled-Wolf commented Jul 4, 2020

Same problem here with Unity 2019.4.1, Facebook SDK 7.21.1.

Using use_frameworks! will just use the dynamic libraries instead of the static ones. It compiles, of course, but then those frameworks must be embedded somehow. Still looking into this, but in any case I need Unity generated XCode workspace/project to already be setup or our CI system will fail...

Having to manually modify the podfile and then the project is something that we should not have to do for such an easy task as simply integrating the Facebook SDK...

Here you can setup a simple post build script to modify the podfile programmatically, I use it in my project and it works just fine
Create a new MonoBehaviour file (for example: PostProcessBuild_Podfile.cs) and put it in Assets/Editor folder

using System.Collections;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.IO;

public class PostProcessBuild_Podfile : MonoBehaviour
{
[PostProcessBuildAttribute(45)]//must be between 40 and 50 to ensure that it's not overriden by Podfile generation (40) and that it's added before "pod install" (50)
private static void PostProcessBuild_iOS(BuildTarget target, string buildPath)
{
if (target == BuildTarget.iOS)
{
var fileName = buildPath + "/Podfile";
var endTag = "platform :ios, '9.0'";
var lineToAdd = "use_frameworks!";

        Debug.Log("PostProcess: Adding use_frameworks! to podfile, this fix for new Facebook SDK");
        var txtLines = File.ReadAllLines(fileName).ToList();
        txtLines.Insert(txtLines.IndexOf(endTag)+1, lineToAdd);
        File.WriteAllLines(fileName, txtLines);
        Debug.Log("PostProcess: Adding use_frameworks! to podfile Completed successfully!");
    }
}

}

image

@gtino
Copy link

gtino commented Jul 4, 2020

@Khaled-Wolf thanks for the code, that's really useful, but still even if this makes the project compile then the framework are not embedded in the binary automatically and the app crashes at startup as mentioned by @NumaNumaNuma. I have tried to manually embed the FB frameworks to the build but I honestly don't know which file from which project I should add to which target. All my attempts failed... Any clue on that? (and also, any clue in how to make it work using a post process script?)

@NumaNumaNuma
Copy link

I've reverted to using an older version of the sdk for now (7.19.2 is the most recent one that doesn't use the 7.0 swift iOS sdk).

@eladleb
Copy link

eladleb commented Jul 6, 2020

I also reverted back to 7.19.2 as use_frameworks! Seems to have caused issues with other pods I’m using.
We will wait for an updated Facebook SDK to try again :(

@gtino
Copy link

gtino commented Jul 6, 2020

@NumaNumaNuma yeah that seems to be the only option for now, it compiles and runs without problems! Thanks for sharing this!

@KylinChang
Copy link
Contributor

Current workaround here is to add "use_frameworks!" to Podfile or add an empty swift file to exported iOS project. The issue is fixed in 8fdb57a and will be shipped in the next release.

@Thaina
Copy link

Thaina commented Jul 16, 2020

@KylinChang And this is 6 days already from that commit, what happen? Why it still have error in travis and why it not released yet?

@NumaNumaNuma
Copy link

NumaNumaNuma commented Jul 16, 2020

@Thaina If you're in a rush maybe you could try and fixing it manually. If you look at the commit it's a very small change you could try to implement yourself. Add that blank swift file and the 2 build properties to your xcode project in a post-build script in unity. Sucks having to do it manually, but it might save you a few days (weeks?) while they release it.
Or maybe they do weekly releases and it'll be out tomorrow :D

@Thaina
Copy link

Thaina commented Jul 17, 2020

@NumaNumaNuma First, because that doesn't work

So I don't actually know I do something wrong or the fix is not really work in the first place. Or it has some requirement that it should or must be a fix from facebook SDK package directly or any other reason

Second, it not official so it pollute my code and need to actually remove it in the future when the real fix came out so I try to avoid that. And that's why I don't like to do that before confirm that facebook will not release it soon

Third, it really didn't work, at least in unity 2020.2

  • That .swift cannot be exist in Editor folder or else it would not be copied into actual xcode project
  • In 2019.3 and after, unity change their build structure into main and framework
    • So just set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES in only one main target is not fix the problem
    • Set to both target cause error that Invalid bundle… contains disallowed file 'frameworks'

In my case I need to move that .swift outside into Assets folder. Then made a build process like this

#if UNITY_2019_3_OR_NEWER
		string target = proj.GetUnityMainTargetGuid();
#else
		string targetName = PBXProject.GetUnityTargetName();
		string target = proj.TargetGuidByName(targetName);
#endif

////

#if UNITY_2019_3_OR_NEWER
		foreach(var framework in new [] { target,proj.GetUnityFrameworkTargetGuid() })
#else
		foreach(var framework in new [] { target })
#endif
		{
			proj.SetBuildProperty(framework, "ENABLE_BITCODE", "NO");
			proj.SetBuildProperty(framework, "EMBEDDED_CONTENT_CONTAINS_SWIFT", "YES");
			proj.SetBuildProperty(framework, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
			proj.SetBuildProperty(framework, "SWIFT_VERSION", "5.0");
		}

@IgorGalimski
Copy link

Current workaround here is to add "use_frameworks!" to Podfile or add an empty swift file to exported iOS project. The issue is fixed in 8fdb57a and will be shipped in the next release.

Hi! Coud you please say when you are going to release fix?

@Nezz
Copy link

Nezz commented Jul 24, 2020

@KylinChang The fix is correct for older versions of Unity, but Unity 2019.3 and newer require a different target to be "fixed":
YousicianGit@878fc7b

I'll submit the fix in a PR soon.

@KylinChang
Copy link
Contributor

The issue is fixed in the latest release

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

Successfully merging a pull request may close this issue.