How to force portrait orientation in NativeScript 8.x for iOS and Android - nativescript

There are a few community plugins that made for this, but none of them support NativeScript 8.x. They utilize "tns-core-modules" rather than "#nativescript/core". I've only found one paid plugin that supports NativeScript 8.x.
Is there truly no way to force portrait orientation natively in NativeScript? If not, it seems like a major oversight for a framework dedicated to making mobile apps.

You will have to update your AndroidManifest.xml & Info.plist in your App_Resources.
AndroidManifest.xml
Set screenOrientation to portrait on your main activity
<activity android:name="com.tns.NativeScriptActivity"
...
android:screenOrientation="portrait">
Info.plist
Keep only the portrait orientation, remove rest from UISupportedInterfaceOrientations.
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
Note: Make sure you run a clean build after these changes.

Related

Application's iCloud drive folder doesn't show in macOS

I have an app that needs to store video files in it's own container folder in iCloud Drive. I have tried suggestions from most forums and I still couldn't resolve this issue.
These are the things I did to setup a cloud container for my app -
Added iCloud capability. Selected 'iCloud Documents' for Services and selected the appropriate iCloud container that I had created through my developer account.
Added the following entry in Info.plist
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.TeamName.AppName</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>AppName</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
These are the values in the entitlement file
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.TeamName.AppName</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.com.TeamName.AppName</string>
</array>
Have tried with new bundle identifiers and cloud containers.
Have tried updating the Version and the Build value
The app folder is created at '/Users/{user}/Library/Mobile\ Documents/iCloud~com~TeamName~AppName/Documents' and I can see the files I've written to it.
I can find these files at iCloud -> Manage Storage -> AppName on my iPhone too.
Will 'NSUbiquitousContainerIsDocumentScopePublic' be accepted as true only when an app is released on the Appstore? Or it's just that I'm missing something here?
Same here, I followed every tip I could find here and on other websites, but still the folder / files are not showing up visibly.
Problem: ubiquitous container works, files can be read and written, but are not showing up in macOS Finder, nor in the Files app on iOS devices.
macOS 11.5, iOS 14.7, Xcode 12.5.1
I have tried:
everything stated here: https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/FileProvider.html
everything stated here: https://developer.apple.com/library/archive/qa/qa1893/_index.html
every variation of info.plist values for NSUbiquitousContainers (eg. both the container id and my bundle id)
every variation of info.plist values for NSUbiquitousContainerIsDocumentScopePublic
every variation of info.plist values for NSUbiquitousContainerName
every variation of info.plist values for NSUbiquitousContainerSupportedFolderLevels
creating new containers
changing the apps' version and build numbers, including only increasing CFBundleShortVersionString.
changing the apps' bundle identifier
deleting and reinstalling the app
reboots of used devices
switching off/on iCloud drive for the user on all devices
It is driving me crazy. Who can help?

Can't deploy to iPad when I add iCloud entitlement

Using Xcode and Visual Studio for Mac:
In Xcode, I can make, deploy and run an out-of-the-box HelloWorld app to my provisioned iPad.
Also in Xcode, I can add iCloud to the same app (via entitlements), and it deploys and runs on my iPad.
In VS for Mac, I can make and deploy a blank Xamarin Forms HelloWorld app and it runs on my iPad.
However, if I add iCloud to the entitlements.plist for the Xamarin forms app, it won't deploy to my iPad.
I get the following for #4:
ApplicationVerificationFailed: Failed to verify code signature of /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.tlZMLz/extracted/HelloWorldV.iOS.app : 0xe8008016 (The executable was signed with invalid entitlements.)
error MT1006: Could not install the application '/Users/Huber/Projects/HelloWorldV/iOS/bin/iPhone/Debug/device-builds/ipad5.3-11.1.1/HelloWorldV.iOS.app' on the device 'Denny's iPad': Your code signing/provisioning profiles are not correctly configured. Probably you have an entitlement not supported by your current provisioning profile, or your device is not part of the current provisioning profile. Please check the iOS Device Log for details (error: 0xe8008016).
Application could not be uploaded to the device.
The entitlements.plist file that Xamarin generates is:
<?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>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.DennyHuber.HelloWorldV</string>
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
</array>
</dict>
</plist>
I have Key-Value Storage and iCloud Documents both checked.
Can anyone help?
Thanks,
Denny Huber
You need to go to developer.apple.com and regenerate provisioning profile with new entitlements. After that, I advise you to manually delete all provisions, because sometimes it still tries to sign with an old one.
The provisions located in ~/Library/MobileDevice/Provisioning Profiles
After that go to Xcode, Setting -> Accounts -> Select your program, and press Download Manual Profiles.
After that clean the project and try to build again.

Info.plist may not contain the UIRequiredDeviceCapabilities key

When I try to upload my iOS + apple watch app to iTunes using Application Loader, I get the error message
ERROR ITMS-90595: "Unsupported Key. The Info.plist of bundle Watchless.app/Watch/WatchlessWatchApp.app/PlugIns/WatchlessWatchApp Extension.appex may not contain the UIRequiredDeviceCapabilities key."
Info.plist contains
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>healthkit</string>
</array>
which I think is absolutely necessary because both, watch app and iOS app depend heavily on HealthKit.
The entry is generated when I turn on the HealthKit capability of the watch extension target.
I am running out of ideas what to change.
Using XCode 7.2, Application Loader 3.4
UIRequiredDeviceCapabilities are just your way of saying "I don't want to be installed on device without this functionality".
Removing this will not affect your Watch extension using HealthKit.
Just remove the UIRequiredDeviceCapabilities from the plist in your extension and it should be fine.

WKWebView problems in iOS 9

I'm having trouble with WKWebView in XCode 7 using the iOS 9 sdk. For some reason, half of the websites I try to load come up blank (for example mobile Facebook).
WKWebView worked perfectly when I built my app on iOS 8. I haven't changed any of the code for loading webpages (I used loadrequest with a nsurl), and I know that the webviews are active because some links do load.
Is this a possible bug?
This might be related to a new feature called ATS (App Transport Security), which was introduced in iOS 9.
Please see:
https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
All connections using the NSURLConnection, CFURL, or NSURLSession APIs
use App Transport Security default behavior in apps built for iOS 9.0
or later, and OS X 10.11 or later. Connections that do not follow the
requirements will fail.
It is possible to add exceptions or to allow any non-secured connections. For example, you can add this to your Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

iOS Device Orientation settings in project.pbxproj

I'm developing an Hybrid iOS application using Cordova (http://cordova.apache.org/).
I need to tweak the device orientation settings manually from the XCode project with Cordova hooks.
I was able to customise the deployment target and the targeted device family with IPHONEOS_DEPLOYMENT_TARGET and TARGETED_DEVICE_FAMILY fields in project.pbxproj respectively, however, can't seem to find how to change orientation settings from there.
I applied the same process that I used to discover the above fields:
Take a copy of project.pbxproj.
Modify the settings from within XCode.
Take another copy of the updated project.pbxproj.
Doing a diff between them.
However it didn't reveal any information for orientation settings change.
Are those settings saved somewhere else?
Finally found the answer.
Orientation settings are found in <project-name>-Info.plist XML file:
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>

Resources