Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Xcode 11 things #6163

Open
tgoyne opened this issue Jun 3, 2019 · 125 comments

Comments

@tgoyne
Copy link
Member

commented Jun 3, 2019

  • Get Realm/RealmSwift building in Xcode 11 (#6164)
  • Swift Package Manager support as that's finally included with Xcode (#6187)
  • SwiftUI
  • Combine framework
  • PropertyWrapper-based RealmOptional
  • Make all property types PropertyWrapper-based rather than @objc dynamic?
  • Support catalyst/UIKit for Mac (requires 10.15 to build)
  • Catalyst installation example/tests
  • Update release packaging
  • Login with Apple for sync auth

More things to be discovered?


Using Realm with Xcode betas requires building from source, and typically will require using dev branches rather than releases.

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/realm/realm-cocoa", from: "3.17.3")
],

Targets named "Realm" and "RealmSwift" (for the obj-c and swift APIs respectively) are exported from the package. SPM support is currently experimental and does not support Realm Sync.

Carthage

github "realm/realm-cocoa" "master"

DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer carthage bootstrap -no-use-binaries

CocoaPods

  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

Explicitly including the Realm pod as a dependency is required as otherwise it'll try to use the latest release of the obj-c part.

Manual framework

git clone --recursive https://github.com/realm/realm-cocoa.git
cd realm-cocoa
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer sh build.sh build

Built frameworks are in the build directory.

@tgoyne tgoyne added the T-Enhancement label Jun 3, 2019
@tgoyne tgoyne self-assigned this Jun 3, 2019
@varyP

This comment has been minimized.

Copy link

commented Jun 4, 2019

I get Primary Key for a particular RealmObject not found, when i run my project using XCode11, it works fine on XCode10.

Realm 3.16.1
RealmSwift 3.16.1

uncaught exception 'RLMException', reason: 'Primary key property 'identifier' does not exist on object

@owenzhao

This comment has been minimized.

Copy link

commented Jun 4, 2019

I get Primary Key for a particular RealmObject not found, when i run my project using XCode11, it works fine on XCode10.

The same here.

@etown

This comment has been minimized.

Copy link

commented Jun 4, 2019

I as well.

@joshgrenon

This comment has been minimized.

Copy link

commented Jun 4, 2019

Same

@corteggo

This comment has been minimized.

Copy link

commented Jun 4, 2019

Same here, unfortunately.

@haawa799

This comment has been minimized.

Copy link

commented Jun 4, 2019

Same

@umwelt

This comment has been minimized.

Copy link

commented Jun 4, 2019

On my side the exception is on:
'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole'

is this related, or do I start another issue?

@varyP

This comment has been minimized.

Copy link

commented Jun 4, 2019

On my side the exception is on:
'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole'

is this related, or do I start another issue?

It's the same issue.

@fishfisher

This comment has been minimized.

Copy link

commented Jun 4, 2019

I am seeing the same issue. After digging around a bit I was able to see the following:
All String properties of a Realm class with a default 'String' value set are disregarded.

I.e:
allProperties = [[RLMObjectSchema propertiesForClass:cls isSwift:isSwift] on line 125 in RLMObjectSchema.mm returns all properties, except properties of non-optional 'String'.

This is why the 'primaryKeyProperty' is not set.

However, having an 'Int' as a primary key works.

It should be easy to reproduce for the Realm Team! Keep up the good work!

@haawa799

This comment has been minimized.

Copy link

commented Jun 4, 2019

In my case replacing all
: String = ""

with:
: String! = ""

and
: Date = Date()

with:
: Date! = Date()

fixed the issue. Good enough as a temporary workaround.

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Jun 4, 2019

You will need to use the tg/xcode-11-b1 branch for now since the PR (#6164) has not yet been merged.

@etown

This comment has been minimized.

Copy link

commented Jun 4, 2019

pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true

@fishfisher

This comment has been minimized.

Copy link

commented Jun 4, 2019

@etown and everyone else trying the Xcode-11-b1 branch:
Remember to add
pod 'Realm', :git => 'https://github.com/realm/realm-cocoa.git', :branch => 'tg/xcode-11-b1', submodules: true
to the Podfile as well.
If not it will not update to the branch.

@bendodson

This comment has been minimized.

Copy link

commented Jun 4, 2019

Using the Xcode-11-b1 branch lets my iPad app run in Xcode 11 but there are compile errors when trying to use UIKitForMac (Project Catalyst / Marzipan). I'm not sure if you're supporting this and couldn't see it being tracked so thought I should flag it. My compile error looks like this:

ld: in /Users/redacted/App Files/Pods/Realm/core/librealmcore-ios.a(bptree.o), building for UIKitForMac, but linking in object file built for iOS Simulator, for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Jun 4, 2019

We'll probably need to adopt the new xcframework format to support uikitformac well. For now using the macOS framework rather than the iOS framework should work for that (but not for iOS/iPadOS).

@jbhav24

This comment has been minimized.

Copy link

commented Jun 5, 2019

@tgoyne have you been able to get the frameworks to work together on UIKitForMac?

@mariohahn

This comment has been minimized.

Copy link

commented Jun 5, 2019

The branch is not working for me? I am still getting the same error: *** Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftClassPermission''

@xfreebird

This comment has been minimized.

Copy link

commented Jun 5, 2019

@mariohahn
Have you tried adding this to your Podfile?
Also try doing a clean build.
It worked for me.

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
@mariohahn

This comment has been minimized.

Copy link

commented Jun 5, 2019

@xfreebird answer worked 4 me 🎉

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Jun 5, 2019

sh build.sh build will now produce a universal xcframework for both Realm and RealmSwift (if DEVELOPER_DIR points to Xcode 11) that should be usable with catalyst.

@cliftonlabrum

This comment has been minimized.

Copy link

commented Jun 5, 2019

+1 for Swift Package Manager support. That would be a huge improvement! I'll be eager to test it once it's available.

@simon0814

This comment has been minimized.

Copy link

commented Jun 6, 2019

I have already add

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true

Then I run

pod install

Then there was an error:

Screen Shot 2019-06-06 at 13 57 33 pm

Where's the problem?

@ainopara

This comment has been minimized.

Copy link

commented Jun 6, 2019

sh build.sh build will now produce a universal xcframework for both Realm and RealmSwift (if DEVELOPER_DIR points to Xcode 11) that should be usable with catalyst.

I'm building Realm and RealmSwift with this command and successfully generate the xcframework files.

DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer ./build.sh build

By using those xcframework files, I can successfully build my app in Xcode 11 for iOS target, but it seems not enough to use it for catalyst

error: Unable to find a suitable library in the XCFramework 'RealmSwift.xcframework' (in target 'redact')
@varyP

This comment has been minimized.

Copy link

commented Jun 6, 2019

I have already add

pod 'Realm', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true
pod 'RealmSwift', git: 'https://github.com/realm/realm-cocoa.git', branch: 'tg/xcode-11-b1', submodules: true

Then I run

pod install

Then there was an error:

Screen Shot 2019-06-06 at 13 57 33 pm

Where's the problem?

This is because the Commandline tools are still set as default for older XCode.
Considering your XCode beta is in Applications folder, running this on Terminal should solve your issue.

sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Sep 12, 2019

Still trying to get Xcode 11 working on the CI machines. The new simulator runtime has caused some issues (they bumped up the minimum requirements and switching between Xcode 10 and 11 breaks in exciting new ways) and the iteration time on rolling out a change and retesting is awkwardly long.

@virtuosovidit

This comment has been minimized.

Copy link

commented Sep 13, 2019

@tgoyne So what do you suggest developers do to add Realm in their iOS 13 apps? Now that even the SPM doesn't work!!? Is there any process that'd lead to a functioning Realm Library on iOS? Forget watchOS or Catalyst. That seems out of question at this point in the release schedule.

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Sep 13, 2019

Why do you say that SPM doesn't work?

Installing via CocoaPods and Carthage still work fine other than not supporting catalyst.

@corteggo

This comment has been minimized.

Copy link

commented Sep 13, 2019

SPM, CocoaPods and Carthage options are working as expected as of Xcode 11 GM. Same as previous betas since Package.swift manifest file was merged to master as well.

@virtuosovidit

This comment has been minimized.

Copy link

commented Sep 13, 2019

Using SPM with the master branch results in a duplicate symbols error at the moment (Switching to 3.17.3 resolves the issue but on builds prior to the GM, the master was working fine).

@corteggo

This comment has been minimized.

Copy link

commented Sep 13, 2019

@virtuosovidit you should either upload a sample project with repro steps or try to clear derived data folder and try it again, because I tested master branch with Xcode 11 GM and it worked fine as I said in my previous comment.

@ChristianSteffens

This comment has been minimized.

Copy link

commented Sep 13, 2019

... because I tested master branch with Xcode 11 GM and it worked fine as I said in my previous comment.

I just downloaded Xcode 11 GM, cleared all caches and the derived data folder entirely, but I'm not able to build the latest master using carthage. There's no need for an example project as the build process itself is failing.

@corteggo did you try building the master with carthage?

ld: bitcode bundle could not be generated because 'core/librealm-ios-dbg.a(bptree.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** ARCHIVE FAILED **
@ChristianSteffens

This comment has been minimized.

Copy link

commented Sep 15, 2019

Well release 3.18.0 solves everything (for me) - thanks a lot.

@mmdumi

This comment has been minimized.

Copy link

commented Sep 16, 2019

I'm getting:

Compiling for iOS 10.0, but module 'RealmSwift' has a minimum deployment target of iOS 13.0

Is this intentional ?

@nimi1

This comment has been minimized.

Copy link

commented Sep 16, 2019

@tgoyne thanks for the nice progress on SPM support. Any news on when RealmSync will be usable purely through swift package dependencies? (I don't see it listed in the checklist at the top of this thread - is that not a priority?)

@advaita13

This comment has been minimized.

Copy link

commented Sep 16, 2019

I'm using 3.18.0 but my app crashes with the following error.

Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'identity' does not exist on object 'RealmSwiftPermissionUser''

@bmunkholm

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2019

@advaita13 This is unrelated to this issue. It's not a bug and it's not a feature request, so please post on StackOverflow or the Forum. Before doing that though please check you have defined a primary key called identity in RealmSwiftPermissionUser.

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Sep 16, 2019

Any news on when RealmSync will be usable purely through swift package dependencies? (I don't see it listed in the checklist at the top of this thread - is that not a priority?)

The problematic bit there is that the sync library is currently closed source, and SPM doesn't yet support binary packages. Apple is actively working on adding support for them (or at least designing the feature) so I'm currently thinking that it makes more sense to wait for that than to try to find some way to make spm do things it's specifically not supposed to do.

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Sep 16, 2019

This week is the mongodb engineering offsite, so I will have very limited time to look into the remaining (or any new) issues.

@advaita13

This comment has been minimized.

Copy link

commented Sep 17, 2019

@bmunkholm

Noticed a similar issue at the top of this issue thread.
#6163 (comment)

Also, RealmSwiftPermissionUser is a RealmSwift wrapper in the Sync.swift file, it is not something I've defined.

@marcocattai

This comment has been minimized.

Copy link

commented Sep 18, 2019

Swift Pack Manager / master - works perfectly
If I import Realm using cocoapods it download 3.18.0 and I receive the error: librealmcore-ios.a (bptree.o) building for Mac Catalyst, but linking in object file build for iOS Simulator for architecture x86_64

@tgoyne

This comment has been minimized.

Copy link
Member Author

commented Sep 18, 2019

Cocoapods does not support catalyst for projects with vendored libraries yet. You can follow CocoaPods/CocoaPods#9148 for updates on that.

@fanthus

This comment has been minimized.

Copy link

commented Sep 20, 2019

@advaita13 maybe you should clean you project after 'pod install'

@ntnhon

This comment has been minimized.

Copy link

commented Sep 20, 2019

Well release 3.18.0 solves everything (for me) - thanks a lot.

pod 'RealmSwift', '~> 3.18.0'

then
pod repo update
and
pod install
solves the issue for me.

@andre991

This comment has been minimized.

Copy link

commented Sep 20, 2019

This error still happens in 3.18.0 Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole''

@gggal123

This comment has been minimized.

Copy link

commented Sep 21, 2019

This error still happens in 3.18.0 Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole''

Updating to 3.18.0, as @ntnhon wrote and then Product -> Clean Build Folder fixed the issue.

@services-thirdparty

This comment has been minimized.

Copy link

commented Sep 21, 2019

/Users/realm/workspace/ealm-sync_release_4.7.5-catalyst/realm-sync/src/realm/sync/object.cpp:397: [realm-core-5.23.4] Assertion failed: info.object_id_index == 0 [3, 0]
after trying to add object to List in write transaction (3.18.0)

@smelloftime

This comment has been minimized.

Copy link

commented Sep 23, 2019

On my side the exception is on:
'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole'

is this related, or do I start another issue?

I also encountered the same problem and have solved it.
Xcode11 Version 11.0 (11A420a)
RealmSwift 3.13.1 -> 3.18.0
The processing method is as follows:

Remove 'realm' from 'pod', mask the realm in 'podfile', then 'pod install'
Reinstall the 3.18.0 version of 'realm'
The project is ok!

@Synat

This comment has been minimized.

Copy link

commented Sep 23, 2019

@xfreebird fucking brand branch: 'tg/xcode-11-b1'

@vialyx

This comment has been minimized.

Copy link

commented Sep 23, 2019

Realm 3.18.0 release is already works fine. Close issue, please.

@ajanuar

This comment has been minimized.

Copy link

commented Sep 23, 2019

This error still happens in 3.18.0 Terminating app due to uncaught exception 'RLMException', reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole'' ...

@gggal123 i am still facing crash. My class is still in Swift and I am using RealmCocoa.

Sent with GitHawk

@cellgit

This comment has been minimized.

Copy link

commented Sep 23, 2019

Crashed: reason: 'Primary key property 'name' does not exist on object 'RealmSwiftPermissionRole''

Xcode 11
Realm 3.18.0

The Crashed is solved:

The method is remove the version 3.18.0 and pod install it again, then solved

Podfile write like this:
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
@smelloftime

This comment has been minimized.

Copy link

commented Sep 23, 2019

RealmCocoa
Remove 'realm' from 'pod', mask the realm in 'podfile', then 'pod install'
Reinstall the 3.18.0 version of 'realm'

@realm realm locked as resolved and limited conversation to collaborators Sep 23, 2019
@nirinchev

This comment has been minimized.

Copy link
Member

commented Sep 23, 2019

I'm locking this to avoid continuously spamming participants with similar replies. For those facing issues, reinstalling the pod and clearing the build folder data is likely to resolve them. If after doing that, you still have problems, please open a new issue and fill in the template.

Thanks for everyone who participated in the discussion and we're looking forward to supporting the rest of the features outlined in the issue summary. If your favourite Xcode 11 feature/addition is not there, please open a new issue and we'll add it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.