Converting RealmSwift to Xcode9/Swift 4 (workaround)
Environment
Xcode: 9.0 GM Seed (9A235)
Swift: 4.0
Carthage: 0.25.0
(tried on 2017/9/12 PDT)
Introduction
In your existing Xcode project, you might see this error if you convert swift version to 4.
Usually I must be able to use it through Carthage, but now I couldn’t.
It seems that the problem is RealmSwift doesn’t take measures against Swift 4 yet for Carthage.
So let me share how I fixed it.
This is just a workaround, I think the situation will turn better soon.
Thanks in advance
https://stackoverflow.com/questions/44640852/how-can-i-use-realm-with-swift-4
https://ja.stackoverflow.com/questions/28951/realm%E3%81%8Cbuild-%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84
Solution
Before that, confirm the xcodebuild version.$ sudo xcode-select -s /Applications/Xcode9.app
$ xcodebuild -version
Xcode 9.0
Build version 9A235
1) Change swift version to 4
select TARGETS then move to Build Settings > Swift Language Version.
Then choose Swift 4.
2) Build RealmSwift by yourself
For now, download RealmSwift manually
$ git clone --recursive https://github.com/realm/realm-cocoa.git
$ cd realm-cocoa
$ git checkout v2.10.0
fetch submodule
// at root of realm-cocoa directory
$ git submodule update --init
build using script, passing argument by devices you want
// build will fail if you forget the previous step
$ REALM_SWIFT_VERSION=4.0 sh build.sh ios-swift
It takes time.
※ Or you can choose the other devices.// this is optional
$ REALM_SWIFT_VERSION=4.0 sh build.sh osx-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh watchos-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh tvos-swift
Gotcha! frameworks are produced in the directory realm-cocoa/build/ios/swift-4.0
.
You only have to replace the old frameworks with the new stuff.
Well done! Error disappeared.
Mission completed.
That's it!
In my small private projects, Conversion to Swift 4 was easy (Luckily I only have to fix NSAttributedStringKey and add @objc annotation before keyword dynamic
. Xcode9 taught me everything I should do.)
Thanks for reading! Happy coding.
Reference
이 문제에 관하여(Converting RealmSwift to Xcode9/Swift 4 (workaround)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/creaa/items/6d7080c5873055cb3e48
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
In your existing Xcode project, you might see this error if you convert swift version to 4.
Usually I must be able to use it through Carthage, but now I couldn’t.
It seems that the problem is RealmSwift doesn’t take measures against Swift 4 yet for Carthage.
So let me share how I fixed it.
This is just a workaround, I think the situation will turn better soon.
Thanks in advance
https://stackoverflow.com/questions/44640852/how-can-i-use-realm-with-swift-4
https://ja.stackoverflow.com/questions/28951/realm%E3%81%8Cbuild-%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84
Solution
Before that, confirm the xcodebuild version.$ sudo xcode-select -s /Applications/Xcode9.app
$ xcodebuild -version
Xcode 9.0
Build version 9A235
1) Change swift version to 4
select TARGETS then move to Build Settings > Swift Language Version.
Then choose Swift 4.
2) Build RealmSwift by yourself
For now, download RealmSwift manually
$ git clone --recursive https://github.com/realm/realm-cocoa.git
$ cd realm-cocoa
$ git checkout v2.10.0
fetch submodule
// at root of realm-cocoa directory
$ git submodule update --init
build using script, passing argument by devices you want
// build will fail if you forget the previous step
$ REALM_SWIFT_VERSION=4.0 sh build.sh ios-swift
It takes time.
※ Or you can choose the other devices.// this is optional
$ REALM_SWIFT_VERSION=4.0 sh build.sh osx-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh watchos-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh tvos-swift
Gotcha! frameworks are produced in the directory realm-cocoa/build/ios/swift-4.0
.
You only have to replace the old frameworks with the new stuff.
Well done! Error disappeared.
Mission completed.
That's it!
In my small private projects, Conversion to Swift 4 was easy (Luckily I only have to fix NSAttributedStringKey and add @objc annotation before keyword dynamic
. Xcode9 taught me everything I should do.)
Thanks for reading! Happy coding.
Reference
이 문제에 관하여(Converting RealmSwift to Xcode9/Swift 4 (workaround)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/creaa/items/6d7080c5873055cb3e48
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Before that, confirm the xcodebuild version.
$ sudo xcode-select -s /Applications/Xcode9.app
$ xcodebuild -version
Xcode 9.0
Build version 9A235
1) Change swift version to 4
select TARGETS then move to Build Settings > Swift Language Version.
Then choose Swift 4.
2) Build RealmSwift by yourself
For now, download RealmSwift manually
$ git clone --recursive https://github.com/realm/realm-cocoa.git
$ cd realm-cocoa
$ git checkout v2.10.0
fetch submodule
// at root of realm-cocoa directory
$ git submodule update --init
build using script, passing argument by devices you want
// build will fail if you forget the previous step
$ REALM_SWIFT_VERSION=4.0 sh build.sh ios-swift
It takes time.※ Or you can choose the other devices.
// this is optional
$ REALM_SWIFT_VERSION=4.0 sh build.sh osx-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh watchos-swift
$ REALM_SWIFT_VERSION=4.0 sh build.sh tvos-swift
Gotcha! frameworks are produced in the directory realm-cocoa/build/ios/swift-4.0
.You only have to replace the old frameworks with the new stuff.
Well done! Error disappeared.
Mission completed.
That's it!
In my small private projects, Conversion to Swift 4 was easy (Luckily I only have to fix NSAttributedStringKey and add @objc annotation before keyword dynamic
. Xcode9 taught me everything I should do.)
Thanks for reading! Happy coding.
Reference
이 문제에 관하여(Converting RealmSwift to Xcode9/Swift 4 (workaround)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/creaa/items/6d7080c5873055cb3e48
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(Converting RealmSwift to Xcode9/Swift 4 (workaround)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/creaa/items/6d7080c5873055cb3e48텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)