iOS SDK -- XCode Linker Errors when using Real Time API.
T
Theodore Hecht
started a topic
over 5 years ago
I'm trying to use the iOS SDK -- specifically the Real Time functionality. The specific linker errors I get when trying to build my project look like the following:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get these linker errors whenever I:
(1) Use Real Time classes in the scope of a function
(2) Use Real Time classes as a variable of a class.
I do NOT get linker errors when I:
(1) Use the rest of the GameSparks API from the iOS SDK.
(2) Use RT classes as parameters in functions.
I installed the iOS SDK using cocoapods, in the normal way.
Example code (made using a fresh iOS SpriteKit game template, after removing some of the boilerplate code. GameSparks installed using cocoapods. Currently using XCode 8.3.3):
import SpriteKit
import GameSparks
class GameScene: SKScene, IRTSessionListener {
var session: IRTSession? // Having this IRTSession var causes a linker error
override func didMove(to view: SKView) {
// Using GameSparksRTSessionBuilder() causes a linker error
session = GameSparksRTSessionBuilder().setConnectToken("TOKEN").setHost("HOST").setPort(4242).setListener(self).build()
}
func onPlayerConnect(_ peerId: NSNumber) {
NSLog("onPlayerConnect: " + String(peerId as Int));
}
func onPlayerDisconnect(_ peerId: NSNumber) {
NSLog("onPlayerDisconnect: " + String(peerId as Int));
}
func onReady(_ ready: Bool) {
NSLog("onReady: " + String(ready));
}
func onPacket(_ packet: RTPacket) {
// no errors thrown by using RTPacket as a parameter above. However, if I attempt to
// use packet in this scope, I get an additional linker error
}
override func update(_ currentTime: TimeInterval) {
// Called before each frame is rendered
// update session here later
}
}
While I don't expect the above code to behave appropriately at run time (since the sessionbuilder isn't configured with correct information), I expect this should at least build, yes?
Are there any project settings I need to change in order to use Real Time services from the iOS SDK?
Best Answer
T
Tech Support
said
over 5 years ago
Hello Theodore, Yes, you're right and thus we have reverted our SDK to last stable version. Basically the RT module is written using C++ and Obj-C and it makes some troubles when users try to use it in Swift projects. So, you need to copy the RT folder from our public repository into the Shared (or any you want) folder of your project, then you have to create an Obj-C bridging header. You could have a look at our GSRTExamples folder to see how it works. Let us know whether now it is fine please.
You are right, it looks like this implementation file wasn't included. Why isn't this file included using pods?
Anyways, I tried dragging it into the project where the other GS files are (under pods/GameSparks), but it looks like there are other things which GSRT.mm references which are also not included using pods (like "GameSparksRT.hpp"), and of course these files include others, etc.
Is there a way to set Cocoapods up to grab everything I need? Alternatively, what steps should I take to manually install the realtime components having used pods to install the regular SDK? (Or, if its easier: what steps should I take to install the whole SDK manually without the use of pods, to be able to access RT components?)
T
Theodore Hecht
said
over 5 years ago
It looks like an update to the iOS SDK podspec file went live a couple hours ago, and it now appears to include the GSRT.mm file by default.
However, this breaks the library due to requirements in GSRT.mm like:
The above line results in a file not found build time error.
Tech Support
said
over 5 years ago
Hello Theodore, We are still looking at this issue and it will be fixed as soon as possible.
Thanks, Giuseppe
Tech Support
said
over 5 years ago
Hi Theodore, We have done some fixes and could you tell us whether now it works for you, please?
Thanks, Giuseppe
T
Theodore Hecht
said
over 5 years ago
Sure thing. I encountered 4 new compiler errors using the most recent build. Here the steps I took and the errors I encountered.
Steps:
1. Create new iOS SpriteKit game template project in Xcode (Swift selected as language)
2. Import the most recent GameSparks API using CocoaPods.
At this point, the project actually built fine, until I used a "import GameSparks" line near the top of one of my swift files (my template's GameScene file to be exact.) After including this import statement, my project flagged 4 errors. These were the errors:
Errors:
1. Could not build Objective-C module 'GameSparks'
2. Unknown type name 'namespace' (in Forwards.hpp)
3. Expected ';' after top level declarator (in Forwards.hpp)
4. '../../include/GameSparksRT/Forwards.hpp' file not found (in GameSparksRT.hpp)
Does it do the same for you when importing the library using cocoapods in a normal swift spritekit template project?
Tech Support
said
over 5 years ago
Answer
Hello Theodore, Yes, you're right and thus we have reverted our SDK to last stable version. Basically the RT module is written using C++ and Obj-C and it makes some troubles when users try to use it in Swift projects. So, you need to copy the RT folder from our public repository into the Shared (or any you want) folder of your project, then you have to create an Obj-C bridging header. You could have a look at our GSRTExamples folder to see how it works. Let us know whether now it is fine please.
Giuseppe
T
Theodore Hecht
said
over 5 years ago
Hi Giuseppe,
Yes, this seems to work. Thanks for the help!
A suggestion: under the installation section for the iOS SDK on Bitbucket, you might want to write a note informing people who want to use the RT components that they need to import the RT folder manually, make the bridging header, and import "GSRT.h" in the bridging header.
Theodore Hecht
I'm trying to use the iOS SDK -- specifically the Real Time functionality. The specific linker errors I get when trying to build my project look like the following:
I get these linker errors whenever I:
(1) Use Real Time classes in the scope of a function
(2) Use Real Time classes as a variable of a class.
I do NOT get linker errors when I:
(1) Use the rest of the GameSparks API from the iOS SDK.
(2) Use RT classes as parameters in functions.
I installed the iOS SDK using cocoapods, in the normal way.
Example code (made using a fresh iOS SpriteKit game template, after removing some of the boilerplate code. GameSparks installed using cocoapods. Currently using XCode 8.3.3):
While I don't expect the above code to behave appropriately at run time (since the sessionbuilder isn't configured with correct information), I expect this should at least build, yes?
Are there any project settings I need to change in order to use Real Time services from the iOS SDK?
Yes, you're right and thus we have reverted our SDK to last stable version. Basically the RT module is written using C++ and Obj-C and it makes some troubles when users try to use it in Swift projects. So, you need to copy the RT folder from our public repository into the Shared (or any you want) folder of your project, then you have to create an Obj-C bridging header. You could have a look at our GSRTExamples folder to see how it works. Let us know whether now it is fine please.
Giuseppe
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstTech Support
Hey Theodore,
Have you got this https://bitbucket.org/gamesparks/gamesparks-ios-sdk/src/c0b03eb76f7afc3672f44004b81b5b382c58717e/GSRT.mm?at=master&fileviewer=file-view-default added to your project? If you're using pods, it isnt automatically added.
Cheers,
Omar
Theodore Hecht
Hi Omar, thanks for the reply.
You are right, it looks like this implementation file wasn't included. Why isn't this file included using pods?
Anyways, I tried dragging it into the project where the other GS files are (under pods/GameSparks), but it looks like there are other things which GSRT.mm references which are also not included using pods (like "GameSparksRT.hpp"), and of course these files include others, etc.
Is there a way to set Cocoapods up to grab everything I need? Alternatively, what steps should I take to manually install the realtime components having used pods to install the regular SDK? (Or, if its easier: what steps should I take to install the whole SDK manually without the use of pods, to be able to access RT components?)
Theodore Hecht
It looks like an update to the iOS SDK podspec file went live a couple hours ago, and it now appears to include the GSRT.mm file by default.
However, this breaks the library due to requirements in GSRT.mm like:
The above line results in a file not found build time error.
Tech Support
We are still looking at this issue and it will be fixed as soon as possible.
Thanks,
Giuseppe
Tech Support
We have done some fixes and could you tell us whether now it works for you, please?
Thanks,
Giuseppe
Theodore Hecht
Sure thing. I encountered 4 new compiler errors using the most recent build. Here the steps I took and the errors I encountered.
Steps:
1. Create new iOS SpriteKit game template project in Xcode (Swift selected as language)
2. Import the most recent GameSparks API using CocoaPods.
At this point, the project actually built fine, until I used a "import GameSparks" line near the top of one of my swift files (my template's GameScene file to be exact.) After including this import statement, my project flagged 4 errors. These were the errors:
Errors:
1. Could not build Objective-C module 'GameSparks'
2. Unknown type name 'namespace' (in Forwards.hpp)
3. Expected ';' after top level declarator (in Forwards.hpp)
4. '../../include/GameSparksRT/Forwards.hpp' file not found (in GameSparksRT.hpp)
Does it do the same for you when importing the library using cocoapods in a normal swift spritekit template project?
Tech Support
Yes, you're right and thus we have reverted our SDK to last stable version. Basically the RT module is written using C++ and Obj-C and it makes some troubles when users try to use it in Swift projects. So, you need to copy the RT folder from our public repository into the Shared (or any you want) folder of your project, then you have to create an Obj-C bridging header. You could have a look at our GSRTExamples folder to see how it works. Let us know whether now it is fine please.
Giuseppe
Theodore Hecht
Hi Giuseppe,
Yes, this seems to work. Thanks for the help!
A suggestion: under the installation section for the iOS SDK on Bitbucket, you might want to write a note informing people who want to use the RT components that they need to import the RT folder manually, make the bridging header, and import "GSRT.h" in the bridging header.
Anyways, thanks again!
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics