+ // Check dylib for bitcode, if the library install path is relative path or @rpath, it has to contain bitcode
+ if ( _options.bundleBitcode() ) {
+ bool isSystemFramework = ( dylibFile->installPath() != NULL ) && ( dylibFile->installPath()[0] == '/' );
+ if ( dylibFile->getBitcode() == NULL && !isSystemFramework ) {
+ // Check if the dylib is from toolchain by checking the path
+ char tcLibPath[PATH_MAX];
+ char ldPath[PATH_MAX];
+ char tempPath[PATH_MAX];
+ uint32_t bufSize = PATH_MAX;
+ // toolchain library path should pointed to *.xctoolchain/usr/lib
+ if ( _NSGetExecutablePath(ldPath, &bufSize) != -1 ) {
+ if ( realpath(ldPath, tempPath) != NULL ) {
+ char* lastSlash = strrchr(tempPath, '/');
+ if ( lastSlash != NULL )
+ strcpy(lastSlash, "/../lib");
+ }
+ }
+ // Compare toolchain library path to the dylib path
+ if ( realpath(tempPath, tcLibPath) == NULL ||
+ realpath(dylibFile->path(), tempPath) == NULL ||
+ strncmp(tcLibPath, tempPath, strlen(tcLibPath)) != 0 ) {
+ switch ( _options.platform() ) {
+ case Options::kPlatformOSX:
+ case Options::kPlatformUnknown:
+ warning("all bitcode will be dropped because '%s' was built without 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.path());
+ _internal.filesWithBitcode.clear();
+ _internal.dropAllBitcode = true;
+ break;
+ case Options::kPlatformiOS:
+ throwf("'%s' 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.path());
+ break;
+ case Options::kPlatformWatchOS:
+#if SUPPORT_APPLE_TV
+ case Options::kPlatform_tvOS:
+#endif
+ throwf("'%s' does not contain bitcode. "
+ "You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE) or obtain an updated library from the vendor", file.path());
+ break;
+ }
+ }
+ }
+ // Error on bitcode marker in non-system frameworks if -bitcode_verify is used
+ if ( _options.verifyBitcode() && !isSystemFramework &&
+ dylibFile->getBitcode() != NULL && dylibFile->getBitcode()->isMarker() )
+ throwf("bitcode bundle could not be generated because '%s' was built without full bitcode. "
+ "All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build",
+ dylibFile->path());
+ }
+