Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Both Unity and Iron Source Mediation fails to build on Xcode with protobuf bitcode error

Discussion in 'Unity Mediation' started by hakankaraduman, Nov 11, 2022.

  1. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    353
    Hi,

    I tried both with Unity Ads with Mediation and also with Iron Source mediation, I get the below error.

    ld: '/Users/myuser/Library/Developer/Xcode/DerivedData/Unity-iPhone-atgpqaqhdoftguekjshddinoqwwc/Build/Products/ReleaseForRunning-iphoneos/Protobuf/Protobuf.framework/Protobuf' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Users/myuser/Library/Developer/Xcode/DerivedData/Unity-iPhone-atgpqaqhdoftguekjshddinoqwwc/Build/Products/ReleaseForRunning-iphoneos/Protobuf/Protobuf.framework/Protobuf' for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Here are the versions I have;

    xcode 14.1
    unity 2021.3.13f1
    iron source v7.2.5.1
    unity ads with mediation 1.0.5
    cocoapods 1.11.3

    I use a MacBook Pro with M1 Pro chip.

    Thanks
     
  2. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Hey @hakankaraduman,

    This is a known issue with Xcode 14, check out this answer if it works for you, thanks!
     
  3. timofey_iam

    timofey_iam

    Joined:
    Oct 28, 2022
    Posts:
    1
    I have the same error.
    I have the same libraries versions and the same XCode.
    And the same - error appeared after I added mediation service.

    Enabling/disabling bitcode option didn't help me.
    I've added a screenshot to show a place where I worked with this option.
    (I tried all combinations both for Unity-IPhone and Pods).

    upload_2022-12-1_11-52-57.png
     
  4. matthieu_unity674

    matthieu_unity674

    Joined:
    Jun 21, 2022
    Posts:
    4
    Hello, I also have kinda the same, it worked well and stopped working since I added IronSource.

    '/........./IronSource.framework/IronSource(ISEventsConfiguration.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '......../IronSourceSDK/IronSource.framework/IronSource' for architecture arm64


    I'm used to the trick @DeclanMcPartlin suggested but it does not work with this specific issue.
     
  5. razer34

    razer34

    Joined:
    Oct 18, 2022
    Posts:
    1
    Any updates on this? Getting the exact same issue.
     
    Last edited: Dec 21, 2022
  6. xdprint

    xdprint

    Joined:
    May 29, 2019
    Posts:
    7
    Hi! Did you manage to solve the problem?
     
  7. El1t3L33t

    El1t3L33t

    Joined:
    Jun 14, 2020
    Posts:
    13
    Having the same problem on Xcode 13.4.1
     
    sachin_unity165 likes this.
  8. sachin_unity165

    sachin_unity165

    Joined:
    Feb 7, 2022
    Posts:
    1
    Any update on this ? Enabling bitcode isn't making a difference
     
  9. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    this is the same problem with unity cloud build also


    ld: '/BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-dipqjitlyjoypafzfjxvahqxtkba/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/IronSourceSDK/IronSource.framework/IronSource(ISAdPlayer.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-dipqjitlyjoypafzfjxvahqxtkba/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/XCFrameworkIntermediates/IronSourceSDK/IronSource.framework/IronSource' for architecture arm64
    150: [2022-12-29T20:33:03.822Z] - 7.2.4.2.7.4 - INFO: ▸ ❌; clang: error: linker command failed with exit code 1 (use -v to see invocation)
     
  10. okravchuk

    okravchuk

    Joined:
    Feb 3, 2022
    Posts:
    1
    Having the same problem
    `IronSource(ISAdPlayer.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target file`
    Enabling/Disabling BITCODE in Build config doesn't help
     
  11. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    build #50
    xcode 14.1
    unity 2021.3.16f1
    ruby 2.42
    clean build

    running this script to disable bitcode in root editor folder

    #if UNITY_IOS

    using UnityEditor;
    using UnityEditor.Callbacks;
    using UnityEditor.iOS.Xcode;


    public static class BitCodeHelperRevised
    {
    [PostProcessBuild( 1000 )]
    public static void PostProcessBuildAttribute( BuildTarget target, string pathToBuildProject )
    {
    if (target != BuildTarget.iOS) return;
    var projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);

    var pbxProject = new PBXProject();
    pbxProject.ReadFromFile(projectPath);
    var targetGuids = new[] { pbxProject.GetUnityMainTargetGuid(), pbxProject.GetUnityFrameworkTargetGuid() };

    pbxProject.SetBuildProperty(targetGuids, "ENABLE_BITCODE", "NO");
    pbxProject.WriteToFile(projectPath);
    }
    }

    #endif


    RESULTS - no longer shows bit code errors but still fails.

    62: [2022-12-30T21:33:41.023Z] - 7.2.4.2.4.2 - INFO: ▸ ⚠;️  ld: object file (/BUILD_PATH/omitted.default-ios/temp20221230-6483-13txorq/Libraries/lib_burst_generated.a(lib_burst_generated_part_0_merged.o)) was built for newer iOS version (16.1) than being linked (12.0)

    81: [2022-12-30T21:34:08.454Z] - 7.2.4.2.4.2 - INFO: ▸ ❌; ld: symbol(s) not found for architecture arm64
    82: [2022-12-30T21:34:08.468Z] - 7.2.4.2.4.2 - INFO: ▸ ❌; clang: error: linker command failed with exit code 1 (use -v to see invocation)

    140: [2022-12-30T21:34:08.526Z] - 7.2.4.2.4.2 - INFO: ❌; ld: symbol(s) not found for architecture arm64
    141: [2022-12-30T21:34:08.526Z] - 7.2.4.2.4.2 - INFO: ❌; clang: error: linker command failed with exit code 1 (use -v to see invocation)
    142: [2022-12-30T21:34:08.559Z] - 7.2.4.2.4.2 - INFO: ▸ clang: error: linker command failed with exit code 1 (use -v to see invocation)
    143: [2022-12-30T21:34:08.559Z] - 7.2.4.2.4.2 - INFO: ▸ /BUILD_PATH/omitted.default-ios/temp20221230-6483-13txorq/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.1.99. (in target 'UnityAds' from project 'Pods')
    144: [2022-12-30T21:34:08.588Z] - 7.2.4.2.4.2 - ERROR: xcode build failed
    145: RuntimeError (Build Failure):
    146: Finished: FAILURE



    The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.1.99. (in target 'UnityAds' from project 'Pods')
     
    Last edited: Jan 1, 2023
  12. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    UPDATE! I HAVE SOME AMAZING NEWS (SORT OF)

    After uninstalling ironsource packages then fresh install and leaving out UnityAds from the Integration Manager, I can now say that it completed the build in cloud build.

    xcode 14.1
    unity 2021.3.16f1
    ruby 2.42
    clean build

    and using the script in my above post for turning off bitcode.
     
    UnityPeterD likes this.
  13. firesightstudios

    firesightstudios

    Joined:
    Mar 29, 2022
    Posts:
    56
    update:


    project version 2021.3.16f1

    ios target 12.0

    cloud build settings (build # 61)

    Xcode 14.1.0

    unity 2021.x

    UnityAds(ironsource manager) (Installed) 4.3.29.1

    ironSource 7.2.6

    ruby 2.7.4

    bitcode disabled

    ^^^^ Build was successful

    For cloud build it was updating ruby to 2.7.4 for a successful build or leaving out unity ads from integration manager and using ruby 2.4.2.
     
    Last edited: Jan 7, 2023
  14. masterton

    masterton

    Joined:
    Dec 11, 2012
    Posts:
    41
    Apple is dropping the bitcode requirement, starting with Xcode 14. Apple never really used bitcode, and it's been a massive PITA for us Unity developers. I'd recommend disabling it all together to make your life easier.

    I added a Fastlane plugin to my Jenkins builds to do just that: no_more_bitcode

    For Unity, you need to call the plugin on the main and the Pods projects. Here's an example from my Fastfile.
    Code (boo):
    1.     private_lane :disable_bitcode do |options|
    2.         no_more_bitcode( xcode_project: @xcode_output + "/Unity-iPhone.xcodeproj" )
    3.         no_more_bitcode( xcode_project: @xcode_output + "/Pods/Pods.xcodeproj" )
    4.     end
    Read more details on the horrors and waste of time that was bitcode.
     
  15. KingoJH

    KingoJH

    Joined:
    Nov 6, 2015
    Posts:
    27
    I don't need ironsource right now. Only thing what causes this bug. What worked for me was to go to packages look up ads mediation. Uninstall, then install again then uninstall again. I think it got glitched with xcode 14. Then delete the ironsource folder in the project. Then build the project, enable bitcode on pods = true. Run it once on a phone, then set Always Embed Swift Standard Libraries to NO at frameworks. Then you can finally archive and publish.

    Got to love unity adoptions and abandonments. Wasted a whole day on this.
     
  16. avinashnx

    avinashnx

    Joined:
    Aug 10, 2018
    Posts:
    4
    For IronSource, the build was successful after setting all the bitcode to NO, including UnityIphone & UnityFrameworks
     
  17. ImYuta

    ImYuta

    Joined:
    Aug 1, 2012
    Posts:
    1
    [SOLVED]
    I've turn off bitcode of all target, build success but app crash immediately after open.

    Then please don't turn off all the bitcode if you don't know what it is, like the firesightstudios's answer before. Just turn off bitcode of true target and it will build success.

    For me:
    Step 1: Turn off bitcode for Unity Framework
    At this step, if it build fail due to Unity Framework issues, that because there are some swift's library that do not auto includes when building. Just do these things to include them:
    - Select Unity Framework target -> Build Settings -> search for "library search path"
    - Add the library uri:
    Code (Boo):
    1. $(SDKROOT)/usr/lib/swift
    2. $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
    Step 2: Turn on bitcode for Pods-Unity-iPhone
    Step 3: Turn off bitcode of all other targets in Pods

    Build Successfully! Play like a boss!
     
    Last edited: Mar 31, 2023
    igoapp likes this.
  18. lblast

    lblast

    Joined:
    Dec 1, 2016
    Posts:
    68
    I'm encountering the same error and I have tried the solutions above (disabling bitcode, turning it on for pods).

    We are using
    XCode 14.3
    Unity 2022.2.8f1
    Iron source v7.3.0
    Unity ads with mediation 1.0.5

    Our PostProcessor code also has ENABLE_BITCODE = NO.

    I then get an error saying

    File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
     
  19. pichikala

    pichikala

    Joined:
    Sep 18, 2021
    Posts:
    5
    I spent two days figuring out how to make Unity LevelPlay work with IronSource, and here's what worked for me. I had to combine three methods that I found on the forum.

    1. Disable BitCode by using the following code in Scripts/Editor/BitCodeHelperRevised.cs (huge thanks to @firesightstudios):
      Code (CSharp):
      1. #if UNITY_IOS
      2.  
      3. using UnityEditor;
      4. using UnityEditor.Callbacks;
      5. using UnityEditor.iOS.Xcode;
      6.  
      7. public static class BitCodeHelperRevised
      8. {
      9.     [PostProcessBuild(1000)]
      10.     public static void PostProcessBuildAttribute(BuildTarget target, string pathToBuildProject)
      11.     {
      12.         if (target != BuildTarget.iOS) return;
      13.  
      14.         var projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
      15.  
      16.         var pbxProject = new PBXProject();
      17.         pbxProject.ReadFromFile(projectPath);
      18.  
      19.         var targetGuids = new[] { pbxProject.GetUnityMainTargetGuid(), pbxProject.GetUnityFrameworkTargetGuid() };
      20.         pbxProject.SetBuildProperty(targetGuids, "ENABLE_BITCODE", "NO");
      21.         pbxProject.WriteToFile(projectPath);
      22.     }
      23. }
      24. #endif
    2. After building in Unity, open Unity-iPhone.xcworkspace (I used to open Unity-iPhone.xcodeproj and didn't know why it wasn't working anymore, so it's important to note that you now need to run the workspace).
    3. Ensure that nothing is using BitCode. Click on 'Unity-iPhone' in the left menu, then check every target and the Project. You can check this by clicking "Build Settings" in the menu and searching for "enable bitcode." If you see something using bitcode (true), change it to false.
    4. After checking every target, click on 'Pods' in the left menu and do the same (check if all bitcodes are set to false).
    5. Select 'Unity-iPhone' in the left menu, click on 'UnityFramework' under targets, then click on Build Settings and search for "library search path." Add the following:
      Code (CSharp):
      1. $(SDKROOT)/usr/lib/swift
      Code (CSharp):
      1. $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
      Huge thanks to @ImYuta for this tip.
    6. Search for "Runpath Search Path" in the same place (UnityFramework -> Build Settings) and add this line:
      Code (CSharp):
      1. /usr/lib/swift
      Then drag it to the top of the list. Thanks to @masterton for this advice.

    That's it! I hope this helps!

    Worked for me on:
    Unity 2021.3.24f
    XCode 14.1
     
    drawcode, DeclanMcPartlin and fcayed like this.
  20. fcayed

    fcayed

    Joined:
    Jan 2, 2017
    Posts:
    2
    @pichikala I had been looking for a way of making it work and your steps did it for me ! Thanks a lot
    Unity 2023.3.10f1
    IronSource SDK 7.5.1
    Xcode 15.0 on Sonoma.
     
    pichikala likes this.
  21. Maree97

    Maree97

    Joined:
    Dec 30, 2018
    Posts:
    1
    In my case I did only first step from @pichikala after that I noticed that I don't have xcworkspace but only xcodeproj, also I had Podfile, all I did I opened terminal in build folder and run pod install, it took a while but after installing I got xcworkspace after that I tried to build from xcodeproj but build failed, after that I tried from xcworkspace and it worked perfectly also ads are working in build
     
  22. KingoJH

    KingoJH

    Joined:
    Nov 6, 2015
    Posts:
    27
    What works for me is to disable bitcode everywhere and change minimum deployment from 8 to 10 for protobuf.

    Important notes though
    You got to open the proj/workspace so you can see pods if you have properly integrated them.

    Unity often doesn't integrate pods well, different type of issues for which you manually have to enable certain things in files, for example UTF-8 encoding which you have to manually edit a document somewhere differently depending on your terminal (M1/intel). Or certain ruby versions/xcode versions not working. It is quite tedious to implement and I spent like 1 month on this :confused:
     

    Attached Files: