0

I'm creating a CodePush Xamarin.iOS binding, I've generated a fat lib .a file by using sharpie tool with the CodePush cocoapod:

sharpie pod init ios CodePush
sharpie pod bind

And then created a Xamarin.iOS binding project with .a file and libCodePush.linkwith.cs definition:

[assembly: LinkWith(
    "libCodePush.a",
    LinkTarget.ArmV7 | LinkTarget.Arm64 | LinkTarget.i386 | LinkTarget.x86_64,
    LinkerFlags = "-ObjC -lz",
    IsCxx = false,
    SmartLink = false,
    ForceLoad = true)]

My ApiDefinition.cs with added bundleURL (the only property I need from the binding so I removed all the rest):

// @interface CodePush : NSObject
[BaseType(typeof(NSObject))]
public interface CodePush
{
    // + (NSURL *)bundleURL
    [Static]
    [Export("bundleURL")]
    NSUrl BundleUrl { get; }
}

And then simple app bootstrap (assuming that RN binding is added as well):

var window = new UIWindow(UIScreen.MainScreen.Bounds);
// case 1: with this line the app works fine and RN app is loaded
// var url = NSBundle.MainBundle.GetUrlForResource("main", "jsbundle");

// case 2: if this line uncommented the app is crashed on startup
var url = CodePush.BundleUrl;
var rootView = new RCTRootView(url, new NSString("codePushBinding"), new NSDictionary(), launchOptions);
var vc = new UIViewController();
vc.View = rootView;
window.RootViewController = vc;
window.MakeKeyAndVisible();

With the CodePush.BundleUrl line uncommented the app crashes on the app startup, I'm unable to access any debug information, no crash reports on device logs, no crash data in app output.

What could be wrong with the binding definition and how can I debug this issue?

Mando
  • 11,414
  • 17
  • 86
  • 167
  • Where are you bootstrapping an RN app as it is not in the code that you posted? You will need the complete RN app to be initialized before trying to load CodePush – SushiHangover Apr 05 '18 at 04:44
  • @SushiHangover RN app is a separate app, already created and tested with a native objC wrapper, and now I'm trying to load the same RN app as part of xamarin wrapper. – Mando Apr 05 '18 at 18:18

0 Answers0