Using Realm on MOE

After the CocoaPods install, I do not have a framework anywhere like Saeed mentions:

I do have a bunch of h files in an “include” directory inside the Realm Pods directory. But, it doesn’t look like the pod install installs a framework.

Did you happen to download that separately?

I don’t know how you went around doing things, I’ll quickly detail how I personally installed the SDK we are using for our iOS version :

/!\ During all these steps, always have the Xcode project closed. When you open it to modify something (for example config files), close it when you’re done.

  • Add the pod to your Podfile
  • If this is the first time you’re using CocoaPods, make sure to change, in the Xcode project, the config files (for debug and release) to “None”. Else you’ll have conflicts with CocoaPods.
  • pod install
  • This will have set the config files, in Xcode, to the ones from CocoaPods, that’s good.
  • If you’re using LibGDX or any other framework that requires you to use a custom xcconfig file (that’s our case), modify your Pods xcconfig files (xcode/Pods/Target Support Files/Pods-ios-moe/Pods-ios-moe.debug.xcconfig , same for release) and add #include "../../../ios-moe/custom.xcconfig"at the top (this way, even though the Xcode project uses the Pods config file, the Pod config file itself has a reference to your custom xcconfig file, which is needed for LibGDX for example. Be careful, you need to re-do this EVERY time you use pod install, because it overwrites the Pods xcconfig file.)
  • Open the .xcworkspace file (when you’re using CocoaPods with Xcode, you need to use this file instead of the xcproject file to work with Xcode), click on Products > Schemes > Manage Schemes, and make sure all schemes are ticked as “shared”. Close Xcode.
  • At this point, your MOE project should properly compile and run in your IDE. If it doesn’t, there’s a problem somewhere.
  • Now you need to do the bindings. Right click your MOE module in your IDE, Multi-OS Engine Actions > Create new bindings.
  • Name it “Realms.nbc” for example.

Here is an example of one of our NBC files, for the Facebook SDK :

48

  • For “output directory”, put where your sources are.
  • Click the green “+”, name it Realms for example. Select “Headers”, since from what I’ve read, you don’t have a .framework file.
  • For “Header path”, “Header search paths”, “User header search paths” and “Framework search paths” you can use the same path, the xcode/Pods/<name_of_the_library>. In your case, that would be xcode/Pods/Realms I imagine ?
  • In “Import headers”, pick the specific headers you need bindings for. You can put all the headers if you wish, although that might be a big too big/long to write. Only use quotes, not < or >. For example in our case, the Facebook SDK has a shit ton of headers, we only need one for the Core SDK, which is FBSDKCoreKit.h. If you realize you’re missing headers, you can always modify the .nbc file and regenerate the bindings, it will seamlessly re-generate the previous bindings (so no code will break) + add the new ones.

That’s it I think. I hope this applies to your case, I think so since you don’t seem to have any framework but just headers/sources, in any case it’s the precise steps to follow whenever you want to add a CocoaPods pod.

you need to download framework separately.

Hi @saeed, I am trying to follow your instructions but am slightly puzzed by the step in the quote.
How should RLMObject.h and RLMResults.h be modified? What changes should be undone?

Thanks in advance.

Lara

Dear @laranyman,

This step needs to remove. I will ask MOE admin to gimme access to edit this post.

Regards,
Saeed.

Ah ok, thanks @saeed.

I was following the instructions and managed to complete most of them (after importing Realm.framework which wasn’t mentioned in the original instructions but found a separate comment mentioning this addition).

However, I am having some issues with generating the bindings for the Person RLMObject as per step:

click on :gear: then Generate Bindings (after a freezing android studio you will see Generate successfully)

When attempting to generate the bindings, I get the following error:

...ios/xcode/ios/Person.h:10:9: fatal error: 'RLMObject.h' file not found

I have tried different combinations of imports in Person.h file to the above mentioned such as:

#import <Foundation/Foundation.h>
#import <Realm/RLMObject.h>

but unfortunately this has not worked either. Was wondering if you might be able to help/have any ideas?

Thanks

Dear @laranyman,

You need to put this binding in realm binding and put it on below of realm than when u generate all binding everything worked ok.

54 AM

Regards,
Saeed.

1 Like

Thank you @saeed for all your help! That worked - I had the Entity (Person binding) in a different binding file which caused my issue.