Unity iOS XCode Build Failed: Apple Mach-O Linker Error - ios

I've been trying to build my Unity game to iOS with Admob, Unity IAP, and Firebase Analytics.
Unity Version: 5.6.2f1 Personal
Xcode Version: 8.3.3
Steps I've completed:
Enabled IAP and Analytics in Unity Service tab, Imported IAP package
Imported Firebase Analytics Package
Imported Admob unity package
Created new Firebase project in the web portal. Downloaded GoogleService-Info.plist file
Put .plist file in Assets folder.
Ensured my player settings in Unity were correctly configured (Bundle Identifier, Version, IL2CPP set, Architecture: Universal, Device SDK set).
Made Xcode project folder (Release mode set in build settings). Build succeeded, no errors.
Opened terminal window and ran "pod init" in Xcode project folder root
Ran "pod 'Firebase/Core'", "pod install". Succeeded
Opened the .xcworkspace file from Xcode
Changed "Enable Modules (C and Objective-C)" to "Yes" in Build Settings for both target and project files.
Downloaded the GoogleMobileAds.framework (from the GoogleMobileAdsSDK zip)
Added the GoogleMobileAds.framework to the list of frameworks in "Build Phases"
Added AdSupport.framework
Added "-ObjC" to "Other Linker Flags" in both Target and Project files.
Cleaned Project
Build Project, Build failed due to linker errors
I've also tried upping the deployment target to 8.0 rather than 6.0 in the general settings and PodFile, but it didn't remove the errors.
Any help would be appreciated. I think I'm just missing a step somewhere in the Xcode configuration but I can't seem to figure it out.

Fixed it! It was a simple mistake on my part. I downloaded an unofficial Google Admob Unity package. This created an "AdmobAPI" folder in my Assets/Plugins which contained the files causing the linker errors.
I didn't notice it right away because this folder was never getting overwritten when I reimported the official packages. It finally caught my eye when I was comparing the directories between my project and Google's sample project which I installed the official packages to.
So in short, double check what you're importing and scan your directories thoroughly if you run into build errors. At this point in time, little to no modification should be needed in Xcode (I didn't need any of those extra steps); Unity does nearly all the work.

Related

UnityFramework.framework contains disallowed file 'Frameworks'. Getting this error while getting Unity IOS build

On my Unity project, I took several builds before without a problem. However, in this build, I integrated Facebook SDK and then this error (image1) started appearing when I try to upload it after archiving it on the Xcode workspace.
I also tried to upload it with Transporter, but Transporter also threw errors (image2).
When I build the project for IOS unity creates some files and there I found a UnityFramework folder, I think this folder is the mentioned folder in the error. However, there are only 2 files in this folder and none is named "Frameworks"(image3).
Here are the build options of the project at Xcode workspace (image4):
With the Android build of the app, everything is okay. This issue appears only with the IOS build.
Try to set the Always Embed Swift Standard Libraries. to No
Yes, but Set the Always Embed Swift Standard Libraries in UnityFrameWork Build Settings, not in main app's Build Settings. That worked for me.

Native iOS Unity Integration - AppStore Provisioning Profile causes 'UnityFramework/UnityFramework.h' file not found

I have a native iOS app (Swift) with Unity integrated as a library following this guide:
https://forum.unity.com/threads/integration-unity-as-a-library-in-native-ios-app.685219/
XCode 12.5.1, Unity 2019.4.12f, CocoaPods 1.10.2
For the last 3 days, I am getting this error when I attempt to archive with an AppStore provisioning profile:
/Users/../Bridging-Header.h:9:9: 'UnityFramework/UnityFramework.h'
file not found
Failed to emit precompiled header
'/Users/../Build/Intermediates.noindex/ArchiveIntermediates/appname-testflight-qa/PrecompiledHeaders/Bridging-Header-swift_OMITED-clang_OMITED.pch'
for bridging header '/Users/../Bridging-Header.h'
When I do a regular build using any Provisioning Profile (PP), it builds successfully and I can run on device. When I archive using an Ad-Hoc PP, it succeeds as well.
It only happens during archiving using a manually specified AppStore PP, which I need for doing command-line builds for automated deployments. I've confirmed it happens in both commandline and in XCode editor. I need the Bridging Header so that I can allow native iOS to interact with Unity to pass it some information.
Here's the bridging header:
#ifndef BRIDGING_HEADER
#define BRIDGING_HEADER
#import <UIKit/UIKit.h>
#import <UnityFramework/UnityFramework.h>
#import <UnityFramework/NativeCallProxy.h>
#endif /* BRIDGING_HEADER */
I've tried the following suggestions already on all the other UnityFramework.h not found questions to no avail:
Switch off Parallize Build
Add UnityFramework.framework and/or Unity-iPhone project as a target first in the build process
Cleaned up project, delete DerivedData, deleted/reinstalled Pods
Switched to another scheme that will archive an Ad-Hoc PP, and changed to using AppStore PP
Reintegrated the Unity project all-over again
Build target set to Device (not simulator) through all these tests
I tried switching to: "../UnityFramework/UnityFramework.h" inside the Bridging header
Made Framework optional inside Build Phases - Link Binary With Libraries (and tried to add Copy File Build Phase - this caused an error saying this copy step was being duplicated)
Validated Runpath already includes #executable_path/Frameworks
Tried changing Pods and Project to iOS 12.1 min version and set Pods' Build Active Architecture Only to YES
Any help or suggestions would be very appreciated. I'm completely out of ideas.
The issue resided with naming of Configurations between the primary project and the Unity-iPhone subproject. Since the Unity project didn't have a matching configuration, it chose from one of the other available configurations, in my case, Debug (QA). When the archive went looking for the UnityFramework, it was in the wrong folder.
Essentially, if you have custom Configurations, make sure all of them in your primary project are also in the Unity-iPhone Project with exact same name.

Build additional target in Xcode: Error 'React/RCTBridgeDelegate.h' file not found in AppDelegate.h

Building my React Native app in Xcode 11.3.1 gives me the error:
"React/RCTBridgeDelegate.h" file not found in AppDelegate.h
only when building an additional target (Release Scheme) directly in Xcode. When building the standard development target, I have no problems.
More detailed:
I have a React Native app with a Watch companion app. The app is equipped with different additional React Native modules. The app runs smoothly when building it in the standard build target (Development scheme) via React Native CLI (react-native run-ios) as well as when building the standard build target (Development scheme) directly in Xcode.
Already a while ago, I have created a duplicate set of targets in Xcode (Release scheme). Building the duplicate target for the iOS app in Xcode bundles the React Native code and images as an additional build phase to be able to deploy the app on an iPhone not depending on the development server. Building this target worked out smoothly as well for a long time.
Now all of a sudden since some days when I want to build my duplicate target (Release scheme) in Xcode I am getting the error
I can still build the standard build target (Development scheme) via console react-native run-ios and also directly in Xcode with no problems. I am not sure what caused this issue now, the only change to my config I have made some days ago is that I have added some additional modules to my React Native app, e.g. react-native-keychain and react-native-push-notification. Both have been configured correctly as I would assume, also pods have been installed as necessary and I can see that those modules also work well when building the development target, so I don't think that adding those additional modules caused the issue.
I have read all issues on StackOverflow describing this problem and have already tried all of the following solution proposals with no effect, unfortunately:
Make sure that "Parallelize builds" is deactivated in the scheme (had already done that by the time when duplicating the development target creating a release target). Also make sure that target "React" is listed above the app build target in "Build" option of the scheme.
De-integrate pods and re-install pods
List additional target in the Podfile with "inherit! :search_paths", again de-integrate and re-install pods --> gives me a warning that the additional target in the Podfile "overrides the HEADER_SEARCH_PATHS build setting"
Clean the build and repeat step 2
Add the React path directly in the HEADER_SEARCH_PATHS in target build settings --> gives me linker errors
Explicitly build target "React" first - Clean Build, Build target "React", then build my release target
I am stuck and would really appreciate your help - do you have further ideas on what I can try out to solve this problem?

Unity iOS Generated project fails to load framework : dylib, reason image not found

I currently have an issue with an XCode project, targeting iOS, generated by Unity : a framework imported from Unity is not loaded at runtime.
I use Unity 2018.1.4f1, XCode 9.4.1, the framework is a SDK in progress (stable version).
The generated XCode project builds fine, but when the app launches, I get the following error :
dyld: Library not loaded:
#rpath/MyFramework.framework/MySDK Referenced from:
/var/containers/Bundle/Application/55523B8-4DE8-432Y-BDAB-C9A4B09IK1DE/MyApp.app/MyApp
Reason: image not found
This thread was handy, and lead me to try the following :
add my .framework to "embedded binaries"
add my .framework to a "Copy File" build phase, targeting "Framework" directory
checked the slices of my .framework (armv7, arm64)
close XCode > delete .framework > delete derived data > clean build folder > restart macos > reimport .framework
Runpath
None of the above solved my issue, and I have no ideas / forums left to try.
Have you ever met this situation ? Any Idea to work on ?
Thanks for your time.

error: Invalid bitcode version (Producer: '800.0.35.0_0' Reader: '703.0.31_0')

When I try to Archive my application on Xcode 7.3.1, I am getting following error:
error: Invalid bitcode version (Producer: '800.0.35.0_0' Reader:
'703.0.31_0') clang: error: linker command failed with exit code 1
(use -v to see invocation)
I was able to successfully Archive my app yesterday, can any one please help me?
i had this error before ...
you may try the following solution it worked for me
search for bitcode keyword in app --> Build Settings and change it to NO
then archive again -->
it should work fine now
Install Xcode 8:
https://developer.apple.com/download/
Xcode 8 GM seed may be used to submit apps to the App Store.
More info:
In my case I updated to the latest Facebook iOS SDK 4.15.1. Since that library was updated with Xcode 8 and I was still using Xcode 7.3.1 it caused the error.
https://developers.facebook.com/docs/ios/change-log-4.x
Updated for Xcode 8 GM and iOS 10.
So, double check 3rd party libraries.
Or if you don't mind disabling bitcode:
Go to build settings search bitcode and change "Enable Bitcode" to "No".
I also faced the same problem, and as suggested by #Nate,
the issue was because of a third party SDK integrated in our project using Cocoapods.
To help me figure out which one of the 15 pods i had in the project was responsible, i did the following:
Create a new xcode project
Copy the Podfile from your original project to the newly created project's directory
Do pod install
Remove one or more of the pods⋆
Archive the new project, and see if it succeeds, if not repeat step 4 till you are able to archive
⋆(you can also try something like binary search, wherein you delete the first half pods in your Podfile and see if the new project archives)
Once you've figured out the library causing the issue, keep downgrading the library by explicitly specifying the version in Podfile, until the project archives successfully.
And then you can use that version of the library to archive and upload to the app store.
If you are using lib or pod that mean that one of them built by a higher version of your current Xcode, you can either update your code or return back to the previous version where the pods were built by your current version.
If you ran pod update check the pods updated if you ran pod install check the dates of the pods comparing to the release date of your Xcode that will will lead you to the responsible pod.
I got it while I was building using Xcode 8.2.1 and the pod built by Xcode 8.3.1
I also faced this error: Invalid bitcode version (Producer: '800.0.24.1_0' Reader: '703.0.31_0') I have googling so many but unable to find the proper solution. I tried Myself and solved this probable
In my case this error occurs after adding FBSDK by drag and drop that we all usually do.
You can resolve this problem by following these steps:
Delete all pod script in build Phases.
Delete the dragged FBSdks file from the project.
Exit xcode and delete 3 things "Pod folder","Podfile.lock" and "Projectworkspace"
Search and add FBSDK pod link in podfile
Install the pod again by using terminal.... now open Xcode archive your project build.
good solutions, but disabling bitcode worked for some people.
edit :- it worked for me too.
but in future your app might be in problem or (build not optimised by Appstore) if your project is **Bitcode Disable **.
Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.
Note: For iOS apps, bitcode is the default, but optional. If you
provide bitcode, all apps and frameworks in the app bundle need to
include bitcode. For watchOS apps, bitcode is required
So thats why try to figure out error solutions right way.
The error basically says:
The static linker could not correctly link a certain bitcode bundle, which was
produced using Producer: '902.0.39.2', and is being read using Reader:
'900.0.37'.
You can look up at https://gist.github.com/yamaya/2924292 to identify the Xcode versions for the corresponding compiler versions. In the current case, the reader (our Xcode version) is Xcode 9.0, whereas the producer (Xcode version of typically a third party SDK) is Xcode 9.4. The incompatibility between the two is the root cause of this issue.
You may either:
turn off the bitcode as discussed in other answers, or
roll-back the SDK to a previous version that worked well, or
update your codebase to use the newer Xcode version.

Resources