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

[PRIORITY] New iOS Plugin for 3.2.4/4.0 #27

Closed
gumaciel opened this issue Dec 18, 2020 · 107 comments
Closed

[PRIORITY] New iOS Plugin for 3.2.4/4.0 #27

gumaciel opened this issue Dec 18, 2020 · 107 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gumaciel
Copy link
Contributor

gumaciel commented Dec 18, 2020

Soon Godot will receive the new Plugin System as Android: godotengine/godot#41230
godotengine/godot#41340

The goal of this repository is being updated with the newest version of Godot, and this new Plugin System for iOS is very welcomed because will be more easy to develop for iOS.

Tutorial: ?

@gumaciel gumaciel added the enhancement New feature or request label Dec 18, 2020
@gumaciel gumaciel self-assigned this Dec 18, 2020
@gumaciel gumaciel pinned this issue Dec 18, 2020
@gumaciel gumaciel added help wanted Extra attention is needed iOS labels Dec 18, 2020
@bashcole
Copy link

bashcole commented Jan 7, 2021

Does anyone have news when we can expect this to happen? Do we have to wait for Godot 4.0?

@gumaciel
Copy link
Contributor Author

gumaciel commented Jan 7, 2021

hey @war1an , we will not need to wait for Godot 4.0, but I talked to the iOS plugin's creator and probably will only happen on 3.2.5 version or with lucky on 3.2.4 (I would give about 1 ~ 5 months to this happen), i'm studying how we can do this when a beta version comes, for now we still need to use "modules"

To use AdMob on Godot iOS, check the tutorial here: https://github.com/Poing-Studios/Godot-AdMob-Android-iOS#ios-v300

@naithar
Copy link

naithar commented Jan 16, 2021

Since godotengine/godot#41340 has been merged, I think you can start working on migrating module to plugin.
Since you have updated the code to work with 3.2.4 beta everything should be pretty straightforward.
The next 3.2.4 beta 6 should be pretty soon.

@bashcole
Copy link

I was just reading the highlights of the beta 6 update when I saw iOS plugins support I'm very excited! Thank you guys for the hard work @naithar and @gustavottc for the Admob plugin! This system is a very welcome change.

@gumaciel
Copy link
Contributor Author

hey @naithar , what a coincidence! i'm going to start working on the plugins now, yesterday i finished the UMP for Android and iOS and was about to start the plugin for iOS

I just found beta6 here: https://downloads.tuxfamily.org/godotengine/3.2.4/beta6/

i should consider this PR too? godotengine/godot#43557 or just the godotengine/godot#41340?

@naithar
Copy link

naithar commented Jan 16, 2021

godotengine/godot#43557 wouldn't give you any benefit really, since you don't seem to be using anything that's related to AppDelegate. But I have a PushNotification plugin example, that might be of some use if you require extending default AppDelegate.

@gumaciel
Copy link
Contributor Author

@naithar , Xcode is giving me this error: 'GoogleMobileAds/GoogleMobileAds.h' file not found

I already place the folder of frameworks inside "Header Search Paths":
Captura de Tela 2021-01-16 às 20 49 08

Tried recursive and non-recursive btw

What's inside the folder:
Captura de Tela 2021-01-16 às 20 49 50

@gumaciel
Copy link
Contributor Author

And i use AppDelegate

Captura de Tela 2021-01-16 às 20 51 16

But if some error appear due app_delegate i will check this repo: https://github.com/naithar/godot_ios_plugin_apns

@gumaciel
Copy link
Contributor Author

A strange thing is this: the frameworks are added and i didn't link:

Captura de Tela 2021-01-16 às 20 58 34

I also added the path into Library Search Path, Header Search Path and Framework Search Path

Tried clean, build, restart Xcode and nothing

@gumaciel
Copy link
Contributor Author

gumaciel commented Jan 17, 2021

Nvm, i fixed: Need to put the link on "Framework Search Path" and make recursive for .xcframework "$(SRCROOT)/lib/GoogleMobileAds.xcframework"

@gumaciel
Copy link
Contributor Author

gumaciel commented Jan 17, 2021

Captura de Tela 2021-01-16 às 22 51 54
@naithar everything great, except for this: the '.a' is from Xcode build

ps = the plugin_example works fine, and this project worked fine too until i try to put the GoogleMobileAds framework

edit: it's working with SCons but on Xcode it's giving this error yet

@gumaciel
Copy link
Contributor Author

@war1an @brendonion please try it out if you guys want to

admob_plugin.zip

Need to: Create a folder called "ios/plugins" and place the content inside this ".zip" into this folder, will be like that:
Captura de Tela 2021-01-16 às 23 06 10

And then into Export Project:
Captura de Tela 2021-01-16 às 23 07 14

After that, do these steps: https://github.com/Poing-Studios/Godot-AdMob-Android-iOS/tree/iOS-Plugin#ios-v300 right on "Add the following frameworks to the project linking"

@gumaciel
Copy link
Contributor Author

@naithar , btw i'm using some frameworks like: JavaScriptCore and all frameworks by GoogleMobileAdsSdk (GoogleMobileAds, User Messaging Platform etc...)

I'm also editing the ".plist", adding these:

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>SKAdNetworkItems</key>
  <array>
    <dict>
      <key>SKAdNetworkIdentifier</key>
      <string>cstr6suwn9.skadnetwork</string>
    </dict>
  </array>

I need to put these things on the ".gdip" file?

Captura de Tela 2021-01-16 às 23 19 26

Actually it's working editing directly inside Xcode project

@bashcole
Copy link

@gustavottc I downloaded Godot_v3.2.4-beta6_osx.universal.zip. Created the ios/plugin folder and unzip the content inside (wouldn't be better if the plugin has it's folder like ios/plugin/admob ?). Downloaded the iOS the export template but I don't have a plugin section inside the settings.

Screenshot 2021-01-17 at 8 52 18

Screenshot 2021-01-17 at 8 52 36

Screenshot 2021-01-17 at 8 53 26

@naithar
Copy link

naithar commented Jan 17, 2021

@war1an plugins can be placed inside admob directory to make grouping better. Also plugin is looking for libadmob_plugin.a, not libadmob.plugin.a so renaming should fix it for you.

@gustavottc under linked, embedded and system you can list frameworks so that plugin users wouldn't have to place libraries manually in their project. Some things might not work that good (like making framework optional), but should cover some use cases.
plist section currently supports only string values, so there is no way to automate .plist modification in your case.

@naithar
Copy link

naithar commented Jan 17, 2021

@gustavottc you might also want to include support for both release and debug configurations. This is done by compiling libraries with both configurations and naming them as <lib_name>.release.a and <lib_name>.debug.a.

@gumaciel
Copy link
Contributor Author

gumaciel commented Jan 17, 2021

I did it, but Godot is giving me this error: Invalid plugin config file admob_plugin.gdip

Captura de Tela 2021-01-17 às 09 59 42

And do you know how to solve this error? #27 (comment) only appear when Xcode builds

And when Xcode builds, he do a single binary file with release a debug for all platform(x86_64, armv7, arm64)?

@war1an please try with this example project: https://github.com/Poing-Studios/Godot-AdMob-Android-iOS/tree/master/example, and also please change the .gdip file that naithar mentioned above, was a mistake mine

@naithar
Copy link

naithar commented Jan 17, 2021

I did it, but Godot is giving me this error: Invalid plugin config file admob_plugin.gdip

There is no need to change binary value. Godot will handle different targets himself, just provide correctly named static libraries. If binary is libadmob_plugin.a, you should just place libadmob_plugin.release.a and libadmob_plugin.debug.a next to the .gdip file.

And do you know how to solve this error? #27 (comment) only appear when Xcode builds

Seems like you need to exclude specific architectures when building with Xcode.

And when Xcode builds, he do a single binary file with release a debug for all platform(x86_64, armv7, arm64)?

Xcode creates a single binary for targeted platform and configuration that you've specified. If you build for debug device, it will result in such. But every library will use the same name overriding the last one.
You should probably use scons, since Xcode might be doing something that's not really needed for Godot's plugin.

@naithar
Copy link

naithar commented Jan 17, 2021

Also note that debug Godot's template is actually a template built with release_debug target (which you can probably guess from the library size), so you might want to change SConstruct file accordingly or wait until I finish migration for builtin plugins godotengine/godot#45252.

@bashcole
Copy link

bashcole commented Jan 17, 2021

@gustavottc
I added all framework but I can't run the project successfully.

The first error was:

*********** main.m
running app main
2021-01-17 15:47:04.069186+0200 Poing-Studios[23738:2181112] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
Path: /var/containers/Bundle/Application/CB7A76A2-FDD1-4C9C-BB09-BE61E38538AE/Poing-Studios.app

which I fix by adding

<array>
	<string>remote-notification</string>
</array>

Then the application fails to install on my device, here is the error message:

*********** main.m
running app main
Path: /var/containers/Bundle/Application/45170E80-E25A-4B45-AB06-2F1518A44058/Poing-Studios.app
godot_iphone /var/containers/Bundle/Application/45170E80-E25A-4B45-AB06-2F1518A44058/Poing-Studios.app/Poing-Studios
cwd /private/var/containers/Bundle/Application/45170E80-E25A-4B45-AB06-2F1518A44058/Poing-Studios.app
os created
setting data dir to /var/mobile/Containers/Data/Application/EFD9E15B-FCED-4963-BEE5-9CF38FBFB183/Documents from /var/mobile/Containers/Data/Application/EFD9E15B-FCED-4963-BEE5-9CF38FBFB183/Documents
setup 0
2021-01-17 15:49:59.980625+0200 Poing-Studios[23773:2183148] Metal GPU Frame Capture Enabled
2021-01-17 15:49:59.981036+0200 Poing-Studios[23773:2183148] Metal API Validation Enabled
2021-01-17 15:50:00.229344+0200 Poing-Studios[23773:2183148] Setting up an OpenGL ES 2.0 context.
2021-01-17 15:50:00.240494+0200 Poing-Studios[23773:2183148] failed to make complete framebuffer object 8cd6
2021-01-17 15:50:00.240630+0200 Poing-Studios[23773:2183148] Failed to create frame buffer!
******** setting up keyboard input view
******** adding observer for keyboard show/hide
start animation!
2021-01-17 15:50:00.877427+0200 Poing-Studios[23773:2183148] **ERROR**: AudioOutputUnitStart failed, code: -50
2021-01-17 15:50:00.877513+0200 Poing-Studios[23773:2183148]    At: drivers/coreaudio/audio_driver_coreaudio.cpp:256:start() - AudioOutputUnitStart failed, code: -50
2021-01-17 15:50:01.072037+0200 Poing-Studios[23773:2183396]  - <Google>[I-ACS025031] AdMob App ID changed. Original, new: (nil), ca-app-pub-3940256099942544~3347511713
2021-01-17 15:50:01.198711+0200 Poing-Studios[23773:2183396]  - <Google>[I-ACS023007] Analytics v.60900000 started
2021-01-17 15:50:01.199161+0200 Poing-Studios[23773:2183396]  - <Google>[I-ACS023008] To enable debug logging set the following application argument: -APMAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2021-01-17 15:50:01.947571+0200 Poing-Studios[23773:2183148] Godot Engine v3.2.4.beta6.official - https://godotengine.org
2021-01-17 15:50:01.973059+0200 Poing-Studios[23773:2183148] OpenGL ES 2.0 Renderer: Apple A9 GPU
2021-01-17 15:50:01.993983+0200 Poing-Studios[23773:2183148] OpenGL ES Batching: ON
2021-01-17 15:50:02.123736+0200 Poing-Studios[23773:2183148] 
2021-01-17 15:50:02.470125+0200 Poing-Studios[23773:2183148] init admob plugin
2021-01-17 15:50:02.470281+0200 Poing-Studios[23773:2183148] initialize admob
2021-01-17 15:50:02.470501+0200 Poing-Studios[23773:2183148] is admob_enabled?
2021-01-17 15:50:02.470528+0200 Poing-Studios[23773:2183148] init cool
2021-01-17 15:50:02.478858+0200 Poing-Studios[23773:2183148] -[__NSCFString containsObject:]: unrecognized selector sent to instance 0x282881d00
2021-01-17 15:50:02.497984+0200 Poing-Studios[23773:2183148] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString containsObject:]: unrecognized selector sent to instance 0x282881d00'
*** First throw call stack:
(0x1976799d8 0x1ab9e2b54 0x197589bbc 0x19767c01c 0x19767df8c 0x10548eef4 0x1054914bc 0x106489528 0x10648ae6c 0x10548feec 0x105267888 0x1052692e4 0x104ffcbf4 0x104ffcb4c 0x10422e910 0x19a7af8e4 0x1a1de05a8 0x1975d6b54 0x1975fa420 0x1975f9834 0x1975f39f4 0x1975f2ba0 0x1ae330598 0x199ee23d8 0x199ee7958 0x1040fe02c)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString containsObject:]: unrecognized selector sent to instance 0x282881d00'
terminating with uncaught exception of type NSException

I have added inside the _ready() these print messages is admob_enabled? and init cool:

if admob_enabled:
		print("is admob_enabled?")
		if (Engine.has_singleton("AdMob")):
			print("init cool")

I'm testing with a real device, not an emulator.

@naithar
Copy link

naithar commented Jan 17, 2021

@war1an if you remove the admob library and comment out admob_plugin_init and admob_plugin_deinit in dummy.cpp file in Xcode, does it crash?

I added all framework but I can't run the project successfully.

The first error was:

*********** main.m
running app main
2021-01-17 15:47:04.069186+0200 Poing-Studios[23738:2181112] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
Path: /var/containers/Bundle/Application/CB7A76A2-FDD1-4C9C-BB09-BE61E38538AE/Poing-Studios.app

which I fix by adding

<array>
	<string>remote-notification</string>
</array>

This is just a warning, shouldn't really cause you any trouble other than just writing a log.

@bashcole
Copy link

if you remove the admob library and comment out admob_plugin_init and admob_plugin_deinit in dummy.cpp file in Xcode, does it crash?

The app was installed successfully

@naithar
Copy link

naithar commented Jan 17, 2021

The app was installed successfully

You mean there is no -[__NSCFString containsObject:]: unrecognized selector sent to instance error, right?

Then, I guess @gustavottc have changed the code somehow, that results in crashing.

@bashcole
Copy link

Yeah, everything is fine. I got the following:

*********** main.m
running app main
Path: /var/containers/Bundle/Application/8EA6A804-3DA9-4770-82A1-0C410FE4D41F/Poing-Studios.app
godot_iphone /var/containers/Bundle/Application/8EA6A804-3DA9-4770-82A1-0C410FE4D41F/Poing-Studios.app/Poing-Studios
cwd /private/var/containers/Bundle/Application/8EA6A804-3DA9-4770-82A1-0C410FE4D41F/Poing-Studios.app
os created
setting data dir to /var/mobile/Containers/Data/Application/01521AB1-89E1-4A5E-90C7-70B1884FE739/Documents from /var/mobile/Containers/Data/Application/01521AB1-89E1-4A5E-90C7-70B1884FE739/Documents
setup 0
2021-01-17 16:15:06.674320+0200 Poing-Studios[24061:2195141] Metal GPU Frame Capture Enabled
2021-01-17 16:15:06.674752+0200 Poing-Studios[24061:2195141] Metal API Validation Enabled
2021-01-17 16:15:06.767338+0200 Poing-Studios[24061:2195141] Setting up an OpenGL ES 2.0 context.
2021-01-17 16:15:06.768409+0200 Poing-Studios[24061:2195141] failed to make complete framebuffer object 8cd6
2021-01-17 16:15:06.768491+0200 Poing-Studios[24061:2195141] Failed to create frame buffer!
******** setting up keyboard input view
******** adding observer for keyboard show/hide
start animation!
2021-01-17 16:15:06.820878+0200 Poing-Studios[24061:2195141] **ERROR**: AudioOutputUnitStart failed, code: -50
2021-01-17 16:15:06.820969+0200 Poing-Studios[24061:2195141]    At: drivers/coreaudio/audio_driver_coreaudio.cpp:256:start() - AudioOutputUnitStart failed, code: -50
2021-01-17 16:15:07.004712+0200 Poing-Studios[24061:2195141] Godot Engine v3.2.4.beta6.official - https://godotengine.org
2021-01-17 16:15:07.013422+0200 Poing-Studios[24061:2195141] OpenGL ES 2.0 Renderer: Apple A9 GPU
2021-01-17 16:15:07.023033+0200 Poing-Studios[24061:2195379]  - <Google>[I-ACS025031] AdMob App ID changed. Original, new: (nil), ca-app-pub-3940256099942544~3347511713
2021-01-17 16:15:07.023954+0200 Poing-Studios[24061:2195379]  - <Google>[I-ACS023007] Analytics v.60900000 started
2021-01-17 16:15:07.024684+0200 Poing-Studios[24061:2195379]  - <Google>[I-ACS023008] To enable debug logging set the following application argument: -APMAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2021-01-17 16:15:07.025420+0200 Poing-Studios[24061:2195141] OpenGL ES Batching: ON
2021-01-17 16:15:07.152314+0200 Poing-Studios[24061:2195141] 
2021-01-17 16:15:07.193560+0200 Poing-Studios[24061:2195390]  - <Google>[I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2021-01-17 16:15:07.209126+0200 Poing-Studios[24061:2195390]  - <Google>[I-ACS023012] Analytics collection enabled
2021-01-17 16:15:07.464296+0200 Poing-Studios[24061:2195141] is admob_enabled?

@gumaciel
Copy link
Contributor Author

gumaciel commented Jan 17, 2021

@war1an First drag all content inside this admob_plugin.zip into this folder:
Captura de Tela 2021-01-17 às 11 25 30

After that, add AdMob to your plugins and export (click Export Project):
Captura de Tela 2021-01-17 às 11 25 45

Open the AdMob.xcodeproj then change your .plist: SEARCH FOR: Update your GAMENAME-Info.plist file
Captura de Tela 2021-01-17 às 11 27 15

Add the -ObjC linker flag to Other Linker Flags in your project's build settings:
Captura de Tela 2021-01-17 às 11 27 48

After, add the frameworks of GoogleMobileAdsSdk you can download the same that i'm using here (if some error of "framework not found" then: do that and this
Captura de Tela 2021-01-17 às 11 29 14

If you want to test on Simulator and it's not appearing, do that:
Captura de Tela 2021-01-17 às 11 29 47

After all that should all work fine:
Captura de Tela 2021-01-17 às 11 30 44

gumaciel added a commit that referenced this issue Jun 2, 2021
gumaciel added a commit that referenced this issue Jun 2, 2021
gumaciel added a commit that referenced this issue Jun 2, 2021
gumaciel added a commit that referenced this issue Jun 2, 2021
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 1ee04e1
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 4b2411e
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: b4b888d [formerly b5ac43a]
Former-commit-id: 0628fa8
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 35441d6 [formerly b0ff228]
Former-commit-id: 1506df7
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 847d2d3 [formerly 1ee04e1]
Former-commit-id: f88789e
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 2eeec64 [formerly 4b2411e]
Former-commit-id: 514a082
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: d0acf05 [formerly 50f6a91]
Former-commit-id: f8d9a1f
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 7e32301 [formerly 5b290c6]
Former-commit-id: 9021abf
gumaciel added a commit that referenced this issue Jan 19, 2023
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: 5cfa4e0 [formerly 8d6fa1e]
Former-commit-id: 01cdfa5
gumaciel added a commit that referenced this issue Jan 19, 2023
Former-commit-id: fe15b45 [formerly 4e9ccca]
Former-commit-id: a658a36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants