11 Replies
      Latest reply on Apr 2, 2020 11:30 AM by edford
      robby28 Level 1 Level 1 (0 points)

        In Xode 11.4, I encounter a failure in my project.

        When running my project, it was successfull in Xcode 11.3. Now in Xcode 11.4 I get the failure message:

        Target Integrity: Building for ios simulator but the linked library ' my_library.a ' was built for may OS + ios.

         

        The library " my_library.a is pointed to architecture: x86_64 and arm64 and never changed

        I can run the Project on my device, but it is not running in the simulator.

         

        Please help me what to do in Xcode 11.4. Do I have to change settings in Xcode 11.4.

         

        regards, Robert

        • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
          chzhij5 Level 1 Level 1 (0 points)

          I have the same problem.

           

          "error: Building for iOS Simulator, but the linked library 'lib.a' was built for iOS.  "

           

          We have some lib only used in generic device and would not called in Simulator. It was work in Xcode 11.3, but not in Xcode 11.4.

           

          I can use the legacy build system to resolve this error. But I think it's not the good solution.

          • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
            edford Apple Staff Apple Staff (865 points)

            Having x86_64 code is not sufficient to distinguish if a binary is intended for the iOS Simulator, a macOS app, or a Mac Catalyst app. Combing built binaries across different destinations (which includes the simulator vs. device binaries) is not a supported combination -- there is no Apple platform where ARM code and x86_64 code in the same binary is a correct configuration.

             

            If this is your library, you should have your app build it from source as a dependency of your Xcode project, either through an Xcode target or through Swift Package Manager, so that the right platform information is included based on the build target.

             

            If this is your library but you have a specific reason for it to be pre-compiled, please build it as an XCFramework. XCFrameworks correctly separate out binaries that have the right architectures for the different platforms you target. In addition to instructions on how to build such a XCFramework linked earlier, we have a WWDC talk illustrating it.

             

            If this library is from a framework vendor (either as source or a pre-compiled binary), or you integrate a vendor's library into your app with a third party dependency manager, please consult with the library vendor or dependency manager for support.

              • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
                fkoebel Level 1 Level 1 (0 points)

                in case your project is only targeting iOS + iOS simulator it should be sufficient if your dependencies are recompiled with Xcode 11, like edford mentioned it in another thread (https://forums.developer.apple.com/thread/117346)

                • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
                  robby28 Level 1 Level 1 (0 points)

                  Thanks for the info.

                  But I did not get the library running by changes in Xcode settings. So, I tried to recompile it in xcode 11.4

                  The library is a static C-Library. . So, c-code has to be compiled and linked. I have done it before and library was running in Xcode 11.3

                   

                  in the MAKE file I adjusted:

                  CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

                  CFLAGS = -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk

                  When I run it, I receive a new library. This library is arch: X86_64 and arm64

                  But even with this new created library in my project  I get the same mistake:

                  "Building for ios simulator , but the linked library was build for macOS + ios

                   

                  Then I changed the CFLAGS to the iphone simulator platform:

                  CFLAGS = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk

                   

                  Problem is that I do not know what is the arch for the Simulator ?

                   

                  Can You help me to adjust the CFLAGS settings or other adjustments in the MAKE File to receive a library accepted by the simulator ?

                  Thanks, Robert

                  • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
                    Smithers Level 1 Level 1 (5 points)

                    That hasn't helped me. I've rebuilt my libraries (forked existing libraries that weren't supported anymore, imported them into Xcode 11.4) - I can still run the app just fine on the device but building for the simulator fails every time with the same error.

                      • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
                        edford Apple Staff Apple Staff (865 points)

                        What xcodebuild command did you use to rebuild the libraries?

                          • Re: Xcode 11.4 : Building for iOS Simulator but the linked library was built for Mac OS + iOS
                            robby28 Level 1 Level 1 (0 points)

                            In Your answer before, You adviced me to create the library through an xcode project or a Swift package..

                             

                            I give you first here the info, how I have done it actually

                            To create the library , I did the following steps:

                            I have some -.c files that have to be compiled and linked to get the library.

                            for all that I use the Terminal :

                            1. I gave the -.c files in a folder  /usr/local/f2c/libf2c

                            2. I modified the makefile on CC and CFLAGS to adjust for the Xcode settings

                            here some extracts of the makefile:

                            .SUFFIXES: .c .o

                            CC = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc"

                            SHELL = /bin/sh

                            CFLAGS = -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.4.sdk

                             

                            # compile, then strip unnecessary symbols

                            .c.o:

                              $(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c.  # HERE the COMPILING starts

                              ld -r -x -o $*.xxx $*.o

                              mv $*.xxx $*.o

                            .....

                            all: f2c.h signal1.h sysdep1.h libf2c.a

                            ........

                             

                            libf2c.a: $(OFILES)

                              ar r libf2c.a $?

                              -ranlib libf2c.a

                            3. I call ' make ' in the terminal and then the sript is running

                            Result is a library called : libf2c.a

                            to check the library by :  lipo -info libf2c.a

                            this library is architecture X86_64 and arm64, same as before, when I created it with previous MAC and Xcode versions

                             

                            But even the library is now created by MAC OS 10.15.4 and Xcode 11.4, the error message is the same:

                            "Building for ios Simultor but the linked library 'libf2c.a' was build for mac OS + ios

                             

                            If you want, then I can ship You all the c-files and the makefile, to that you can reproduce the creation of the library.

                             

                            What shold be the solution to create a library running in Xcode 11.4 , both in Simulator and on device, same as before ?

                            You adviced to do it in a xcode project, but How can I do all the works inside a xcode project or from a swift package, when I have native C-code ? In my Xcode project, i just inserted the library and it was working. But no more in Xcode 11.4