yasirkula / UnityNativeGallery

A native Unity plugin to interact with Gallery/Photos on Android & iOS (save and/or load images/videos)
MIT License
1.4k stars 199 forks source link

Symbol(s) not found for architecture arm64 #236

Open FrankdenUijl opened 2 years ago

FrankdenUijl commented 2 years ago

Unable make a iOS build in Unity Cloud Build

I have the following issue in Unity Cloud Build: image image

craytive-technologies-bv-baselinez-ios-baselinez-dev-40-BaselineZ-Dev-Unity-iPhone.log

Reproduction steps

Include the package, run it in Unity Cloud Build

FrankdenUijl commented 2 years ago

image I use automated setup.

yasirkula commented 2 years ago

Are there any editor scripts that call "SetBuildProperty" with "OTHER_LDFLAGS" parameter in the entirety of the project?

FrankdenUijl commented 2 years ago

We have the following: project.SetBuildProperty(targetGUID, "ARCHS", "arm64"); (Only gets called when UNITY_IOS && PLATFORM_OCULUS, not this build)

proj.SetBuildProperty (targetGUID, "IPHONEOS_DEPLOYMENT_TARGET", "9.0"); we change the IPHONEOS_DEPLOYMENT_TARGET to 11 (in another script) before it goes into the xcode. I just removed that line of code.

And ofcours: image

yasirkula commented 2 years ago

It just feels like my -framework additions are either removed by some other post-processing script or ignored by Xcode for unknown reasons because I can see a variety of unknown symbols that come from all of these frameworks. You can try adding those frameworks via PBXProject.AddFrameworkToProject, if you wish. You should then comment out my AddBuildProperty lines.

FrankdenUijl commented 2 years ago

Hmm, like this?

Debug.Log("NGPostProcessBuild OnPostprocessBuild");
// Minimum supported iOS version on Unity 2018.1 and later is 8.0
#if !UNITY_2018_1_OR_NEWER
if( !Settings.Instance.MinimumiOSTarget8OrAbove )
{
    pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-weak_framework Photos" );
    pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-weak_framework PhotosUI" );
    pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-framework AssetsLibrary" );
    pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-framework MobileCoreServices" );
    pbxProject.AddBuildProperty( targetGUID, "OTHER_LDFLAGS", "-framework ImageIO" );
}
else
#endif
{
    pbxProject.AddFrameworkToProject( targetGUID, "PhotosUI.framework", true );
    pbxProject.AddFrameworkToProject( targetGUID, "Photos.framework", false );
    pbxProject.AddFrameworkToProject( targetGUID, "MobileCoreServices.framework", false );
    pbxProject.AddFrameworkToProject( targetGUID, "ImageIO.framework", false );
}

//pbxProject.RemoveFrameworkFromProject( targetGUID, "Photos.framework" );
yasirkula commented 2 years ago

Yeah that looks fine to me.

FrankdenUijl commented 2 years ago

Oke, thanks! I will let you know if it works.

FrankdenUijl commented 2 years ago

Hmm, I just checked same error.

The strange thing is that the OnPostprocessBuild does not get called at all.. I dont see the NGPostProcessBuild OnPostprocessBuild in the log on Unity Cloud Build. (I added that log before building)

That explain the error. Do you have any idea why?

yasirkula commented 2 years ago

Is it possible that Settings.Instance.AutomatedSetup returns false on Cloud Build? Does deleting #if UNITY_IOS allow OnPostprocessBuild to be called?

FrankdenUijl commented 2 years ago

I have just tested that it runs fine locally. Also found out that none of my "OnPostprocessBuild" methods are being called in Unity Cloud Build.

image image

But none of the logs shows up in UCB.

I have reported this to Unity.

yasirkula commented 2 years ago

How about you throw an exception there and see if it breaks the cloud build? It's so that we can eliminate the possibility of PostProcessBuild logs intentionally being omitted from Cloud Build by Unity (for unknown reasons).

FrankdenUijl commented 2 years ago

Nope, no exception, error or warning.

image

yasirkula commented 2 years ago

Yeah, seems like a UCB issue then.

FrankdenUijl commented 2 years ago

I have fixed it by calling your method via a Post-export method.

Seems like this issue is only in m project.

yasirkula commented 2 years ago

I'm curious, how did you figure out that this issue is only in your project?

FrankdenUijl commented 2 years ago

I run an old commit via UCB, it had your package in it (an older version) and other postprocessbuild methods. All of the post methods where invoked correctly. I only updated your package after I saw that UCB failed.

So something in my newer commits prevents post processing methods in UCB.

yasirkula commented 2 years ago

Did you possibly add a class named PostProcessBuildAttribute which has overridden Unity's own attribute?

FrankdenUijl commented 2 years ago

image The only strange way of invoking OnPostprocessBuild.

But the package is excluded in our project. image

Do you think I should investigate this?

yasirkula commented 2 years ago

I don't think you should investigate that ~ symbol. If you type PostProcessBuild and hover your cursor over it, make sure that it shows the namespace as UnityEditor.Callbacks.PostProcessBuildAttribute. Otherwise you have a conflicting custom PostProcessBuildAttribute. If the namespace is correct, I don't know how you can investigate this issue :D