Giter Club home page Giter Club logo

ios-jsc's Introduction

iOS Runtime for NativeScript

Contains the source code for the NativeScript's iOS Runtime. NativeScript is a framework which enables developers to write truly native mobile applications for Android and iOS using JavaScript and CSS. Each mobile platform has its own ecosystem and offers completely different development tools and language(s) - Java for Android and Objective C (Swift) for iOS. In order to translate JavaScript code to the corresponding native APIs some kind of proxy mechanism is needed. This is exactly what the "Runtime" parts of NativeScript are responsible for. The iOS Runtime may be thought of as "The Bridge" between the JavaScript and the iOS world. A NativeScript application for iOS is a standard native package (ipa) which besides the JavaScript files embed the runtime as well.

git clone --recursive [email protected]:NativeScript/ios-runtime.git

Requirements

Architecture Diagram

The NativeScript iOS Runtime architecture can be summarized in the following diagram.

iOS Runtime diagram

For more details on how it works, read the documentation.

Local Development

To be able to open and build {N} iOS Runtime in Xcode you need to configure it for WebKit development and generate the Xcode project files using cmake. To do this execute the following:

sudo ./src/webkit/Tools/Scripts/configure-xcode-for-ios-development
./cmake-gen.sh
open "cmake-build/NativeScript.xcodeproj"

After you open the newly generated project in Xcode you can run the TestRunner target or the Gameraww example app.

For more information on WebKit configuration see Building iOS Port section of WebKit's README

Building a Distribution Package

To build the tns-ios npm package run ./build/scripts/package-tns-ios.sh in the root of the repository. The package contains the NativeScript Cocoa Framework, the NativeScript CLI template project and the API metadata generator.

To build the tns-ios-inspector npm package run ./build/scripts/package-tns-ios-inspector.sh in the root of the repository. The package contains the Web Inspector frontend.

Contribute

We love PRs! Check out the contributing guidelines. If you want to contribute, but you are not sure where to start - look for issues labeled help wanted.

Get Help

Please, use github issues strictly for reporting bugs or requesting features. For general questions and support, check out Stack Overflow or ask our experts in NativeScript community Slack channel.

ios-jsc's People

Contributors

atanasovg avatar deyanginev avatar dicksmith avatar dimitartachev avatar dtopuzov avatar e2l3n avatar erjangavalji avatar etabakov avatar facetious avatar fatme avatar fealebenpae avatar fpattis avatar ivanbuhov avatar jasssonpet avatar kristinakoeva avatar mbektchiev avatar nathanaela avatar panayotcankov avatar peterstaev avatar pkoleva avatar rigor789 avatar roblav96 avatar rosen-vladimirov avatar speigg avatar svetoslavtsenov avatar tbozhikov avatar tdermendjiev avatar tjvantoll avatar vtrifonov avatar yyosifov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-jsc's Issues

xCode project needs to be updated

CLI generates xcode project that targets iOS 7.0. The project should be updated to latest (at the moment 8.2). And more important is to add Launch Screen File in the default template otherwise applications that run on iPhone 6 Plus are zoomed.

Tagged pointers marshalling

Currently we crash when tagged pointers are marshalled to JavaScript as wrapper objects on iOS 7 - 64 bit. This affects roughly 3% of all devices (statistics).

The reason lies in a bug in the Objective-C runtime, which seems to be fixed in iOS 8:

NSNumber *number = @123;
objc_setAssociatedObject(number, ...); // Crashes

Possible workarounds:

  • Use a WeakGCMap from pointer to JSValue

Library must clean cashed metadata

I'm developing custom iOS framework for NativeScript . Once library added , the metadata folder is not updated anymore and have to be deleted by hand to apply new changes.

3rd party static libraries: Integrate Cocoapods with the CLI Plugins Mechanism

This will require us to support build from the Xcode workspace the cocoapods generate.

We will have to somehow generate metadata for the cocoapods. The best solution would be to generate module maps from the podspecs.

We will have to reasearch what part of the cocoa apis can we consume (e.g there may be C apis that get stripped during the linking, although cocoapods add -ObjC flag)

Later this issue will probably be integrated with the NPM plugins mechanism, and allow pods to be specified in the package.json or a podfile in a plugin.

Implement the Metadata Generator in C++

We want to lower the dependencies for the end devs, and increase the performance of the metadata generator, so we are rewriting the metadata generator in C++. It will link statically all dependencies. The result should be a self contained command line tool.

Location issue with iOS

Hi everyone,

I am using a beta Yosemite, 10.3.3. and am trying to implement a simple location retrieve and I am getting this error when running the app in the emulator. The code is this:

if (LocationManager.isEnabled()) {
    locationManager.startLocationMonitoring(function (location) {
        mainViewModel.set("latitude", location.latitude);
        mainViewModel.set("longitude", location.longitude);
    }, function (error) {
        console.log('Location error received: ' + error);
    });
}

ERROR: org.nativescript.mobile is depending on legacy on-demand authorization, which is not supported for new apps

The other thing I tried is a simple latest location retreival:

location.getLocation({ maximumAge: 30000, timeout: 30 }).then(function (location) {
    console.log('Location received: ' + location);
}, function (error) {
    console.log('Location error received: ' + error);
});

Is there a way to make location work? I assume I should also request permission, but I don’t know how to do that.

Thanks,
Eduárd

Generate TypeScript Declarations for Modules with the C++ Generator

We are working on polishing the MetadataGenerator by rewriting it in C++.
Also we are planning to introduce a mechanism to "require" modules.
(e.g classes from UIKit will be available by using a require("UIKit"))

So we will need the TypeScript declarations generator ported from the C# project to the C++ one.

Failed to recurse into submodule path 'src/metadata-generator'

Cloning into 'src/generator/nclang'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:NativeScript/ios-metadata-generator-nclang.git' into submodule path 'src/generator/nclang' failed
Failed to recurse into submodule path 'src/metadata-generator'

Performance Optimizations Based on TelerikNEXT Conference App

Try to squeeze as much as possible out of the TelerikNEXT Conference App. The application is close to the target LOB style applications we target. It has rich UI with lot of CSS styles and layout.

We should maximize the frame-rates, minimize CPU utilization, allocations, memory usage, frame-rate spikes/hiccups.

We should provide report on time spent in GC, JSC JavaScript or native code as well as memory spent for JavaScript heap and native allocations.

Change enum syntax

In the current implementation enumerations are exposed as:

var v1 = HMCharacteristicValueHeatingCooling.HMCharacteristicValueHeatingCoolingOff;

We should instead support both:

var v2 = HMCharacteristicValueHeatingCooling.Off;
var v3 = HMCharacteristicValueHeatingCoolingOff;

This way the code isn't so verbose and looks closer both to C/Objective-C and JavaScript.

This is a breaking API change, so it should be done sooner.

Create a global require function

The modules are wrapped in a function that defines a local require. However when using the debugger it would be useful to have the require at hand, even if we are not stopped at breakpoint.

We can make that by defining a global require function. It should search from a path relative to the app's root. And expressions such as:

global.require("ui/frame").topmost().ios.navBarVisibility

should easily locate the ui/frame module.

Live-sync in the CLI

We need something like a file watcher in the CLI that upon file save will perform fast deploy on the device.

We should check whether a regular "tns run ios" fits in decent times with the latest metadata generator and library improvements. If the delay is small we should simply hook a file watcher.

If the build time is not acceptable we should research how to deliver the changes to the phone and restart the app fast.

Report errors in bootstrap.js to the debugger

We should call reportFatalErrorBeforeShutdown() if there was a syntax error or runtime (e.g. wrong require before we enter UIApplicationMain) when executing bootstrap.js so the debugger can be notified.

console.log output

console.log is somewhat hard to track.
We should provide a way to obtain the console.log output even in published apps.

ios-metadata-generator is not public?

Submodule path 'src/jsc': checked out '9cd6d7947270a7059c8f766ebea15d20543e4e2e'
Cloning into 'src/metadata-generator'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:NativeScript/ios-metadata-generator.git' into submodule path 'src/metadata-generator' failed

Require for native APIs

The global object is currently polluted for iOS with all classes, structs, constants, functions etc. etc. for all iOS SDKs and additional libraries included in an App.

We want to expose the native APIs through require. So for example the UIButton will not appear as a class available in the global object but rather should be pulled through require("objc!UIKit").
Consider implementing this on top of the SystemJS #165 instead of the current Require implementation.

We will try to keep that backward compatible and preserve the SDK APIs in the global object but we will try to promote the require usage as best practice.

3rd party static libraries

We need to support static libraries added in a NativeScript for iOS project.

One of the use cases is adopting existing codebase that is not available in source form.
We had request for the MagTek hardware support. They do distribute officially a static library.

We are not certain for implementation:

  1. Ideally the NativeScript users will use a library add like command with the lib*.a file, point the headers that declare the exposed APIs and provide additional flags if necessary. Since static libraries does not declare their dependencies the developers may also need to resolve them.
  2. As an alternative we can let the clients set up the Xcode project and link the library themselves as well as set header search paths, and we can try to simply generate metadata for these headers and expect that the static libraries are setup properly.
  3. We can also investigate if we can provide tooling to wrap static libraries in shared frameworks that work with the already existing tooling.

Create small examples using:

  • Static Library
  • Static Framework - #141
  • Cocoa pods example - #144
  • Consume Objective-C Code in the Project - #145

Also we should keep an eye on this issue, and try to satisfy its prerequisites. (pods for example)

Add out of the box support for:

  • Consuming Objective-C Code in the Project - #146
  • Static Framework added through Plugins
  • Write an article how to wrap static library into a framework - #147
  • Cocoa pods added through Plugins - #94

News/Rumors
Google is embracing CocoaPods to bring its services to iOS developers

NSDecimalNumber marshalling

Currently NSDecimalNumber (which inherits from NSNumber) is marshalled as JS number primitive and the precision is lost. We should create a wrapper object instead like we do for NSString and NSMutableString.

CMake the JSC

Use CMake to build the JSC used in NativeScript for iOS.

  • Verify with the AppStore
  • Update build scripts
  • Update Jenkins bulds
  • Pass excessive testing NativeScript (automation tests etc.)
  • Investigate a crash on one of the devices we have
  • Update Web Inspector - #163
  • JSC unit tests - #50
  • Update the build performance
  • Migrate the NSDictionary adapters
  • Update the README.md
  • Update documentation with ES6 features - #122
  • Add lib.d.ts with the globals of our JSC version - #218
  • Performance and memory diffs - #185
  • Fix TypeScript inheritance - #178

Failed to build JSC

Running "exec:libNativeScript_i386_x86_64" (exec) task
>> 2015-03-17 13:57:59.276 xcodebuild[75692:1007] +[MCLog load], env: (null)
>> 2015-03-17 13:57:59.278 xcodebuild[75692:1007] +[MCLog pluginDidLoad:], NSBundle </Users/admin/Library/Application Support/Developer/Shared/Xcode/Plug-ins/MCLog.xcplugin> (loaded)
>> ** BUILD FAILED **
>> 
>> 
>> The following commands produced analyzer issues:
>> ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-bvfhtokzrqkgxqhitqycfkossseh/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.analyzer
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-bjvuvnszjqgedbccadprdsmucacj/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.analyzer
>> (2 commands with analyzer issues)
>> 
>> The following build commands failed:
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-cdzokvntawqmhxchizvfgcxdbsvl/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-bpvwiwtcwzhhjscvlnbcwkzipguc/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-afqkafmuzxgvjwewufeqgtdypype/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-badphdphizkkoqbkzouewsnygudg/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal i386 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-bvfhtokzrqkgxqhitqycfkossseh/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.analyzer
>>  ProcessPCH++ /Users/admin/Library/Developer/Xcode/DerivedData/NativeScript-fgiklipfbakxszehhukovewaiiey/Build/Intermediates/PrecompiledHeaders/NativeScript-Prefix-bjvuvnszjqgedbccadprdsmucacj/NativeScript-Prefix.pch.pch NativeScript/NativeScript-Prefix.pch normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.analyzer
>> (6 failures)
>> Exited with code: 65.
Warning: Task "exec:libNativeScript_i386_x86_64" failed. Use --force to continue.

iOS Extensions Research

We need to build and distribute a shared framework out of the NativeScript.framework. This should be relatively easy, we have an internal proof of concept spike that proved that today views work with such framework. It should be distributed in the "tns-ios" npm package. However we should be sensitive for the filesize.

Then we need to provide bootstrappers and instructions how each type of the extension types can be set up manually. Please note that we will not integrate this in the CLI yet.

The most valuable deliverable would be a working WatchKit example. For integration with storyboards we will be ok to require manually written headers for now. In future if we provide our own XML markup for the WatchKit we will be able to generate headers from the XML. Or we can generate headers out of TypeScript declaration files if this would be more familiar to JavaScript developer.

We need to have only one copy of the metadata.

Images on tab buttons

Hi,

Can I add images on tab buttons? Currently, I can do this:
<TabEntry title=“Title">
but I don’t find any image possibility. Is there any?

Thanks,
Eduárd

Unicode console logs in stderr

When using console.log() with non-ASCII characters the output in stderr is trash. (The output in the console client is fine though.) The reason for this seems to come from utf8ForRange which calls convertLatin1ToUTF8.

Run the unit tests for JSC

In order to adopt rapidly new versions of the JSC we will need an infrastructure to run the relevant unit tests for JSC on emulator and devices.

Remove the pre-packaged metadata

Once we have the metadata-generator's performance improved enough to run before build, we should drop the metadata from the npm package and run the tool before build. This should help us keep up with new iOS versions and native libraries.

Implicitly convert Pointer to id

Think about implicitly converting pointer to ids. This will make the following code easier to translate to NativeScript:

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor blackColor] CGColor], nil];

Currently, this looks like this on NS:

var gradient = CAGradientLayer.layer();
var colorsArray = NSMutableArray.alloc().initWithCapacity(2);
colorsArray.addObject(interop.types.id(UIColor.redColor().CGColor));
colorsArray.addObject(interop.types.id(UIColor.blueColor().CGColor));
gradient.colors = colorsArray;

If there is implicit convertion - we can get rid of the interop.types.id( ... ) calls

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.