[英]How to Import Rollout.io in SWIFT Xcode
I am trying to install rollout.io its simply it says put thus code in you ApppDelegate the problem is that it is in Objective-C. 我正在尝试安装rollout.io,它只是说它把代码放在你的ApppDelegate中,问题是它在Objective-C中。 So i used a converter to try and change it to Swift but it doesn't work when i try to put the Objective-C import header into my code.
所以我使用转换器尝试将其更改为Swift,但是当我尝试将Objective-C导入头放入我的代码时它不起作用。 Even when i try to convert it the Online converter doesn't even show the "import" part
即使我尝试转换它,在线转换器甚至不会显示“导入”部分
Ive tried these all ready 我已经准备好了这些
Code: 码:
import Rollout
import rollout
import UIRollout
all of these fail. 所有这些都失败了。
i can get the bottom part in the swift eject but not the top"import ,Rollout/Rollout.h>" part 我可以在快速弹出中获得底部但不是顶部的“import,Rollout / Rollout.h>”部分
The following will allow you to setup Rollout SDK in case your AppDelegate is in Swift. 以下将允许您设置Rollout SDK,以防您的AppDelegate在Swift中。
Rollout SDK 1.1.0 has Swift interface for calling the setup, so all the following info is not relevant now. Rollout SDK 1.1.0具有用于调用设置的Swift接口,因此以下所有信息现在都不相关。
To call [Rollout setupWithDebug:]
from Swift, you should have Objective-C Bridging Header set and <Rollout/Rollout.h>
should be imported from it: 要从Swift调用
[Rollout setupWithDebug:]
,你应该设置Objective-C Bridging Header并从中导入<Rollout/Rollout.h>
:
ObjC-Bridging-Header
ObjC-Bridging-Header
SWIFT_OBJC_BRIDGING_HEADER
to point to the file you've created ( ObjC-Bridging-Header.h
). SWIFT_OBJC_BRIDGING_HEADER
设置为指向您创建的文件( ObjC-Bridging-Header.h
)。 A relative path is required in the setting if the file is not at the project's root - more details in this SO answer Go to the header and add the import line there: 转到标题并在那里添加导入行:
#import <Rollout/Rollout.h>
#if debug
#if debug
In order to allow Rollout testing mode (for easy hot-patches testing) it's also required to translate #ifdef Debug
from ObjC . 为了允许Rollout测试模式(为了便于热补丁测试),还需要从ObjC翻译
#ifdef Debug
。 This can be done by setting OTHER_SWIFT_FLAGS
in build settings like this: 这可以通过在构建设置中设置
OTHER_SWIFT_FLAGS
来完成,如下所示:
Now you can add the following lines to application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
: 现在您可以
application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
添加到application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)
:
#if DEBUG
Rollout.setupWithKey("<rollout_key>", developmentDevice: true)
#else
Rollout.setupWithKey("<rollout_key>", developmentDevice: false)
#endif
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.