LoginSignup
4
5

More than 5 years have passed since last update.

RomoのSwift sample codeをXcode7.1(Swift2.1)で動くようにしてみた

Last updated at Posted at 2015-11-21

以前、RomoSDKをSwiftで使う。【導入編】を参考に、Xcode6.1.1(Swift1.1)でRomoサンプルコードを動かす事ができたのですが、Xcode7.1(Swift2.1)で動かそうとするとエラーになります。
XcodeもSwiftも初心者ですが、Xcodeのバージョンをあげながら、エラー対応をまとめてみました。
結果的には、Swiftのバージョンがあがるたび、動作やsyntaxが変わっているのが原因のようです。

Xcode6.1.1(Swift1.1)

最初に試したバージョン問題なし。

Xcode6.2(Swift1.1)

問題なし。

Xcode6.3(Swift1.2)

RMCoreControllerPID.hに関するエラー

下記を追加。

RMCoreControllerPID.h
#undef I

touches*メソッドの引数指定記述変更

こちらこちらを参考に、touchesBegan,touchesMoved,touchesEnded,touchesCancelledの引数を下記のように変更。

    override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
        let touchLocation = touches.anyObject()?.locationInView(self.view)

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
        let touch = touches.first
        let touchLocation = touch!.locationInView(self.view)

Xcode6.4(Swift1.2)

問題なし。

Xcode7.0.1(Swift2.0)

touches*メソッドの引数指定記述変更

こちらを参考に、touchesBegan,touchesMoved,touchesEnded,touchesCancelledの引数を下記のように変更。

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
        let touch = touches.first
        let touchLocation = touch!.locationInView(self.view)
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touchLocation = touches.first!.locationInView(self.view)

シミュレータでiPhone6/6Sを選択した場合、表示画面の右側が空白になる。

原因不明。
iPhone5sでは正常表示するので、当面iPhone5sを使用する事で問題先送り。

romo20151122.png

Xcode7.1(Swift2.1)

シミュレータでiPhone6/6Sを選択した場合、表示画面の右側が空白になる。

事象継続中。

実機転送時、エラー発生

試していなかったが、Xcode7.0.1以前でも同事象でていたかもしれない。

clang: error: linker command failed with exit code 1 (use -v to see invocation)

こちらを参考にproject -> target -> build settings -> Build Options -> Enable Bitcode->No に変更
下記の通り、iPhone5s実機での動作を確認

romo_iphone5s.png

まとめ

  • Swift2.1でRomo SDKを始める場合、遭遇するエラーの対応方法をまとめました。
  • これでやっとSwift2.1でRomo開発がすすめられます。

参考

Xcode 6-7系のバージョン間の微妙な差異まとめ

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5