Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Xcode recursive search frameworks in project dir #28153

Merged

Conversation

DrMoriarty
Copy link
Contributor

Use case:
I have made exporting plugin as described in #11783
My frameworks placed in "res://addons/iOS/ThirdParty.framework"
The exporting plugin copied them in ProjectDir/addons/iOS/ and Xcode doesn't find them without recursive search flag.

@vini-guerrero
Copy link

Were you able to bypass this in the XCode project @DrMoriarty? Is your framework an ObjectiveC .a file? I’m working on this as well...

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero I'm using facebook sdk and many firebase related frameworks, and they works pretty well with this enhancement.

@vini-guerrero
Copy link

That’s exactly what I’m trying to achieve... Facebook login, can you provide an example on this @DrMoriarty? I got a little bit confused on how to pass/recieve variables between Godot and the .a framework (perhaps call_deferred?) To retrieve the token...

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero You can check my FB module: https://github.com/DrMoriarty/godot-facebook
The readme is outdate a little bit. It now supports iOS and Android.

@vini-guerrero
Copy link

vini-guerrero commented Apr 26, 2019

Thank you!! Do you still have to create the GDNative part / reference the framework as stated here ( #11783 ) gdnlib extension to refer this framework ? @DrMoriarty

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero The FB module has native C++ class which uses obj-c frameworks. All frameworks placed in godot-facebook/GodotFacebook/ios/ directory. Then you should make iOS export plugin (as described in #11783 ) which will copy and setup these frameworks for your iOS export project.

My export_plugin.gd is very simple:

tool
extends EditorPlugin

class MyExportPlugin:
    extends EditorExportPlugin

    func _export_begin(features, debug, path, flags):
        # Firebase libraries
        add_ios_framework("libicucore.tbd")
        add_ios_framework("res://addons/iOS/FIRAnalyticsConnector.framework")
        add_ios_framework("res://addons/iOS/FirebaseABTesting.framework")
        add_ios_framework("res://addons/iOS/FirebaseAnalytics.framework")
        add_ios_framework("res://addons/iOS/FirebaseAuth.framework")
        add_ios_framework("res://addons/iOS/FirebaseCore.framework")
        add_ios_framework("res://addons/iOS/FirebaseCoreDiagnostics.framework")
        add_ios_framework("res://addons/iOS/FirebaseDatabase.framework")
        add_ios_framework("res://addons/iOS/FirebaseFunctions.framework")
        add_ios_framework("res://addons/iOS/FirebaseInstanceID.framework")
        add_ios_framework("res://addons/iOS/FirebaseMessaging.framework")
        add_ios_framework("res://addons/iOS/FirebaseRemoteConfig.framework")
        add_ios_framework("res://addons/iOS/GTMSessionFetcher.framework")
        add_ios_framework("res://addons/iOS/GoogleAppMeasurement.framework")
        add_ios_framework("res://addons/iOS/GoogleMobileAds.framework")
        add_ios_framework("res://addons/iOS/GoogleUtilities.framework")
        add_ios_framework("res://addons/iOS/Protobuf.framework")
        add_ios_framework("res://addons/iOS/leveldb-library.framework")
        add_ios_framework("res://addons/iOS/nanopb.framework")
        add_ios_linker_flags("-ObjC")
        add_ios_bundle_file("res://addons/iOS/GoogleService-Info.plist")
        # Facebook libraries
        add_ios_framework("res://addons/iOS/Bolts.framework")
        add_ios_framework("res://addons/iOS/FBSDKCoreKit.framework")
        add_ios_framework("res://addons/iOS/FBSDKLoginKit.framework")
        add_ios_framework("res://addons/iOS/FBSDKShareKit.framework")
        add_ios_plist_content("""
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb267317697516060</string>
            </array>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>CFBundleURLName</key>
            <string>ru.ok</string>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>267317697516060</string>
    <key>FacebookDisplayName</key>
    <string>Galactic Adventure</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string>
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fb-messenger-api20140430</string>
    </array>""")
        # Fabric & Crashlytics
        add_ios_framework("res://addons/iOS/Fabric.framework")
        add_ios_framework("res://addons/iOS/Crashlytics.framework")
        # Performance
        add_ios_framework("res://addons/iOS/GoogleToolboxForMac.framework")
        add_ios_framework("res://addons/iOS/FirebasePerformance.framework")
        # Encryption
        add_ios_plist_content("<key>ITSAppUsesNonExemptEncryption</key><false/>")
        # Notifications
        add_ios_framework("UserNotifications.framework")

func _init():
    add_export_plugin(MyExportPlugin.new())

func _enter_tree():
    pass

func _exit_tree():
    pass

@vini-guerrero
Copy link

Oh I understand now! So, no GDNative required acctually... thanks a lot @DrMoriarty!

@vini-guerrero
Copy link

Did you need a developer account to test local device @DrMoriarty ?
Placed the Godot-Facebook module inside the Addons folder:

image

I got some issues with linker:

image

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero No, you should use this module when rebuild iOS template. Copy GodotFacebook folder to godot/modules. Then rebuild template as described in http://docs.godotengine.org/en/3.1/development/compiling/compiling_for_ios.html

@vini-guerrero
Copy link

@DrMoriarty I thought the reason of ( #11783 ) ( Similar to 3.2 Android Custom Modules Feature ) was not having anymore the need of re-compiling the engine since modules could be added via .gd ( So frameworks such as Facebook will be in both res://addons// and godot/modules ) I'm asking because I've been also working on a few custom iOS modules.

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero As far as I know #11783 can add any frameworks to your project but it doesn't add you any gd script interface to it.
Some times it enough. For example, when you add crashlytics or firebase performance tool. But for FB you need some wrapper between gd code and objective-c code.

@vini-guerrero
Copy link

Makes sense now, thanks for the explanation @DrMoriarty Hopefully some future release allows custom modules thru editor on iOS as well...

@vini-guerrero
Copy link

@DrMoriarty took the opportunity to go on and test your commit ( applied the changes on 3.1 )

Facebook Module

Compiling ( all 3 archs ) -> Worked
Exporting the XCode Solution in Godot -> Worked
Fixing Dependencies and Compiling in XCode - Worked
Running the ipa on a real device ( debug version ) -> Crashes When Opening Up

Here's the Godot script ( basic scene ) with this attached:
https://gist.github.com/vini-guerrero/9bff41839bd6f3e376d6428bb66cadf1

The XCode part worked pretty well with recursive as it got compiled.
Maybe I'm doing something wrong in the module?
Here's my compiling guide > https://gist.github.com/vini-guerrero/f55cc074f4ba72adcd37de0128404ff4

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero could you show the run log from Xcode?

@vini-guerrero
Copy link

Do you have discord or slack @DrMoriarty ? When I ran on XCode it didn't print anything, after unpluggin it crashed.

@vini-guerrero
Copy link

Finally, got the logs pulled out, @DrMoriarty :

2019-04-26 20:55:05.232076-0300 xcodesolution[15425:4898841] [DYMTLInitPlatform] platform initialization successful *********** main.m running app main Path: /var/containers/Bundle/Application/CA552FAA-B116-4FE0-A167-4B181FF2E0E1/xcodesolution.app godot_iphone /var/containers/Bundle/Application/CA552FAA-B116-4FE0-A167-4B181FF2E0E1/xcodesolution.app/xcodesolution cwd /private/var/containers/Bundle/Application/CA552FAA-B116-4FE0-A167-4B181FF2E0E1/xcodesolution.app os created setting data dir to /var/mobile/Containers/Data/Application/BAC3329D-3080-441C-90F3-BDBEA38DA97E/Documents from /var/mobile/Containers/Data/Application/BAC3329D-3080-441C-90F3-BDBEA38DA97E/Documents setup 0 after init super 0x15dd148b0 2019-04-26 20:55:05.678696-0300 xcodesolution[15425:4898674] Metal GPU Frame Capture Enabled 2019-04-26 20:55:05.679314-0300 xcodesolution[15425:4898674] Metal API Validation Enabled 2019-04-26 20:55:05.833445-0300 xcodesolution[15425:4898674] Setting up an OpenGL ES 2 context. Based on Project Settings "rendering/quality/driver/driver_name" ******** screen size 640, 1136 after init gles 0x15dd148b0 ******** adding observer for sound routing changes ******** adding observer for keyboard show/hide cadisaplylink: 1start animation! ******** screen size 640, 1136 2019-04-26 20:55:05.865977-0300 xcodesolution[15425:4898674] OpenGL ES 2.0 Renderer: Apple A10 GPU OpenGL ES 2.0 Renderer: Apple A10 GPU 2019-04-26 20:55:06.038686-0300 xcodesolution[15425:4898674] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2019-04-26 20:55:06.079817-0300 xcodesolution[15425:4898674] [MC] Reading from public effective user settings. 2019-04-26 20:55:06.850030-0300 xcodesolution[15425:4898674] FBSDKLog: Missing [FBSDKAppEvents appID] for [FBSDKAppEvents publishInstall:] 2019-04-26 20:55:06.850832-0300 xcodesolution[15425:4898674] FBSDKLog: Missing [FBSDKAppEvents appEventsState.appID] for [FBSDKAppEvents flushOnMainQueue:] 2019-04-26 20:55:06.850870-0300 xcodesolution[15425:4898674] FBSDKLog: Missing [FBSDKAppEvents appEventsState.appID] for [FBSDKAppEvents flushOnMainQueue:] 2019-04-26 20:55:07.719343-0300 xcodesolution[15425:4898674] +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x244b07f40 2019-04-26 20:55:07.720227-0300 xcodesolution[15425:4898674] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x244b07f40' *** First throw call stack: (0x20b1a8518 0x20a3839f8 0x20b0ca2c4 0x20b1add60 0x20b1af9fc 0x1021ce844 0x1021cd1d4 0x20b091e1c 0x1021ccf04 0x1021cc248 0x1021ca3dc 0x105c7f6f0 0x105c80c74 0x105c8e6fc 0x20b139ec0 0x20b134df8 0x20b134354 0x20d33479c 0x23771fb68 0x1021fcef0 0x20abfa8e0) libc++abi.dylib: terminating with uncaught exception of type NSException

image

@DrMoriarty
Copy link
Contributor Author

@vini-guerrero it looks like your app didn't linked against FBSDKCoreKit.framework

@vini-guerrero
Copy link

@DrMoriarty weird is that it didn’t show any error during compile and the CoreKit.framework is inside the solution folder. 🤔 Another weird behavior is that even with this framework files inside the Godot project, it still requires pointing at them later on in XCode...

@akien-mga akien-mga requested a review from samgreen April 30, 2019 08:17
@DrMoriarty
Copy link
Contributor Author

@vini-guerrero just thought about that, did you add -ObjC linker flag?

@vini-guerrero
Copy link

Hi @DrMoriarty, I did added the flag, however it did not find the frameworks on the first try, I even tried downloading the sdk (newest from fb source) and include manually... I tried referencing the sdk within the module folder, XCode says dependencies are fixed, but I couldn’t solve that error... maybe I'm doing something wrong, not sure, still researching on how to do it.

@atologist-pratik
Copy link

@vini-guerrero have you find out whats the issue? have you complete FB login integration?

@vini-guerrero
Copy link

@atologist-pratik still having the same issue =/ I know that the problem is XCode not linking the library itself, but inside XCode it shows ok, but when you compile it throws that error, so I'm not sure what is the proper way to link this lib.

@mhilbrunner
Copy link
Member

Hey! Thanks for this. This looks good to me, but it should go against the master branch, not 3.1, as it is valid for all future versions; we then can decide if it should get backported to 3.1.

@DrMoriarty DrMoriarty force-pushed the recursive-framework-search-paths branch from e1acfbf to 6419227 Compare May 14, 2019 16:12
@DrMoriarty DrMoriarty changed the base branch from 3.1 to master May 14, 2019 16:13
@DrMoriarty
Copy link
Contributor Author

@mhilbrunner done

@mhilbrunner
Copy link
Member

Thanks again!

@mhilbrunner mhilbrunner merged commit 256bac6 into godotengine:master May 14, 2019
@akien-mga
Copy link
Member

Cherry-picked for 3.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants