Parse framework constants

840 views
Skip to first unread message

Richard Venneman

unread,
May 7, 2012, 7:43:58 AM5/7/12
to rubymotion
Hi,

I've added the Parse framework to my app like this:
http://stackoverflow.com/a/10453895/123048.
While most methods work correctly, I have trouble accessing the
caching constants defined by Parse.

Parse constants are defined like this in PFConstants.h:
typedef enum {
kPFCachePolicyIgnoreCache = 0,
kPFCachePolicyCacheOnly,
kPFCachePolicyNetworkOnly,
kPFCachePolicyCacheElseNetwork,
kPFCachePolicyNetworkElseCache,
kPFCachePolicyCacheThenNetwork
} PFCachePolicy;

However, trying to access the constant (like above or with capital
first letter) results in the following error:
=> #<NameError: uninitialized constant KPFCachePolicyCacheOnly>

Does anyone have an idea on how to access these constants?

Robert Payne

unread,
May 7, 2012, 7:53:27 AM5/7/12
to rubym...@googlegroups.com
Hey Richard,

As per the way RubyMotion/MacRuby works your access to constants looks correct. Is there any chance you could extract an example project setup? I noticed Parse is a bit proprietary so it's hard to see what may be giving you troubles.


-Robert

Richard Venneman

unread,
May 7, 2012, 8:51:25 AM5/7/12
to rubym...@googlegroups.com
Hi Robert,

Thanks for helping. While trying to put together a test case, I stumbled upon another problem.

Parse requires you to set an applicationId and key (in the app delegate) with the following method:
Parse.setApplicationId('123', clientKey:'456')

Doing just that and running the app results in the following error:
(main)>> Objective-C stub for message `setApplicationId:clientKey:' type `v@:@@' not precompiled. Make sure you properly link with the framework or library that defines this message.
But with the following code added right after it it runs fine:
    testObject = PFObject.objectWithClassName('TestObject')
    testObject.setObject('Bar', forKey:'Foo')
    testObject.saveEventually

This leads me to the conclusion that the framework is not fully compiled unless some methods are being called. Which could explain the constants not being accessible because they aren't compiled. Is there any way to force a full compile for a framework?

In any case, here is my example project setup: https://github.com/richardvenneman/parsemotion

Richard

Heath Provost

unread,
May 7, 2012, 8:56:52 AM5/7/12
to rubym...@googlegroups.com


On Monday, May 7, 2012 6:43:58 AM UTC-5, Richard Venneman wrote:
Hi,

I've added the Parse framework to my app like this:
http://stackoverflow.com/a/10453895/123048.
While most methods work correctly...

I am trying to get this working as well, but I am finding that most methods don't seem to work correctly... I copied the Parse.framework folder into my vendor folder under my project. My rake file looks like this:

$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'

Motion::Project::App.setup do |app|
  # Use `rake config' to see complete project settings.
  app.name = 'SG Careers'
  app.libs << '/usr/lib/libz.1.1.3.dylib'
  app.frameworks += [
 'AudioToolbox',
 'CFNetwork',
 'SystemConfiguration',
 'MobileCoreServices',
 'Security',
 'QuartzCore'
  ]
  app.vendor_project(
  'vendor/Parse.framework', 
  :static, 
  :products => ['Parse'], 
  :headers_dir => 'Headers'
  )
  app.device_family = :iphone
  app.deployment_target = '5.1'
end

I basically took the approach of porting the Parse.com SDK example project verbatim to RubyMotion. So I have this for my app delegate didFinishLaunchingWithOptions:

def application(application, didFinishLaunchingWithOptions:launchOptions)
    # This is where you fill in your Parse credentials
    Parse.setApplicationId('12345', clientKey:'67890')
    # Optionally if you are using Facebook, fill in with your Facebook App Id
    # PFFacebookUtils.initializeWithApplicationId('YourFacebookAppId')
    PFUser.enableAutomaticUser
    defaultACL = PFACL.ACL
    # Optionally enable public read access by default.
    # defaultACL.setPublicReadAccess(true);
    PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser:true)
    # Start general application customizations here
 
    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) 
    @window.rootViewController = MainView.alloc.init;
    @window.makeKeyAndVisible
    application.registerForRemoteNotificationTypes(
    UIRemoteNotificationTypeBadge || 
    UIRemoteNotificationTypeAlert || 
    UIRemoteNotificationTypeSound
    )
    return true
end

...Omitting the rest of the app_delegate file as it is mostly not interesting

It is basically a line for line port, including the view controller (which does nothing but create and save a test object to parse in the viewDidLoad handler). 

Anyway, when I do a "rake build" I get this error:

ERROR! Building vendor project `vendor/Parse.framework' failed to create at least one `.a' library. 

If I just do "rake default", it appears to build cleanly (why this has a different result I don't know) but when it tries to run in the simulator I get this:

Objective-C stub for message `setDefaultACL:withAccessForCurrentUser:' type `v@:@c' not precompiled. Make sure you properly link with the framework or library that defines this message.

If I comment out the setDefaultACL call I can get a bit further, but then it fails with this:

Objective-C stub for message `objectWithClassName:' type `@@:@' not precompiled. Make sure you properly link with the framework or library that defines this message.

which is this line in my view controller's viewDidLoad handler:

testObject = PFObject.objectWithClassName('TestObject') 

Did you get any of this to work? I see you are asking about the caching constants - I can't even get that far...

Heath

David Rupp

unread,
May 7, 2012, 9:09:52 AM5/7/12
to rubym...@googlegroups.com
Heath,

I'm having a similar problem. I noticed that "rake build" tries to build for both the simulator and device, where the default task builds for the simulator only. The simulator build goes in "./build/iPhoneSimulator-5.1-Development" and builds cleanly. The device build wants to go in "./build/iPhoneOS-5.1-Development", but does not seem happy. Those directory names are constructed by convention; see /Library/RubyMotion/lib/motion/project/app.rb and .../config.rb for more details. I suspect there's something out-of-sync with the convention and either the Xcode project or my local setup.

Cheers,
David

Greg Pasquariello

unread,
May 7, 2012, 9:48:36 AM5/7/12
to rubym...@googlegroups.com, rubym...@googlegroups.com
I ran into a very similar problem integrating ZBar, though it did not occur to me to try to load other methods to fix it.  I'll give that a try later today. Thanks for giving me a direction!  

Regards
-Greg Pasquariello

Sent from my iPhone

David Rupp

unread,
May 7, 2012, 9:56:11 AM5/7/12
to rubym...@googlegroups.com
On further inspection -- there is code in the build_xcode method that checks for the presence of the "build-#{platform}" directory. If it already exists, I guess motion assumes there is no need to try again; it just reuses whatever artifacts were previously built. This seems like a bug. I don't want to have to clean (which will delete that directory) every time I build. Also, as in my case, if the directory got created but the build failed later, subsequent builds won't even try until you clean up that directory.

I was able to get further along by doing a "rake clean", then doing "rake build:simulator" and "rake build:device" separately. The device build is still failing, but I think I've got a better handle on the process now.

Igor Guerrero

unread,
May 7, 2012, 11:06:47 AM5/7/12
to rubym...@googlegroups.com
Same here with ZBar, I noticed if I create an instance of the object that failed in the debugger it works. I think the libraries are getting loaded too late (after the view loads?).

-- 
Thanks,

Igor.

Greg Pasquariello

unread,
May 7, 2012, 11:09:08 AM5/7/12
to rubym...@googlegroups.com
For me, the views all load correctly.  The problem occurs on the imageCaptured callback when I try to access the ZBarSymbolSet.count method.  I was just getting back into trying this when the phone started ringing, so hopefully I'll be back at it shortly.

The workaround that coded was to modify the ZBarSDK library to call a different callback passing back the parsed strings.  It works, but is not ideal.

Regards
-Greg Pasquariello
----
Email:    gr...@pasq.net
Phone:   303-648-1334
Skype:   gregpasq

Richard Venneman

unread,
May 7, 2012, 9:35:01 PM5/7/12
to rubym...@googlegroups.com
Heath, David,

I'm still experiencing the same problems. In my rootViewController the following method
query.findObjectsInBackgroundWithBlock:lambda { |objects, error|
throws this error:
(main)>> Objective-C stub for message `findObjectsInBackgroundWithBlock:' type `v@:@?' not precompiled. Make sure you properly link with the framework or library that defines this message.

But objects = query.findObjects works fine!

Have you been able to get this working?

Best,
Richard

Heath Provost

unread,
May 7, 2012, 9:54:29 PM5/7/12
to rubym...@googlegroups.com
Nope... I'm still stuck. What is really odd is that different people seem to be reporting different methods working and non-working... I'm still stuck not being about to call PFObect.objectWithClassName because of the stub error.

Heath

Jason Jones

unread,
May 7, 2012, 10:23:11 PM5/7/12
to rubymotion
I dealt with this overall 'stub for message not precompiled' issue
when using a different static 3rd party library. The issue is that
there is no BridgeSupport file, and Ruby Motion is not generating one.
I'm not sure if I don't understand how to configure the project
correctly, or if its a bug when using a Framework as a static library,
but essentially the RubyMotion code doesn't grab the headers provided
in the :headers_dir for generating the BridgeSupport file.

Here is the relevant section of my Rakefile:

app.vendor_project('/Users/jj/Library/SDKs/ArcGIS/
ArcGIS.framework', :static,
:products => ['ArcGIS'],
:headers_dir => 'Headers'
)

Now, to make this work, I've modified /Library/RubyMotion/lib/motion/
project/vendor.rb and changed the Dir.glob on line 38 from:
source_files = (opts.delete(:source_files) or Dir.glob('*.
{c,m,cpp,cxx,mm,h}'))

to:
source_files = (opts.delete(:source_files) or Dir.glob('**/*.
{c,m,cpp,cxx,mm,h}'))

After doing that, and then running rake clean, everything runs
correctly on the next build (rake).

I've submitted a ticket for this, and hopefully it either gets fixed
or I get instruction on how to configure my Rakefile properly.

On May 7, 5:54 pm, Heath Provost <heath_prov...@schumachergroup.com>
wrote:

Mac Fanatic

unread,
May 7, 2012, 11:20:52 PM5/7/12
to rubym...@googlegroups.com
Thanks for the post, I've had the same stub message error when trying to compile RestKit using Cocoapods.

Aaron Feng

unread,
May 8, 2012, 11:53:59 AM5/8/12
to rubym...@googlegroups.com
Still stuck with this:

(main)>> Objective-C stub for message `objectWithClassName:' type `@@:@' not precompiled. Make sure you properly link with the framework or library that defines this message.


Not 100% sure how to fix it.  Is there a work around?

The only way I can save the object is to do it in the REPL.

Aaron

Provost, Heath

unread,
May 8, 2012, 12:37:13 PM5/8/12
to rubym...@googlegroups.com
That fixed it for me :) Thank you very much!

-----Original Message-----
From: rubym...@googlegroups.com [mailto:rubym...@googlegroups.com] On Behalf Of Jason Jones
Sent: Monday, May 07, 2012 9:23 PM
To: rubymotion
Subject: Re: Parse framework constants

[Snip...]

Now, to make this work, I've modified /Library/RubyMotion/lib/motion/
project/vendor.rb and changed the Dir.glob on line 38 from:
source_files = (opts.delete(:source_files) or Dir.glob('*.
{c,m,cpp,cxx,mm,h}'))

to:
source_files = (opts.delete(:source_files) or Dir.glob('**/*.
{c,m,cpp,cxx,mm,h}'))

[Snip...]

This message is intended only for the addressee. If you received this message in error, please immediately notify the sender. Since the message may contain confidential, proprietary, legally privileged or private healthcare information, please also delete and/or destroy all copies of it. You must not use, disclose, distribute, print or copy any part of this message if you are not the intended recipient.

Aaron Feng

unread,
May 8, 2012, 12:49:48 PM5/8/12
to rubym...@googlegroups.com

That fixed it for me :) Thank you very much!

Ah, should have read all the messages.  Yes, it fixed it for me too.  Thx.

Aaron

Igor Guerrero

unread,
May 9, 2012, 3:19:29 AM5/9/12
to rubym...@googlegroups.com
Thanks a lot! That really helped, now to continue rewriting :)

-- 
Thanks,

Igor.

Deny Styler

unread,
Jul 31, 2013, 3:00:34 PM7/31/13
to rubym...@googlegroups.com
Hello Igor!

  I've notice you have tried to use ZBar with RubyMotion. I am trying to accomplish similar task here now, but I am stuck on getting error messages during linking. The messages are:
Undefined symbols for architecture i386:
  "_iconv", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
  "_iconv_close", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
  "_iconv_open", referenced from:
      _qr_code_data_list_extract_text in libzbar.a(qrdectxt.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!

  I am not sure if I am adding ZBar library correctly. I am using:
app.vendor_project('vendor/ZBarSDK', :static)
The library itself is located right inside that folder, but I am not sure if linker can find headers, and more then that - I can not understand what path I should use for headers_dir param. 

  Can you give me an advise?  

среда, 9 мая 2012 г., 11:19:29 UTC+4 пользователь Igor Guerrero написал:

Deny Styler

unread,
Jul 31, 2013, 3:26:09 PM7/31/13
to rubym...@googlegroups.com
Never mind, I've googled and found similar thing, so I changed my Rakefile with:
  app.libs += ['/usr/lib/libiconv.dylib']
and linker error about iconv symbols not found were gone)
Sorry for this probably stupid question, I am newcomer to both - Ruby and MacOS world =)
Reply all
Reply to author
Forward
0 new messages