6 Replies
      Latest reply on Jul 24, 2015 9:18 AM by comptonsw
      cypher Level 1 Level 1 (0 points)

        There are many third party libraries out there with complex shell scripts to build them (OpenSSL comes to mind which is explicitly recommended by Apple for users to build themselves in the Security session from WWDC). Xcode 7 beta 3 has now made it a hard requirement to build at all for WatchOS that every piece of code must enable Bitcode. That's fine except AFAICT absolutely nothing has been published about all the edge cases here like such libraries.

         

        I have managed to sniff out "-fembed-bitcode-marker" as one of the compiler flags needed to do this from a shell script. That actually makes such libraries pass the Xcode WatchOS Bitcode requirement. However, Xcode then starts outputting a new warning implying there is some additional step I'm not aware of:

         

        ld: warning: full bitcode bundle could not be generated because 'xx/libcrypto.a(bn_lib.o)' was built only with bitcode marker. The library must be generated from Xcode archive build with bitcode enabled (Xcode setting ENABLE_BITCODE)
        

         

        I don't know what this means. I told the compiler to add Bitcode. It did. Clearly, I'm missing some additional magic parameter that only the Bitcode gods know. I've compared the build commands between the Xcode default WatchOS static library project and the shell script and I'm not coming up with the answer. It seems a bit premature to make these hard requirements when this information is not available. Beta 2 had an easy bypass.

        • Re: ENABLE_BITCODE equivalent from shell scripts
          fealebenpae Level 1 Level 1 (10 points)

          What you need is -fembed-bitcode. When ENABLE_BITCODE is enabled, Xcode builds with -fembed-bitcode-marker for regular builds and with -fembed-bitcode for archive builds.

          One option simply "marks" where the bitcode would be in the binary after an archive build and enforces the new bitcode rules, while the other actually does the full-on bitcode generation, which is likely slower and thus not enabled on every kind of build.

            • Re: ENABLE_BITCODE equivalent from shell scripts
              cypher Level 1 Level 1 (0 points)

              -fembed-bitcode did work.

               

              Oddly though, Xcode fails with a fatal error claiming the Watch app is not signed when doing Archive builds with the Bitcode version of the third party library. Whereas, if I swap back in the Bitcode Marker version of the library, Xcode returns to a Warning state about not being able to build a complete Bitcode binary but allows the Archive build to complete. Submitting the Archive build with the Bitcode marker to the App Store though does fail with cryptic errors, so I assume it's looking for complete Bitcode.

               

              At this point I'm trying to ignore the issue. I think the fix is correct, but presume Xcode B3 bugs are preventing the final steps of Archive and Submit.

              • Re: ENABLE_BITCODE equivalent from shell scripts
                comptonsw Level 1 Level 1 (0 points)

                Sorry for the dumb question - how do I add this switch in Xcode?

              • Re: ENABLE_BITCODE equivalent from shell scripts
                Danoli3 Level 1 Level 1 (0 points)

                One side effect I have noticed is an increased binary size of static libraries that are using bitcode. I have a library I build that is 80MB normally however with bitcode embedded this is now 178MB.

                • Re: ENABLE_BITCODE equivalent from shell scripts
                  Level 1 Level 1 (0 points)

                  Is there something I'm missing? I can't get archive builds to work. I get the error : ld: warning: ignoring file X, file was built for archive which is not the architecture being linked (arm64). I've tried with a separate c library I compiled myself (has a simple multiplication function), and get the same result, so I don't think it's the library I'm using. I'm iust going up to product > archive, is that correct? I have a free provisioning profile, but I doubt that's the problem since I can archive without the extra library.

                    • Re: ENABLE_BITCODE equivalent from shell scripts
                      Level 1 Level 1 (0 points)

                      I just built a library in Xcode and realized that it builds for architectures of armv7 and arm64 when you make a bitcode library. I'm assuming this is why mine isn't working, as I was only using an armv7 bitcode library. However, I thought the whole purpose of bitcode was to eliminate fat binaries/libraries. Can someone explain what I'm misinterpreting?