Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

iOS & tvOS Xcode Fails: 'Library not found for -liPhone-lib'

Discussion in 'iOS and tvOS' started by Xander-Davis, Nov 24, 2019.

  1. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    After updating my project (macOS, iOS, tvOS) to Unity 2019.2.13f1, it built to macOS fine without issue but once converted to iOS and built to Xcode (11.2.1), the Xcode project gives me the following error when trying to build to an iOS device:

    Library not found for -liPhone-lib

    How do I resolve this?

    Thanks for your help... !
     
    Last edited: Nov 24, 2019
  2. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    PS: I tried building to tvOS and, while Unity built the Xcode project without issue, in Xcode, building to an actual iOS device failed and yielded the same error.

    I've been able to successfully build to iOS on a fresh project under this same install of Unity 2019.2.13f1 so I'm not sure what's going on here. The project I'm building and getting this error with was dormant for a period and upgraded from about a March 2019 Unity version. It builds to macOS fine.

    Anyone have any ideas?
     
  3. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
  4. fredericoraiss

    fredericoraiss

    Joined:
    Aug 13, 2013
    Posts:
    17
    I had the same problem, it occurred because of a plugin I used from OneSignal, I removed it and it worked perfectly.

    Are you using any plugins? Especially that you need cocoapods? If so, you must open the xcode project from .xcworkspace and not from .xcodeproj

    I hope it helps
     
  5. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    I haven't installed any plugins and just have vanilla Xcode. I did see some other threads about opening the .xcworkspace but Unity doesn't create this when it builds the Xcode project. I tried Saving the .xcodeproj as a Workspace, quitting, and then opening the .xcworkspace and it didn't make any difference in that attempt.

    Thanks for your insight. This is super weird and a showstopper for us on iOS/tvOS...
     
  6. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    I upgraded Unity to latest today (2019.2.16f1), deleted the project's Library folder, opened it for macOS to force it to rebuild the Library folder, and it successfully created a macOS build.

    With a new Library folder, I converted it to iOS and built to Xcode. Then opening Xcode, I got the same Build Failure for the same reason, iPhone Library not found.

    'ld: library not found for -liPhone-lib

    clang: error: linker command failed with exit code 1 (use -v to see invocation)'


    Since no Workspace file was created, and having seen opening it from the Workspace can resolve this in other similar but not exact forum thread posts around the Internet and in this thread, I went to File and Save as Workspace. I created a Workspace file in the same directory as the Xcode project. I quit Xcode. I opened the Workspace file, opening Xcode and the project, which appeared identical. I tried to build...

    Fail. Same reason.

    And yet, here is the iPhone Library just as Unity built it for Xcode. I compared this with a fresh Unity project that successfully created an iOS Xcode project that built to iPhone and it was identical.



    Why is the error looking for '-liPhone-lib' when the file itself is 'libiPhone-lib'? I tried duplicating the .a archive and renaming it either '-liPhone-lib' or 'liPhone-lib' and this also failed, no help.

    Also here is the libiPhone-lib listed under General: Frameworks, Libraries, and Embedded Content:



    Also, while I didn't install any Xcode plug-ins myself, I checked anyway and forum threads say they are stored here:

    ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/

    However, the path ends at Developer. There's no Shared or Xcode folder in there.

    Someone please help... How do we resolve this?
     
    Last edited: Dec 18, 2019
  7. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    414
    Well I started fiddling with 'File > Workspace Settings'. It failed again until I set it to Legacy:



    This project was originally created in Summer 2017 with Unity then and has been maintained and upgraded with newer versions of Unity (and Xcode) ever since. But here we are...

    My only worry now is how long until Apple deprecates Legacy completely and this is no longer an option? Can Unity get to the bottom of whatever causes this with an older project and handle it during a project upgrade to a current version of Unity so it can build Xcode projects (and workspaces) correctly?

    And/or is there a way I can fix some configuration in the Unity project itself so this isn't an issue?
     
    Last edited: Dec 18, 2019
  8. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    241
    Did you take a look at Library Search Paths in the build settings?

    "-l" is a complier convention. The "lib" part of the library file name is ignored when using the "-l" arguments. But in order to use it, "-L" arguments are needed as well to tell the compiler in which paths are the libraries located. In Xcode, those "-L" argument are specified in the Library Search Paths. That setting for a typical unity project looks like this. My iOS output project is on the desktop, hence Desktop/iOS:

    upload_2019-12-19_0-38-58.png
     
    Xander-Davis likes this.
  9. jimjimimjimmy

    jimjimimjimmy

    Joined:
    Jul 11, 2013
    Posts:
    4
    same here,

    compele empty project with same error
     
unityunity