Few cents about my commits

iOS13 PostFix #5: implementation of missing Struct.offsetOf

|

This post continues the series of fixes discovered during compilation of CocoaTouch library and improvements to compiler.

PostFix #5: Struct.offsetOf always returns zero

Other postfixes:

Struct.offsetOf is required to proper implement initialization of variable size structs with flexible array member such as:

struct vectord {
    size_t len;
    double arr[]; // the flexible array member must be last
};

Root case and fix

Struct has offsetOf definition and it returns always zero similar to sizeOf method. `` its implemenation is being synthesized by RoboVM compiler and invocation of sizeOf being fixed during trampoline phase from Struct.sizeOf to DestStruct.sizeOf (DestStruct – an example struct implementation).
Root case – compiler doesn’t not synthesize offsetOf.

AltPods: pods updated - 1.4.0-SNAPSHOT

|

AltPods were update to v1.4.0-SNAPSHOTS to sync with recent releases. Part of list didn’t receive any API update hovewer bindings were re-generated against recent version of frameworks. Update list look as bellow:

Updated pod

Unchanged pod

These pods were pushed to https://oss.sonatype.org/content/repositories/snapshots maven repo under 1.4.0-SNAPSHOTS version.
Source code @github

Updates are not fullty tested, please open issue if bug found.

NB: AltPods – are robopods kept at my personal standalone repo. This is done to prevent main robopods repo from turning into code graveyard. As these pods have low interest of community and low chances to be updated.

iOS13 PostFix #4: Compilation failed on @Bridge annotate covariant return synthetic method

|

This post continues the series of fixes discovered during compilation of CocoaTouch library.

PostFix #4: @Bridge annotated covatiant return bridget methods

Other postfixes:

Issue was discovered while compiling NWTxtRecord:

java.lang.IllegalArgumentException: @Bridge annotated method <org.robovm.apple.network.NWTxtRecord: org.robovm.apple.foundation.NSObject copy()> must be native
	at org.robovm.compiler.BridgeMethodCompiler.validateBridgeMethod(BridgeMethodCompiler.java:87)
	at org.robovm.compiler.BridgeMethodCompiler.doCompile(BridgeMethodCompiler.java:233)

Root case and fix

In source code NWTxtRecord doesn’t contain NSObject copy() method but containts NWTxtRecord copy().
Hovewer once class file is decompiled following methods can be found there:

iOS13 PostFix #3: Support for @Block member in structs

|

This post continues the series of fixes discovered during compilation of CocoaTouch library.

PostFix #3: Adding support @Block members in structs

Other postfixes:

Issue was discovered while compiling CMBufferHandlers:

java.lang.IllegalArgumentException: No @Marshaler found for return type of @StructMember method <org.robovm.apple.coremedia.CMBufferHandlers: org.robovm.objc.block.Block1 getGetDecodeTimeStamp()>
	at org.robovm.compiler.MarshalerLookup.findMarshalerMethod(MarshalerLookup.java:169)
	at org.robovm.compiler.BroMethodCompiler.getStructMemberType(BroMethodCompiler.java:977)
	at org.robovm.compiler.BroMethodCompiler.getStructType(BroMethodCompiler.java:677)
	at org.robovm.compiler.BroMethodCompiler.getStructType(BroMethodCompiler.java:568)
	at org.robovm.compiler.StructMemberMethodCompiler.reset(StructMemberMethodCompiler.java:63)

Root case and fix

Root case and fix is clear from exception: there is no @Marshaller for @Block return type at moment StructMemberMethodCompiler performs reset. And the fix is to provide such.
In details there are several moments and fixes:

  • Marshallers for @Block affected methods are generated by ObjCBlockPlugin in ObjCBlockPlugin.Before class run. The problem here is that ClassCompiler invokes it after StructMemberMethodCompiler.reset where this marshaller is required (and where exception is happening). The fix is to move reset section of method compilers below invocation of plugins Before. This makes marshallers generated at moment StructMemberMethodCompiler.reset needs it.
  • Second moment is that ObjCBlockPlugin.Before was not considering @StructMember annotated methods as subject for method transformation and the fix is trivial – extending condition to include the case.

The fix is delivered as PR421

iOS13 PostFix #2: Non static @Bridge method in enums

|

This post continues series of fixes discovered during compilation of CocoaTouch library.

PostFix #2: Adding support for non-static @Bridge method in enums classes

Other postfixes:

Issue was discovered during compiling of UIImageSymbolWeight class:

java.lang.IllegalArgumentException: Receiver of non static @Bridge method <org.robovm.apple.uikit.UIImageSymbolWeight: double toFontWeight()> must either be a Struct or a NativeObject
	at org.robovm.compiler.BroMethodCompiler.getBridgeOrCallbackFunctionType(BroMethodCompiler.java:554)
	at org.robovm.compiler.BroMethodCompiler.getBridgeFunctionType(BroMethodCompiler.java:526)

What is wrong

iOS13 PostFix #1: Generic class arguments and @Block parameters

|

iOS13 bindings are complete but CocoaTouch related issues keep arriving, part of them about compiler not able to compile one or other class.
Most of these issues can be detected just by compiling entire CocoaTouch library as simple smock test to find out outstanding issues. This can be done by force linking its class path with template like this:

<forceLinkClasses>
    <pattern>org.robovm.apple.**</pattern>
</forceLinkClasses>

This post start series of fixes discovered during compilation of CocoaTouch library.

PostFix #1: Generic class arguments and @Block parameters

Other postfixes:

fix414: run/debug on ios13 device

|

History: errors when deploying to ios13 #414
Fix: PR416

Root case

libmobiledevice when locking services has to perform SSL handshake if required.
in iOS13 debugerserver started requiring this as well by including EnableServiceSSL in response:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>EnableServiceSSL</key>
	<true/>
	<key>Port</key>
	<integer>49745</integer>
	<key>Request</key>
	<string>StartService</string>
	<key>Service</key>
	<string>com.apple.debugserver</string>
</dict>

The weird thing is that after SSL handshake debug server service switches back to plain text communication over same underlayer socket. There was a try-fix in libmobiledevice to close SSL connection but it didn’t work. Root case of it is that it was trying close SSL connection by calling SSL_shutdown which sends close_notify shutdown to underlaying socket. But debugserver expects clear text GDP protocol communication and close_notify aren’t expected which causes gdp protocol error.
This issue was also discussed on libimobiledevice repo: issue789

The fix

iOS 13 bindings

|

iOS 13

bindings have arrived as PR406.
iOS13 introduces bunch of new frameworks:

  • ImageCaptureCore
  • VisionKit
  • SoundAnalysis
  • QuickLookThumbnailing
  • PencilKit
  • MetricKit
  • CryptoTokenKit
  • CoreHaptics
  • BackgroundTasks
  • LinkPresentaion

Beside new ones also missing in previous binding cycle frameworks were added:

  • (new from ios 10) Speech
  • (new from ios 9.3) HealthKitUI
  • (new from ios 11) DeviceCheck
  • (new from ios 10) CallKit
  • (new from ios 11.3) BusinessChat

Beside new framework there was massive API from iOS13. Also this PR delivers lot of fixes to existing bindings as well as generic classes received template parameters (with enhanced version of bro-gen).

Known issues

  • ios13 changed few previously existing classes were common api were moved to new super class introduced in ios13. As result running on pre-ios12 will cause crash due native class not found. This to be fixed in RoboVM obj-c runtime itself;
  • several existing API naming were changed (to improve namings). this might break existing code;

AltPods: pods updated + new bindings(Facebook)

|

AltPods were update to v1.3.0-SNAPSHOTS. Changes include:

New pod

Updated pod

Unchanged pod

Other changes

All pods now have proper dependency setup:

  • references to other pods;
  • references for required framework thorugh META-INF/robovm.xml (no need to specify frameworks in host application)

These pods were pushed to https://oss.sonatype.org/content/repositories/snapshots maven repo under 1.3.0-SNAPSHOTS version.
Source code @github

Updates are not fullty tested, please open issue if bug found.

NB: AltPods – are robopods kept at my personal standalone repo. This is done to prevent main robopods repo from turning into code graveyard. As these pods have low interest of community and low chances to be updated.

Ios13: Fixing broken launch on simulator target

|

With Xcode 11 RoboVm can’t deploy to simulator anymore. It fails with:

simlauncher[70781:19762861] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘+[DVTSimulatorApplication simulatorApplicationForDevice:]: unrecognized selector sent to class 0x1077a3590’

simlauncher was borrowed from MOE project and internaly build around tonns of hacks, and its hard to keep maintain it this way.
Meanwhile Apple provides simctl tool allong with Xcode and its functionality quite enough for RoboVm needs.

PR402 deliver migration to simctl and introduces following changes:

  • rmeoves simlauncher;
  • boots simulator if required with simctl boot;
  • deploys application with simctl install;
  • and launches it with simctl launch.

It works for me with Xcode11 and also has to be backward compatible.