# Build share library with Sliver for multi platform

**URL:** https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368
**Category:** Silver
**Created:** [June 12, 2015, 7:10am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368 "2015-06-12T07:10:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![SamLam](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@SamLam](https://talk.remobjects.com/u/SamLam)
#### Post date: [June 12, 2015, 7:10am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368/1 "2015-06-12T07:10:42Z")

</div>

I am doing a POC on Silver to see if it can be beneficial to deploy our iOS native Swift App on other Platform.  
I try to build a cross-platform static library with Silver by shipping those code written with Swift on Xcode to Silver. I had created one Shared project and three different platforms library project. Then I try my best afford to fix those syntax error on Fire.

However, I am defeated by the following issues:

**Array count is not support on Android**  
Array count is okay for Cocoa. but it is not compilable when try to compile for Android project.

**protocol is not well support on Cocoa**  
In Silver:

```
protocol FormatHelperProtocol {
	func formatCurrency(amount: Double) -> String
	func formatCurrency(amount: Double, fractionDigits: Int) -> String
}

```

In the library header of .a , it just have a empty protocol

```
@protocol FormatHelperProtocol
@end 

```

I had tried put public on the method of protocol to Silver, but it is not compilable on Silver. I think it is just not a valid syntax 😛

**Sugar.reflection on Cocoa**  
I am not sure if the reflection in Sugar is trying to handle the reflection of the class, i.e. I can get all the property names in a given class by that. But it seems not work for Silver on Cocoa at the moment.

**Sugar.Data.JSON for all Platform**  
Similar to the reflection, it seems also not completed for Silver. right ❓

Besides the above, I also got the problems mentioned at  
[http://talk.remobjects.com/t/issue-on-sugar-datetime/6365](http://talk.remobjects.com/t/issue-on-sugar-datetime/6365)

[http://talk.remobjects.com/t/nsobject-is-an-unknown-identifier-on-swift-net-console-app/5834](http://talk.remobjects.com/t/nsobject-is-an-unknown-identifier-on-swift-net-console-app/5834)

I don’t know if I miss any thing. May be there are other work arround,  
I know Sugar, Silver and Fire are all on beta now. I just wish the above can be aware by you. 😄 and waiting for your next release. And looking forward the integration of Swift 2.0.

Sam

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [June 12, 2015, 8:15am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368/2 "2015-06-12T08:15:19Z")

</div>

> [@SamLam](#):
>
> Array count is not support

Can you give me a code sample or more context? Swift arrays should support `count`. The platform-native away/list classes on the various platforms might have different names (\*such as `Length`, etc).

> [@SamLam](#):
>
> In the library header of .a , it just have a empty protocol

are the functions _only_ missing from the header, or do you also not see them in your code from within your Silver project?

If you could send me your complete project that shows all these issues,that would be super helpful in helping us narrow these down.

> [@SamLam](#):
>
> Sugar.Data.JSON

That code is incomplete should never have shipped, and i apologize for that. The latest version of Sugar on GitHub (and in the upcoming next build) has a full/proper cross-platform JSON implementation in the core Sugar library. Please let me know how this works out for you.

> [@SamLam](#):
>
> NSObject is an “Unknown identifier”

Hmm. the Swift Base Library should define NSObject as an alias to the system object types in .NET and Java. Are you sure you have the Swift reference in your project?

```
public typealias NSObject = Object

```

> [@SamLam](#):
>
> I’m just trying to create a basic Dictionary using [NSObject:AnyObject] and I’m getting an “Unknown identifier” compiler error.

Sund sike that too would be caused by the Swift library not being references )and it this not finding either `NSObject` (on .NET and Java) nor `AnyObject` on any of the three platforms, coz `AnyObject` is specific to Swift and not a general Cocoa type name).

> [@SamLam](#):
>
> And looking forward the integration of Swift 2.0.

We’re hard at work on that. Some exciting new stuff in Swift 2.0. 😉

---

<div class="post-metadata">

### Author: ![SamLam](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@SamLam](https://talk.remobjects.com/u/SamLam)
#### Post date: [June 12, 2015, 8:50am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368/3 "2015-06-12T08:50:48Z")

</div>

Thanks so much for your quick responds! That raise my confidence on Silver.

> [@mh](#):
>
> Array count is not support
> 
> Can you give me a code sample or more context? Swift arrays should support count. The platform-native away/list classes on the various platforms might have different names (\*such as Length, etc).

I had modify my quotation, it is only not work when I try to compile the source (in Silver) on my Android library project. All the .count highlighted with red

> [@mh](#):
>
> In the library header of .a , it just have a empty protocol
> 
> are the functions only missing from the header, or do you also not see them in your code from within your Silver project?

the Code I writen in Silver is just like I posted here

```
protocol FormatHelperProtocol {
    func formatCurrency(amount: Double) -> String
    func formatCurrency(amount: Double, fractionDigits: Int) -> String
}

```

We use protocol mechanism to let the Silver Library calling the platform specific code that handle what Silver can’t do.

> [@mh](#):
>
> Sugar.Data.JSON
> 
> That code is incomplete should never have shipped, and i apologize for that. The latest version of Sugar on GitHub (and in the upcoming next build) has a full/proper cross-platform JSON implementation in the core Sugar library. Please let me know how this works out for you.

I saw the Source of the Sugar for Json. I am looking for the release of next build. 😃

> [@SamLam](#):
>
> Sugar.reflection on CocoaI am not sure if the reflection in Sugar is trying to handle the reflection of the class, i.e. I can get all the property names in a given class by that. But it seems not work for Silver on Cocoa at the moment. (I don’t see the function definition)

For the Reflection and DateTime, I have check the latest Git source of Sugar, it seems still not support Cocoa (DateTime for Android too), right?

Thanks so much! You are doing a fantastic work, keep on that!

Sam

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [June 13, 2015, 10:52am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368/4 "2015-06-13T10:52:55Z")

</div>

Can you send me the project in question? here, or privately to [mh@remobjects.com](mailto:mh@remobjects.com) is fine.

---

<div class="post-metadata">

### Author: ![SamLam](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/eada6e/32.png) [@SamLam](https://talk.remobjects.com/u/SamLam)
#### Post date: [June 15, 2015, 7:47am UTC](https://talk.remobjects.com/t/build-share-library-with-sliver-for-multi-platform/6368/5 "2015-06-15T07:47:29Z")

</div>

😄 I have send you email. as i can’t attach file here.
