extender
extender copied to clipboard
Path to Mac SDK missing when building for osx with Cocoapods
Attempting to build extension-firebase for osx (adding a Podfile, allowing firebase_ios.mm to also build for DM_PLATFORM_OSX) fails with errors such as:
In file included from CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Delay.m:17:
In file included from CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Delay.h:17:
In file included from CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise.h:17:
CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromiseError.h:17:9: fatal error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
Examining the logs for the failed build, a typical compiler invocation looks like this:
Log from osx extension-firebase build
clang++ -c -DDLIB_LOG_DOMAIN="PROMISESOBJC" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_MACOS -DDM_PLATFORM_OSX -DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -DDM_DEBUG -fobjc-arc --language=objective-c -fmodules -fmodule-name=FBLPromises -fmodule-map-file=/var/folders/ny/05wk595149v2zs2zz5jtwct40000gn/T/job8963115461759210323/CocoaPodsService/generated/PromisesObjC/module.modulemap -Iupload/ -Iupload/firebase/include/ -ICocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/include/ -ICocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/ -ICocoaPodsService/Pods/PromisesObjC/ -ICocoaPodsService/generated/PromisesObjC/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Privacy/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Environment/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Environment/Public/ -ICocoaPodsService/Pods/GoogleUtilities/third_party/IsAppEncrypted/Public/ -ICocoaPodsService/Pods/GoogleUtilities/third_party/IsAppEncrypted/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Environment/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Logger/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Logger/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Logger/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/UserDefaults/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/UserDefaults/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/UserDefaults/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/NSData+zlib/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/NSData+zlib/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/NSData+zlib/ -ICocoaPodsService/Pods/FirebaseCoreInternal/ -ICocoaPodsService/generated/FirebaseCoreInternal/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/Public/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/Public/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Extension/ -ICocoaPodsService/Pods/FirebaseCore/ -ICocoaPodsService/generated/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsIDController/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Public/FirebaseInstallations/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Public/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Private/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsAPI/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Errors/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/IIDMigration/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsStore/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseCore/Extension/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseInstallations/ -ICocoaPodsService/generated/FirebaseInstallations/ -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//include -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//sdk/include -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//ext/include CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Do.m -obuild/FBLPromise+Do.m_7.owhereas the equivalent for a successful iOS build is:
Log from ios extension-firebase build
clang++ -c -arch arm64 -target arm-apple-darwin19 -m64 -O2 -g -stdlib=libc++ -miphoneos-version-min=11.0 -isysroot /usr/local/extender-stage/platformsdk/iPhoneOS16.2.sdk -nostdinc++ -DDLIB_LOG_DOMAIN="PROMISESOBJC" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_IOS -DDM_DEBUG -fobjc-arc --language=objective-c -fmodules -fmodule-name=FBLPromises -fmodule-map-file=/var/folders/2b/mpxyl1m54jvg2rcs2cnbsqxc0000gn/T/job9297218435465495137/CocoaPodsService/generated/PromisesObjC/module.modulemap -Iupload/ -Iupload/firebase/include/ -ICocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/include/ -ICocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/ -ICocoaPodsService/Pods/PromisesObjC/ -ICocoaPodsService/generated/PromisesObjC/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Privacy/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Environment/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Environment/Public/ -ICocoaPodsService/Pods/GoogleUtilities/third_party/IsAppEncrypted/Public/ -ICocoaPodsService/Pods/GoogleUtilities/third_party/IsAppEncrypted/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Environment/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Logger/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/Logger/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/Logger/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/UserDefaults/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/UserDefaults/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/UserDefaults/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/NSData+zlib/Public/GoogleUtilities/ -ICocoaPodsService/Pods/GoogleUtilities/GoogleUtilities/NSData+zlib/Public/ -ICocoaPodsService/Pods/GoogleUtilities/ -ICocoaPodsService/generated/NSData+zlib/ -ICocoaPodsService/Pods/FirebaseCoreInternal/ -ICocoaPodsService/generated/FirebaseCoreInternal/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/Public/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/Public/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Sources/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseCore/FirebaseCore/Extension/ -ICocoaPodsService/Pods/FirebaseCore/ -ICocoaPodsService/generated/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsIDController/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Public/FirebaseInstallations/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Public/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Private/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsAPI/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/Errors/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/IIDMigration/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/Library/InstallationsStore/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseInstallations/Source/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseCore/Extension/ -ICocoaPodsService/Pods/FirebaseInstallations/FirebaseCore/ -ICocoaPodsService/Pods/FirebaseInstallations/ -ICocoaPodsService/generated/FirebaseInstallations/ -ICocoaPodsService/frameworks/headers/arm64-ios/ -F/var/folders/2b/mpxyl1m54jvg2rcs2cnbsqxc0000gn/T/job9297218435465495137/CocoaPodsService/frameworks/lib/arm64-ios -I/usr/local/extender-stage/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//include -I/usr/local/extender-stage/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//sdk/include -I/usr/local/extender-stage/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//ext/include CocoaPodsService/Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Do.m -obuild/FBLPromise+Do.m_7.oI'm suspicious that a path to the Mac SDK is not specified with -isysroot, which would normally be the case, i.e. this is an empty objective-c file being built for osx in a test project:
Log from osx non-podfile objective-c file compile
clang++ -c -isystem /usr/local/extender/platformsdk/MacOSX13.1.sdk/usr/include/c++/v1 -DDLIB_LOG_DOMAIN="DEFOLDIMGUI" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_MACOS -DDM_PLATFORM_OSX -DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -O2 -g -stdlib=libc++ -mmacosx-version-min=10.13 -isysroot /usr/local/extender/platformsdk/MacOSX13.1.sdk -nostdinc++ -fno-exceptions -fvisibility=hidden -Werror=format -arch arm64 -target arm64-apple-darwin19 -m64 -Iupload/imgui/include/ -Ibuild/imgui/ -Iupload/ -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//include -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//sdk/include -I/usr/local/extender/sdk/37a4a8548850a7243055bb820e45580cfdae5f32/defoldsdk//ext/include upload/imgui/src/empty_file.m -obuild/empty_file.m_0.oNB this is when running a local standalone server, on this commit
Did you specify Foundation for osx platform similar way?
Yes I tried that. My suspicion is there's something particular to Cocoapods, similar to this https://github.com/defold/extender/blob/06b486ad28b37e38376ae7504c8835ed4e0f5f61/server/src/main/java/com/defold/extender/Extender.java#L846-L853
The osx build does not include a -isysroot. Not sure why yet.
I'm confused. I don't see any of these flags in the osx build:
https://github.com/defold/defold/blob/dev/share/extender/build_input.yml#L131
I get the flags, including sysroot, but I'm missing the cocoapod includes, which perhaps says they're not resolved:
clang++ -c -isystem /Users/mathiaswesterdahl/work/extender/localserver/platformsdk/MacOSX14.2.sdk/usr/include/c++/v1 -DDLIB_LOG_DOMAIN="FIREBASEEXT" -DDDF_EXPOSE_DESCRIPTORS -DDM_PLATFORM_MACOS -DDM_PLATFORM_OSX -DGL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -DDM_DEBUG -O2 -g -stdlib=libc++ -mmacosx-version-min=10.13 -isysroot /Users/mathiaswesterdahl/work/extender/localserver/platformsdk/MacOSX14.2.sdk -nostdinc++ -fno-exceptions -fvisibility=hidden -Werror=format -arch arm64 -target arm64-apple-darwin19 -m64 -Iupload/firebase/include/ -Ibuild/firebase/ -Iupload/ -I/Users/mathiaswesterdahl/work/defold/tmp/dynamo_home//include -I/Users/mathiaswesterdahl/work/defold/tmp/dynamo_home//sdk/include -I/Users/mathiaswesterdahl/work/defold/tmp/dynamo_home//ext/include upload/firebase/src/firebase_ios.mm -obuild/firebase_ios.mm_3.o
Yeah, once I resolved the pods, it triggers the source build for the cocoapods, and it doesn't seem to use the command line that the rest of the build system is using.
The culprit is in the cocopod builder, which deletes all flags:
// clean up flags from context
Map<String, Object> trimmedContext = ExtenderUtil.mergeContexts(manifestContext, new HashMap<>());
trimmedContext.put("flags", new ArrayList<String>());
And, since the platforms are setup slightly differently in our build config, you will then get different results:
FBLPromise+All.m
macOS:
CMD: clang++ -c {{#systemIncludes}}-isystem {{{.}}} {{/systemIncludes}} {{#defines}}-D{{{.}}} {{/defines}} {{#flags}}{{{.}}} {{/flags}} {{#ext.includes}}-I{{{.}}} {{/ext.includes}} {{#ext.frameworkPaths}}-F{{{.}}} {{/ext.frameworkPaths}} {{#includes}}-I{{{.}}} {{/includes}} {{src}} -o{{tgt}}
iOS:
CMD: clang++ -c -arch arm64 -target arm-apple-darwin19 -m64 -O2 -g -stdlib=libc++ -miphoneos-version-min={{osMinVersion}} -isysroot {{env.SYSROOT}} -nostdinc++ {{#systemIncludes}}-isystem {{{.}}} {{/systemIncludes}} {{#defines}}-D{{{.}}} {{/defines}} {{#flags}}{{{.}}} {{/flags}} {{#ext.includes}}-I{{{.}}} {{/ext.includes}} {{#ext.frameworkPaths}}-F{{{.}}} {{/ext.frameworkPaths}} {{#includes}}-I{{{.}}} {{/includes}} {{#platformIncludes}}-I{{.}} {{/platformIncludes}} {{src}} -o{{tgt}}
Which then ofc adds the isysroot flag to iOS but not macOS.
Question is what reason in particular that the "flags" field was cleared, as it sidesteps the build system. I need @britzl to help clarify this.
I can of course modify the defold sdk so that the sysroot flag is part of the base flags, as a fix. However, it feels like we might need a more robust fix for this, so we don't accidentally break this in the future again.