Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build realm for Swift 3 & Xcode 8

Tags:

swift

realm

I am following the steps given here to build realm to be used in an iOS project, I am using Xcode 8 beta 3 :

I get these warnings :

ld: warning: ignoring file .../Realm.framework/Realm, missing required architecture x86_64 in file .../Realm.framework/Realm (2 slices)
ld: warning: ignoring file .../RealmSwift.framework/RealmSwift, missing required architecture x86_64 in file .../RealmSwift.framework/RealmSwift (2 slices)

and this error

Lipo: -remove's specified would result in an empty fat file

Why is this happening?

like image 594
ielyamani Avatar asked Aug 01 '16 10:08

ielyamani


2 Answers

Can you try these updated instructions, which should work for Beta 3?

  1. Clone the Realm Cocoa git repository: git clone https://github.com/realm/realm-cocoa.git
  2. Open the Xcode project. Click on the Realm project, then the RealmSwift target, then the 'Build Settings' tab, and set Use Legacy Swift Language Version to Yes (if building for Swift 2.3) or No (if building for Swift 3).
  3. From the directory containing the git repository, run the following command: sh build.sh TARGET, where TARGET is one of the following: ios-swift, osx-swift, tvos-swift, or watchos-swift, depending on what platform you are building for.
  4. Once the build has completed, go to the 'build' directory, then the directory named after the platform for which you built (e.g. 'ios').
  5. Open the 'swift-2.3' or 'swift-3.0' directory (depending on which version you built for).
  6. Drag RealmSwift.framework and Realm.framework into your project, as per step 2 in the instructions here, and do steps 3 and 4.

If these don't work please do post a comment.

like image 181
AustinZ Avatar answered Nov 12 '22 16:11

AustinZ


In order to get Swift 3 versions of Realm and RealmSwift, I had to explicitly target master, set submodules to true, and include a post_install hook to set the Swift version:

use_frameworks!

target 'TARGET_NAME' do
    pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true
    pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'master', submodules: true

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '3.0'
            end
        end
    end
end
like image 31
Scott Gardner Avatar answered Nov 12 '22 16:11

Scott Gardner