UIMain屏幕不是函数错误NativeScript iOS
我正在尝试在iOS模拟器上运行我的NativeScript应用程序。由于iTunes希望应用程序通过Xcode 9.0或更高版本发布,我不得不从使用Xcode 7.3的NativeScript iOS v3.1(我的应用程序运行得非常好)升级到使用Xcode 9.0的NativeScript iOS v4.2。现在很遗憾,我无法在任何设备上执行我的应用程序。它一路启动,我看到加载屏幕,然后遇到以下错误:UIMain屏幕不是函数错误NativeScript iOS,ios,xcode,nativescript,Ios,Xcode,Nativescript,我正在尝试在iOS模拟器上运行我的NativeScript应用程序。由于iTunes希望应用程序通过Xcode 9.0或更高版本发布,我不得不从使用Xcode 7.3的NativeScript iOS v3.1(我的应用程序运行得非常好)升级到使用Xcode 9.0的NativeScript iOS v4.2。现在很遗憾,我无法在任何设备上执行我的应用程序。它一路启动,我看到加载屏幕,然后遇到以下错误: CONSOLE ERROR file:///app/tns_modules/zone.js/
CONSOLE ERROR file:///app/tns_modules/zone.js/dist/zone-node.js:419:27: Unhandled Promise rejection: UIScreen.mainScreen is not a function. (In 'UIScreen.mainScreen()', 'UIScreen.mainScreen' is an instance of UIScreen) ; Zone: angular ; Task: Promise.then ; Value: TypeError: UIScreen.mainScreen is not a function. (In 'UIScreen.mainScreen()', 'UIScreen.mainScreen' is an instance of UIScreen)
CONSOLE ERROR file:///app/tns_modules/zone.js/dist/zone-node.js:421:23: Error: Uncaught (in promise): TypeError: UIScreen.mainScreen is not a function. (In 'UIScreen.mainScreen()', 'UIScreen.mainScreen' is an instance of UIScreen)
当我回到使用NativeScript iOS 3.1.0的Xcode 7.3时,它又能正常工作了。我不知道我能做些什么来解决这个问题
我看到了一些与UIScreen.main屏幕错误相关的问题(例如),但它们似乎是与本机iOS相关的,我无法从NativeScript中影响它们(至少我不知道如何才能做到)
下面是我的配置中的一些内容:
package.json:
{ //...
"tns-ios": {
"version": "4.2.0"
}
},
"dependencies": {
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/platform-server": "2.0.0-rc.4",
"@angular/router": "3.0.0-beta.2",
"nativescript-angular": "0.3.1-2016-08-04-787",
"nativescript-calendar": "1.1.2",
"nativescript-drop-down": "1.3.2",
"nativescript-fresco": "1.0.6",
"nativescript-ng2-translate": "1.1.1",
"nativescript-social-share": "1.3.0",
"nativescript-telerik-ui": "1.3.1",
"ng2-translate": "2.2.2",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"tns-core-modules": "^2.4.4",
"typescript": "^1.8.10",
"url": "0.10.3",
"zone.js": "0.6.12"
},
"devDependencies": {
"babel-traverse": "6.10.4",
"babel-types": "6.10.2",
"babylon": "6.8.1",
"filewalker": "0.1.3",
"lazy": "1.0.11",
"nativescript-dev-typescript": "0.3.2",
"nativescript-dev-webpack": "0.0.20",
"typescript": "1.8.10"
}
}
build.xconfig:
CODE_SIGN_IDENTITY = iPhone Developer;
DEVELOPMENT_TEAM = %Number%;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
info.plist:
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>%App_Name%</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0.9.4</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>iPhoneOS</string>
</array>
<key>NSCalendarsUsageDescription</key>
<string>my app needs access to the calendar to create new entries</string>
<key>Minimum </key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>%ip%</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
CfBundledDevelopmentRegion
EN
CbundleDisplayName
%应用程序名称%
Cbundlexecutable
${EXECUTABLE_NAME}
CbundleInfo字典版本
6
CFBundleName
${PRODUCT_NAME}
CbundlePackageType
应用
CbundleShortVersionString
2.0.9
CFBundleSignature
????
循环流化床锅炉
2.0.9.4
LSREQUIRESPHONEOS
UIRequiresFullScreen
UIRequiredDeviceCapabilities
armv7
UI支持接口方向
UIInterfaceOrientationPortrait
UI支持界面方向~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientation上下方向图
CbundleSupportedPlatform
iPhoneOS
NSCalendarsUsageDescription
我的应用程序需要访问日历才能创建新条目
最低限度
NSAppTransportSecurity
NSExceptionDomains
本地服务器
N异常低安全Http负载
n包括多个域
%ip%
N异常低安全Http负载
n包括多个域
问题在于,您的tns核心模块
是一个较旧的版本(大约2年前),并且正在使用已经弃用的iOS API,其中主屏幕
是一个函数(现在它是一个属性)。您只更新了使用新ios API的tns ios运行时,而旧tns核心模块中的代码使用旧API。总之,这是行不通的,您必须更新tns核心模块
和nativescript angular
+所有相关依赖项。您可能还需要到处更新代码隐藏文件
可以找到包/json
依赖项的升级说明
中断从2.x.x迁移时需要考虑的更改
参见tns核心模块的变更日志
最后,可以找到nativescript angular
的变更日志