How to do Flurry binding to Unified API?

KevindeKok.5250KevindeKok.5250 NLMember ✭✭
edited October 2014 in Xamarin.iOS

Binding flurry analytics the monotouch api is no problem, but how to do it to the Xamarin.iOS unified API?

The binding project in Xamarin Studio contains errors, it cannot find the target file it references...

This is what i use for the monotouch binding:
Besides the api definition file FlurryAnalytics.cs, i have a AssemblyInfo.cs:

using System;
using ObjCRuntime;  // prefixed with monotouch it works, but i want it to use the Xamarin.iOS API...

[assembly: LinkWith ("libFlurry_5.4.0.a", LinkTarget.Simulator | LinkTarget.ArmV7, Frameworks = "SystemConfiguration Security", ForceLoad = true)]

And a build.sh:

#!/bin/bash /Developer/MonoTouch/usr/bin/btouch FlurryAnalytics.cs AssemblyInfo.cs --out=FlurryAnalytics.dll --link-with=libFlurry_5.4.0.a,libFlurry_5.4.0.a
The result is:

AssemblyInfo.cs(2,7): error CS0246: The type or namespace name `ObjCRuntime' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
btouch: API binding contains errors.

So, what do i need to change to get this to work with the unified API??

Best Answer

Answers

  • KevindeKok.5250KevindeKok.5250 NLMember ✭✭

    bump
    Nobody ever needed a binding of objC library in a Unified API project?

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Did you get this working? We're also trying to do this.

  • JamesJJamesJ USMember

    btouch has a command line option:

    --new-style

    Which claims to do what you (and I) want. However, I've not had any luck with it. I still get the same errors.

  • §

  • RobertZmudzinskiRobertZmudzinski USUniversity ✭✭

    That did it for me. Thanks!

  • BradMooreBradMoore AUMember ✭✭✭

    Wasn't sure if bindings existed before I found this, so I made this. Updated to the latest 6.0 SDK.

    https://github.com/ytn3rd/MonoTouch.FlurryAnalytics

  • RexChen.9518RexChen.9518 USMember

    @BradMoore Thanks for posting the binding project man! I tried to build it, but some errors popped up. In the "ApiDefinition.cs" file, the using statements below are in red (error CS0103: The name '*****' does not exist in the current context):

    using System.Drawing;
    using ObjCRuntime;
    using Foundation;
    using UIKit;

    I tried to change the reference names to something like "MonoTouch.UIKit" but the issue is still there. I also tried to add in a monotouch reference manually (Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/2.1/monotouch.dll) but that didn't fix the problem.

    I wonder if you could share some thoughts on that. Thanks very much!

  • RexChen.9518RexChen.9518 USMember

    Update: I created a new iOS binding project and encountered the same issue, so it seems to have something to do with my system or xamarin framework. Can someone help me fix this problem?>_<

  • BradMooreBradMoore AUMember ✭✭✭

    Is your Xamarin up to date?

    This binding is built using the unified API so there should be no MonoTouch.xxx (other than its own namespace of MonoTouch.FlurryAnalytics). The reference used in it is
    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll

    I'll double check the binding and throw in a sample app to be sure it does actually run.

  • BradMooreBradMoore AUMember ✭✭✭

    Yeah I messed things up but it still built on my end.
    Fixed the bindings, also added a compiled DLL.

  • IanVinkIanVink CAInsider, University ✭✭✭

    Hi @mattleibow ,

    I tried the Flurry off nuget, but my iOS app fails to compile in Release because:

    Warning MT1301: Native library libFlurry_6.0.0.a (i386, x86_64, armv6, armv7, arm64) was ignored since it does not match the current build architectures (armv7, armv7s, arm64) (MT1301) (CSI.iOS)

    Any idea?

  • adamkempadamkemp USInsider, Developer Group Leader mod

    Change your build settings to use just armv7 and arm64. Even Apple seems to be downplaying armv7s support, which was only useful for iPhone 5 and iPad 4. Prior iOS devices didn't support it, and subsequent iOS devices support arm64. It's just not that useful.

  • IanVinkIanVink CAInsider, University ✭✭✭

    Thanks @adamkemp,

    I didn't know that. That is a really helpful tip.

    It all works great now!
    Ian

  • mattleibowmattleibow ZAXamarin Team Xamurai

    There is also the "Flurry.Analytics.Portable" version.
    This is simply a wrapper around the native bindings, but are more friendly and can be used in PCL or Xamarin.Forms apps.

    An example improvement is event tracking. The "native" way:

    FlurryAgent.LogEvent ("TimedEvent", true);
    await SomeLongRunningTaskAsync();
    FlurryAgent.EndTimedEvent ("TimedEvent");
    

    The "portable" way:

    using (AnalyticsApi.LogTimedEvent("LogNormalTimedEvent")) {
        await SomeLongRunningTaskAsync();
    }
    

    To use parameters in event timed tracking:

    // initial data
    var parameters = new Dictionary<string, string> {
        { "apples", "3" },
        { "pears", "4" }
    };
    
    // start logging the event
    using (var timed = AnalyticsApi.LogTimedEvent("LogNormalTimedEvent", parameters)) {
        await GoShoppingAsync();
    
        // update the parameters
        timed.Parameters["grapes"] = "2";
        timed.Parameters["apples"] = "2";
    }
    

    Then there is the fact that you can share this exact code on all (WP8/iOS/Android) platforms. And, it is only using .NET types. For example Dictionary<,> instead of NSDictionary or some other type.

    All the various members are available on the platforms, however the initialization logic is not available to PCL assemblies as this is very platform-specific.

  • Shane000Shane000 USMember ✭✭✭
    edited October 2015

    The portable works fine on Android with all the latest updates, but I'm having trouble with iOS. Has anyone run into this issue?

    Edit: This crash is occurring when I call: Flurry.Analytics.Portable.AnalyticsApi.LogEvent(action, additionalInfo); on the iOS side. I break pointed and it definitely occurs after calling AnalyticsApi.StartSession() in FinishedLaunching

    2015-10-06 14:45:43.929 AppMobileiOS[23804:882458] Flurry: Starting session on Agent Version [Flurry_iOS_150_6.3.0] 
    2015-10-06 14:45:44.017 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.017 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.018 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.018 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.018 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.018 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.019 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.019 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.019 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.019 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.020 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.020 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.020 AppMobileiOS[23804:882458] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
        /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
    2015-10-06 14:45:44.021 AppMobileiOS[23804:882458] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x81339d20 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)
    2015-10-06 14:45:44.031 AppMobileiOS[23804:882546] critical: 
    Native stacktrace:
    
    2015-10-06 14:45:44.032 AppMobileiOS[23804:882546] critical:    0   AppMobileiOS                      0x0027e187 mono_handle_native_sigsegv + 311
    2015-10-06 14:45:44.033 AppMobileiOS[23804:882546] critical:    1   AppMobileiOS                      0x002aa766 mono_sigsegv_signal_handler + 214
    2015-10-06 14:45:44.033 AppMobileiOS[23804:882546] critical:    2   libsystem_platform.dylib            0x09ef979b _sigtramp + 43
    2015-10-06 14:45:44.033 AppMobileiOS[23804:882546] critical:    3   ???                                 0xffffffff 0x0 + 4294967295
    2015-10-06 14:45:44.033 AppMobileiOS[23804:882546] critical:    4   libobjc.A.dylib                     0x089ab9b4 lookUpImpOrForward + 88
    2015-10-06 14:45:44.033 AppMobileiOS[23804:882546] critical:    5   libobjc.A.dylib                     0x089ab957 _class_lookupMethodAndLoadCache3 + 55
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    6   libobjc.A.dylib                     0x089b6547 objc_msgSend + 135
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    7   AppMobileiOS                      0x000e19b7 -[FlurrySession recordEvent:withParameters:timed:] + 122
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    8   AppMobileiOS                      0x000df418 +[FlurrySession sessionWithApiKey:startTime:] + 1525
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    9   AppMobileiOS                      0x000f4882 __29-[FlurryImpl setupForApiKey:]_block_invoke + 289
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    10  libdispatch.dylib                   0x09bada7f _dispatch_call_block_and_release + 15
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    11  libdispatch.dylib                   0x09bcb6fd _dispatch_client_callout + 14
    2015-10-06 14:45:44.034 AppMobileiOS[23804:882546] critical:    12  libdispatch.dylib                   0x09bb33ca _dispatch_queue_drain + 1065
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical:    13  libdispatch.dylib                   0x09bb2d15 _dispatch_queue_invoke + 563
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical:    14  libdispatch.dylib                   0x09bb47be _dispatch_root_queue_drain + 442
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical:    15  libdispatch.dylib                   0x09bb45fd _dispatch_worker_thread3 + 108
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical:    16  libsystem_pthread.dylib             0x09ee6270 _pthread_wqthread + 1050
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical:    17  libsystem_pthread.dylib             0x09ee3f82 start_wqthread + 34
    2015-10-06 14:45:44.035 AppMobileiOS[23804:882546] critical: 
    =================================================================
    Got a SIGSEGV while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries 
    used by your application.
    =================================================================
    
  • Shane000Shane000 USMember ✭✭✭
    edited October 2015

    This was fixed by updating to 1.2.1 in nuget. Thanks @MatthewLeibowitz.0553

  • dbohlsdbohls USMember
    edited October 2015

    Hi @MatthewLeibowitz.0553, what is the licensing situation for your Flurry project? I noticed the license file in the root of your GitHub is empty and the other one in the NuGet component just repeats the Flurry license. Is there any licensing that applies beyond Flurry's own license? I just want to make sure, are Xamarin developers free to use both your GitHub or NuGet projects for Flurry in their iOS apps? Many thanks for sharing the bindings!

Sign In or Register to comment.