line / line-sdk-unity

Provides a modern way of implementing LINE APIs in Unity games, for iOS and Android.
https://developers.line.biz/
Apache License 2.0
117 stars 24 forks source link

When building line-sdk-unity 1.4.0 with Unity 2021.3.37, a build error occurs due to duplicate registration of xcframework, resulting in a "duplicate output file" error. #69

Closed matsumura-katsuhiro closed 4 months ago

matsumura-katsuhiro commented 6 months ago

Is it a security issue?

No

What did you do?

When building line-sdk-unity 1.4.0 with Unity 2021.3.37, a build error occurs. Unity 2021.3.37 includes xcframework support, which seems to be causing file duplication.

Here is a part of the error that occurs

unexpected duplicate tasks
duplicate output file

(ProjectPath)/Xcode/DerivedData/Unity-iPhone-cvuxrfxovekkikcqqiqjlzycrysy/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/2BAC3286-CC10-3FAA-BB02-6F84A3D39864.bcsymbolmap' on task: ProcessXCFramework (ProjectPath)/iOS/Libraries/Plugins/iOS/LineSDK/LineSDKObjC.xcframework /Users/violet/Library/Developer/Xcode/DerivedData/Unity-iPhone-cvuxrfxovekkikcqqiqjlzycrysy/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/LineSDKObjC.framework

This phenomenon also occurs in a project that only includes the LineSDK.

When setting the environment to iOS and performing an Archive on the Xcode project generated by executing "Build," an Unexpected duplicate tasks error occurs.

What did you expect?

I hope that the duplicate registration of xcframework will not occur and that the build will be successful.

This phenomenon may be due to an issue with Unity's handling of xcframework.

I was able to confirm that the build succeeds by adding the following code:

In FrameworkAdding.cs, I confirmed that removing the LineSDKObjC.xcframework, which Unity seems to be adding, with the following code allows it to work correctly:

private const string frameworkXcodePath = "Frameworks/Plugins/iOS/LineSDK/vendor";

// Get the GUID of the source framework without adding it to the project.
var frameworkXcodeSourcePath = Path.Combine(frameworkXcodePath, frameworkName);
string sourceFrameworkGuid = proj.FindFileGuidByProjectPath(frameworkXcodeSourcePath);
Debug.Log("Framework GUID: " + sourceFrameworkGuid);

// Remove the source framework from the project if it exists.
if (!string.IsNullOrEmpty(sourceFrameworkGuid)) {
    proj.RemoveFileFromBuild(appTargetGuid, sourceFrameworkGuid);
    proj.RemoveFrameworkFromProject(appTargetGuid, frameworkName);
    proj.RemoveFile(sourceFrameworkGuid);
}

I would like to confirm if this approach is correct.

What happened actually?

When building line-sdk-unity 1.4.0 with Unity 2021.3.37, the following build errors occur unexpected duplicate tasks duplicate output file

Your environment?

Apple MacBook Pro M1 2021 macOS 13.6.4 ventura line-sdk-unity 1.4.0 with Unity 2021.3.37

Sample project

Kenward1336 commented 5 months ago

I found easier way to solve this issue. line-sdk-unity 1.4.0 have a problem with LineSDKObjc.framework loaded twice.

When you check your Xcode project, You can found LineSDKObjC.framework in {Project}/Libraries/Plugins/iOS/LineSDK and {Project}/Frameworks/Plugins/iOS/LineSDK/vender

To solve this issue, Simply deselect the iOS import option and then apply the LineSDKObjc.framework within Unity's Assets/Plugins/iOS/LineSDK/vendor. image

onevcat commented 4 months ago

Should be fixed in 1.4.1.