Alex-Dobrynin / Xamarin.Controls.ImageCropper

Cross platform Xamarin library to crop and rotate images
MIT License
8 stars 2 forks source link

Publish iOS maui 8 app to App Store gives contains incomplete bitcode #7

Closed alzubitariq closed 1 month ago

alzubitariq commented 3 months ago

Asset validation failed Invalid bundle executable. the executable zzmma.app/Frameworks/TOCropViewController.framework/TOCropViewController contains incomplete bitcode

Alex-Dobrynin commented 3 months ago

@alzubitariq cloud you check something for me? could you download this repo and add Plugin.Maui.ImageCropper as reference to your maui project instead of nuget package. and add this code to the csproj file of Plugin.Maui.ImageCropper:

<!--hack from https://github.com/dotnet/maui/issues/10989--> 
  <PropertyGroup>
    <!-- Properties used to strip bitcode from frameworks when using Visual Studio for Mac -->
    <_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'=='Unix'">_ExpandNativeReferences</_StripBitcodeFromFrameworksMasterAfterTargets>
    <_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'=='Unix'">_StripBitcodeFromFrameworksOnMac</_StripBitcodeFromFrameworksMasterDependsOnTargets>

    <!-- Properties used to strip bitcode from frameworks when using Visual Studio for Windows -->
    <_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'!='Unix'">_ComputeFrameworkFilesToPublish</_StripBitcodeFromFrameworksMasterAfterTargets>
    <_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'!='Unix'">_StripBitcodeFromFrameworksOnWindows</_StripBitcodeFromFrameworksMasterDependsOnTargets>
  </PropertyGroup>

  <Target Name="_StripBitcodeFromFrameworksMasterTarget" Condition="'$(_StripBitcodeFromFrameworksMasterDependsOnTargets)'!='' AND @(_FrameworkNativeReference-&gt;Count()) != 0" AfterTargets="$(_StripBitcodeFromFrameworksMasterAfterTargets)" DependsOnTargets="$(_StripBitcodeFromFrameworksMasterDependsOnTargets)" />

  <Target Name="_StripBitcodeFromFrameworksOnMac" Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False'">

    <!-- Find the bitcode_strip command -->
    <Exec Command="xcrun -find bitcode_strip" ConsoleToMSBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="_BitcodeStripCommand" />
    </Exec>

    <!-- Strip the bitcode from frameworks -->
    <Exec Command="$(_BitcodeStripCommand) %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />
  </Target>

  <Target Name="_StripBitcodeFromFrameworksOnWindows" Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False' AND '$(IsMacEnabled)'=='true'">

    <!-- Strip the bitcode from frameworks -->
    <Exec SessionId="$(BuildSessionId)" Command="&quot;%24(xcrun -find bitcode_strip)&quot; %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />

    <CopyFileFromBuildServer SessionId="$(BuildSessionId)" File="%(_FrameworkNativeReference.Identity)" TargetFile="%(_FrameworkNativeReference.Identity)" />
  </Target>

and check if it can be uploaded to apple

alzubitariq commented 3 months ago

@Alex-Dobrynin Unable to build the project after doing the steps you asked

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.2.8004/tools/msbuild/iOS/Xamarin.Shared.targets(546,3): error :

Error loading partial Info.plist template file 'obj/Debug/net8.0-ios/iossimulator-arm64/resizetizer/sp/MauiInfo.plist': Could not find a part of the path '/Users/tariq/Desktop/App/App/obj/Debug/net8.0-ios/iossimulator-arm64/resizetizer/sp/MauiInfo.plist'. [/Users/tariq/Desktop/App/App/ZamApp.csproj::TargetFramework=net8.0-ios]

Alex-Dobrynin commented 3 months ago

show me the full csproj you have done

alzubitariq commented 3 months ago
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net8.0-ios</TargetFrameworks>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>

        <SupportedOSPlatformVersion
            Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
            14.2</SupportedOSPlatformVersion>

        <Authors>Alex Dobrynin</Authors>
        <Description>Simple crossplatform image cropper optimized for MAUI</Description>
        <Copyright>2023 Alex Dobrynin</Copyright>
        <PackageProjectUrl>https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper</PackageProjectUrl>
        <RepositoryUrl>https://github.com/Alex-Dobrynin/Xamarin.Controls.ImageCropper.git</RepositoryUrl>
        <PackageReadmeFile>README.md</PackageReadmeFile>
        <PackageTags>maui;image;cropper;crop;android;ios;rotate</PackageTags>
        <PackageLicenseFile>LICENSE</PackageLicenseFile>
        <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
        <Version>1.0.1</Version>
    </PropertyGroup>

    <ItemGroup Condition="$(TargetFramework.Contains('android'))">
        <PackageReference Include="Com.Vanniktech.AndroidImageCropper.Maui">
            <Version>4.4.0</Version>
        </PackageReference>
    </ItemGroup>

    <ItemGroup Condition="$(TargetFramework.Contains('ios'))">
        <PackageReference Include="TimOliver.TOCropViewController.Maui">
            <Version>2.3.6</Version>
        </PackageReference>
    </ItemGroup>

    <!--<ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
    </ItemGroup>-->

    <ItemGroup>
        <None Include="..\LICENSE">
            <Pack>True</Pack>
            <PackagePath>\</PackagePath>
        </None>
        <None Include="..\README.md">
            <Pack>True</Pack>
            <PackagePath>\</PackagePath>
        </None>
    </ItemGroup>

    <PropertyGroup>
        <!-- Properties used to strip bitcode from frameworks when using Visual Studio for Mac -->
        <_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'=='Unix'">
            _ExpandNativeReferences</_StripBitcodeFromFrameworksMasterAfterTargets>
        <_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'=='Unix'">
            _StripBitcodeFromFrameworksOnMac</_StripBitcodeFromFrameworksMasterDependsOnTargets>

        <!-- Properties used to strip bitcode from frameworks when using Visual Studio for Windows -->
        <_StripBitcodeFromFrameworksMasterAfterTargets Condition="'$(OS)'!='Unix'">
            _ComputeFrameworkFilesToPublish</_StripBitcodeFromFrameworksMasterAfterTargets>
        <_StripBitcodeFromFrameworksMasterDependsOnTargets Condition="'$(OS)'!='Unix'">
            _StripBitcodeFromFrameworksOnWindows</_StripBitcodeFromFrameworksMasterDependsOnTargets>
    </PropertyGroup>

    <Target Name="_StripBitcodeFromFrameworksMasterTarget"
        Condition="'$(_StripBitcodeFromFrameworksMasterDependsOnTargets)'!='' AND @(_FrameworkNativeReference-&gt;Count()) != 0"
        AfterTargets="$(_StripBitcodeFromFrameworksMasterAfterTargets)"
        DependsOnTargets="$(_StripBitcodeFromFrameworksMasterDependsOnTargets)" />

    <Target Name="_StripBitcodeFromFrameworksOnMac"
        Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False'">

        <!-- Find the bitcode_strip command -->
        <Exec Command="xcrun -find bitcode_strip" ConsoleToMSBuild="true">
            <Output TaskParameter="ConsoleOutput" PropertyName="_BitcodeStripCommand" />
        </Exec>

        <!-- Strip the bitcode from frameworks -->
        <Exec
            Command="$(_BitcodeStripCommand) %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />
    </Target>

    <Target Name="_StripBitcodeFromFrameworksOnWindows"
        Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True') AND '$(_SdkIsSimulator)'=='False' AND '$(IsMacEnabled)'=='true'">

        <!-- Strip the bitcode from frameworks -->
        <Exec SessionId="$(BuildSessionId)"
            Command="&quot;%24(xcrun -find bitcode_strip)&quot; %(_FrameworkNativeReference.Identity) -r -o %(_FrameworkNativeReference.Identity)" />

        <CopyFileFromBuildServer SessionId="$(BuildSessionId)"
            File="%(_FrameworkNativeReference.Identity)"
            TargetFile="%(_FrameworkNativeReference.Identity)" />
    </Target>
</Project>
alzubitariq commented 3 months ago

Tool /usr/bin/xcrun execution finished (exit code = 1).

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
        <key>com.apple.ibtool.errors</key>
        <array>
                <dict>
                        <key>description</key>
                        <string>Unrecognized commandline options: "14.2" and "/Users/tariq/Desktop/App/App/obj/Debug/net8.0-ios/iossimulator-arm64/resizetizer/sp/MauiSplash.storyboard". Either unrecognized options were passed, or multiple input documents were passed when only one was expected.</string>
                </dict>
        </array>
  </dict>
  </plist>
Alex-Dobrynin commented 3 months ago

The error above has nothing to this library. as it does not like MauiSplash.storyboard. But anyway, I've updated the project. just pull latest changes. and add reference to your project and build and push to apple.

Also, there is demo project inside this repo. It can be built and run.

alzubitariq commented 3 months ago

@Alex-Dobrynin Issue still exist unfortunately.... Screenshot 2024-01-23 at 8 47 55 PM

Alex-Dobrynin commented 3 months ago

Unfortunately, ios binding library TOCropViewController was not made by me, and I cannot just recompile it. But I have in plans to change binding libraries for android and ios to another ones. but, unfortunately it will not be as soon as I want.

I will not close this issue.

Alex-Dobrynin commented 3 months ago

@alzubitariq also read this issue please https://github.com/dotnet/maui/issues/10989 look into your csproj file is there everything the same as in workaround in that issue

Alex-Dobrynin commented 1 month ago

Fixed in latest nuget version