Giter Site home page Giter Site logo

nsappwithwatch's Introduction

A NativeScript app with an associated watchos app.

The app demonstrates communication from the phone app to the watch.

If you launch the phone app and the watch app you can click the "Send Message To Phone" button and should see the number on the screen change in sync.

Building scenario

I wanted a cli based build that I can build with iOS App Development profiles to put on various test devices.

To do the same you will need to change the app id in nativescript.config.ts and have 3 corresponding profiles for the app, watch app and extension.

e.g. for app ids

  • com.test.app
  • com.test.app.watchkitapp
  • com.test.app.watchkitapp.watchkitextension

And modify ios_build_options/exportPlist.plist to match.

see additions to

  • App_Resources/iOS/watchextension/jasonwapp%20Extension/extension.json
  • App_Resources/iOS/watchapp/jasonwapp/watchapp.json

xcode 13 does not generate the info.plist for the watch apps so extra work would have to be done to add them manually. ( I used 12.5 to generate)

Building

nsappwithwatch = whatever the directory it is checked out to is named.

  1. run ns prepare ios

    A plugin modifies the generated IOS project in two ways to allow building ( in after-prepare )

    • sets SUPPORTS_UIKITFORMAC = NO (from project template it is set to YES)
    • replaces CODE_SIGN_IDENTITY[sdk=iphoneos*] with CODE_SIGN_IDENTITY as per NativeScript/nativescript-cli#5291 Checking config.ast.value.get("buildSettings").get("SDKROOT") in pbxproj-dom/xcode.ts could decide to set the sdk
  2. run archive xcodebuild -workspace platforms/ios/nsappwithwatch.xcworkspace -scheme nsappwithwatch archive DEVELOPMENT_TEAM=<TEAM ID> -archivePath builds/MyApp.xcarchive -allowProvisioningUpdates

  3. run export ( the exportPlist.plist need to be edited for your profile uuids etc.) xcodebuild -exportArchive -exportOptionsPlist ios_build_options/exportPlist.plist -archivePath builds/MyApp.xcarchive -exportPath builds/out

Assuming the 3 development profiles for the app, watchapp, extension are already available on the machine out will pop out an ipa that will run on devices.

HOWEVER I ran into this issue: https://developer.apple.com/forums/thread/682775?page=3 because my phone is on IOS15

Resigning the watch app was the only resolution that worked for me.

Steps to resign: ( while in builds/out )

  1. Unpack the ipa

    unzip -q nsappwithwatch.ipa

  2. Resign the watch extension

    codesign -s "Your Code Sign Identity" -f --preserve-metadata --generate-entitlement-der Payload/nsappwithwatch.app/Watch/jasonwapp.app/Plugins/jasonwapp\ Extension.appex

  3. Resign the watch app codesign -s "Your Codesign Identity" -f --preserve-metadata --generate-entitlement-der Payload/nsappwithwatch.app/Watch/jasonwapp.app

  4. Resign the main app

    codesign -s "Your Codesign Identity" -f --preserve-metadata --generate-entitlement-der Payload/nsappwithwatch.app

  5. Repackage the ipa

    zip -qr "app-resigned.ipa" Payload

Building with ns

With the above ns run ios will launch the app but not the watch app in the simulators.

I don't think building/signing will work with ns because of the exportOptions issue NativeScript/nativescript-cli#5291

Versions

  • ns 8.1.3
  • xcode 13

Downgrade the watch simulator os to 7.0 ( there is a bug in the latest watch os simulator that the communication from app to watch does not work and fails sliently)

nsappwithwatch's People

Contributors

jcassidyav avatar

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.