Obj-c to Swift

Posted in General by Tom el Safadi Sat Dec 05 2015 10:29:54 GMT+0000 (Coordinated Universal Time)·6·Viewed 1,654 times

Hey, how can I integrate AppHub if I am using swift as the main language? I don't know how to add AppHub to the AppDelegate if the language is Swift, as you have it in Objective-C in your documentation. Thanks.
Dec 9, 2015

Hey Tom! You definitely can. All of the methods are callable by Swift. For example:

[AppHub setApplicationID:@"YOUR_APPLICATION_ID"];



Let me know if you have any questions about this :)

marked this as solved
Nov 18, 2016

Hey Matt,

Still don't know how to translate

AHBuild *build = [[AppHub buildManager] currentBuild]; jsCodeLocation = [build.bundle URLForResource:@"main" withExtension:@"jsbundle"];

in swift

Nov 18, 2016

Hey Edwin, you can try,

AppHub.buildManager().currentBuild().bundle.URLForResource("main", withExtension: "jsbundle")

Nov 18, 2016

Sorry i'm such a noob.

While dev i'm using :

let jsCodeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios")

and i don't know how to hook your answer with this

Nov 18, 2016

OK nevermind, i'm just tired and stupid :)

But i had to change it to :
let jsCodeLocation = AppHub.buildManager().currentBuild.bundle.url(forResource: "main", withExtension: "jsbundle")

for swift 3 to be happy (thx xcode auto-correct)

Markdown is allowed