I upgraded my iOS application with Xcode 14.2 after which application is running fine but when I try to run the tests it removes function calls automatically while building and gives a compile time error .
if viewController.isKind(of: AssignmentDetailViewController.self) && !viewController.isVisible() {
navController.popToRootViewController(animated: true)
The actual code is this but when I try to run the tests it removes () from isVisible()
if viewController.isKind(of: AssignmentDetailViewController.self) && !viewController.isVisible {
navController.popToRootViewController(animated: true)
isVisble function
func isVisible() -> Bool {
return self.isViewLoaded && self.view.window != nil
}
Related
Good morning!
I have a strange problem where i can run & authenticate my user on my ios device perfectly fine running the app using the command below.
ionic capacitor run -l --external
Using an emulator, it works sometimes, though not always.
When I try to deploy the app using Xcode, the app opens and looks normal, but if I try to send authentication requests to firebase, the app just keeps on loading, although the requests are successfully performed.
I first thought the problem was because of using LocalStorage so I rebuilt everything using Ionic Storage. But that didn't help.
I tried different versions of adding the Firebase SDK in Swift or in the Cocoa Pods file but the behaviour doesn't change so I don't believe that this is a issue with a wrong firebase configuration, what is the proper way to do this by the way - or is Ionic doing this for me already?
The output of Xcode doesn't provide any valuable information either.
2021-12-01 11:20:13.990875+0100 App[3162:27661] Writing analzed variants.
2021-12-01 11:20:14.125754+0100 App[3162:27661] KeyboardPlugin: resize mode - native
⚡️ Loading app at capacitor://localhost...
2021-12-01 11:20:14.552490+0100 App[3162:27661] Writing analzed variants.
⚡️ WebView loaded
⚡️ [log] - Angular is running in development mode. Call enableProdMode() to enable production mode.
⚡️ [log] - null
⚡️ To Native -> App addListener 60635511
2021-12-01 11:20:21.393141+0100 App[3162:27661] [Accessibility] WKContentView[#] set up: # pid: # MACH_PORT -830404096
login-function
loginWithEmail() {
let email: string = this.loginForm.get("email").value;
let password: string = this.loginForm.get("password").value;
this.loadingService.present({
message: "Logging in . . ."
});
this.authService
.loginWithEmail(email, password)
.then((result) => {
this.authService.SetUserData(result.user)
this.resetLoginForm();
this.loginSuccess();
this.router.navigateByUrl("/tabs/intensity");
})
.catch(error => {
console.log(error);
this.loginFailed(error);
});
}
login-success
loginSuccess() {
this.loadingService.dismiss();
this.toastService.present({
message: "Welcome back!",
duration: 3000,
color: "secondary"
});
}
login-with-email
import { AngularFireAuth } from "#angular/fire/compat/auth";
...
async loginWithEmail(email: string, password: string) {
return await this.afAuth.signInWithEmailAndPassword(email, password);
}
set user-data function
SetUserData(user) {
this.user = user;
const userRef: AngularFirestoreDocument<any> = this.afs.doc(`users/${user.uid}`);
const userData: User = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
photoURL: user.photoURL,
emailVerified: user.emailVerified
}
return userRef.set(userData, {
merge: true
})
}
Running it multiple times some times I get this error.
API error: <_UIKBCompatInputView: 0x7fb965726040; frame = (0 0; 0 0); layer = <CALayer: 0x600002f718a0>> returned 0 width, assuming UIViewNoIntrinsicMetric
I am really stuck on this and would appreciate any help. Thank you & kind regards.
Ionic 6.18.1
Angular 12.1.5
Xcode Version 13.1 (13A1030d)
I'm getting an error after upgrading to NS 7 and building in xcode. I can build successfully from the CLI, run the app and everything is fine but when I build in xCode and run on physical device or simulator and try to log in, I get this error.
In the log outputs self = (SAMKeychainQuery*) & password = (NSSTRING *) nil so it's not getting the password value but why would it have access to it when building from the CLI but not Xcode?
I'm running "#nativescript/core": "^7.0.13", "#nativescript/ios": "7.0.6", Xcode 12.
Here is my password textfield:
<TextField
:isEnabled="!processing"
ref="password"
class="input placeholderColor"
hint="Password"
secure="true"
v-model="user.password"
#loaded="passwordTextField"
:returnKeyType="isLoggingIn ? 'done' : 'next'"
fontSize="18"
/>
//login function
async login(user) {
try {
console.log("in login() in authservice")
const loginRequest = await firebase.login({
type: firebase.LoginType.PASSWORD,
passwordOptions: {
email: user.email,
password: user.password,
},
});
const handleLogin = await this.handleLogin(loginRequest);
return handleLogin;
} catch (error) {
return error;
}
}
My login() function isn't even firing when I build from Xcode but again all is well from the CLI.
Completely removing the #nativescript/secure-storage plugin then ns clean and reinstalling secure-storage plugin worked.
Still have no idea why it was working from CLI and not Xcode if the plugin wasn't functioning properly though.
My iOS app was working until I updated to latest Xcode (10.2.1) and updated pods with "pod update". I was previously using Xcode 9.4.1 and swift 3. I did the update because I couldn´t upload to appstore with that version of Xcode.
The rest of the functions work fine (including firebase phone authentication) but all the "Observe" firebase database functions are never triggered. It builds succesfully and no errors shown.
I tried with no success:
-Download plist file from firebase.
-Set database rules to true for read and write.
-Set Deployment Target to 11.0 and podFile platform: ios, '11.0'
podFile:
platform :ios, '12.0'
target 'appname' do
use_frameworks!
pod 'Firebase/Database'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'SwiftyStoreKit'
pod 'Onboard'
pod 'SDWebImage'
pod 'IQKeyboardManagerSwift'
end
Firebase initialized in AppDelegate - didFinishLaunchingWithOptions:
FirebaseApp.configure()
Everything works as expected until this:
Auth.auth().signIn(with: credential) { (user,error) in
if error != nil {
print(error)
} else {
print(phone number: \(String(describing: user?.user.phoneNumber))")//this is successfully printed
let userInfo = user?.user.providerData[0]
print(Provider ID: \(String(describing: userInfo?.providerID))")//this is successfully printed
if let user = Auth.auth().currentUser {
let uid = user.uid
let ref = Database.database().reference()
ref.child("users").observeSingleEvent(of: .value, with: { (snapshot) in
if snapshot.hasChild(uid) {
print("user already exists")//this never gets printed
} else {
let values: [String: AnyObject] = ["phoneNumber": user.phoneNumber as AnyObject]
let userRef = ref.child("users").child(uid)
userRef.updateChildValues(values, withCompletionBlock: { (err,ref) in//user never gets created in database but it is created in firebase
if err != nil {
print(err)
return
}
})
}
let tabBarController = CustomTabBarController()//this never gets executed
present(tabBarController, animated: true)
})
}
}
}
The problem was the cocoapods version, I had 1.5.3. Once I updated to 1.7.2 everything works as expected.
Automated the e2e tests in CI enabled framework with protractor and jasmine in VSTS. Used the jasmine custom reporter to load the e2e test results under sauce labs tab in VSTS build definition. But, it is not loading all the tests. It is displaying only the last e2e test ran in the build. Console log is getting printed for all the e2e tests. Please see the code below.
let sauceLabsReporter: jasmine.CustomReporter = {
specDone: (result: jasmine.CustomReporterResult): void => {
Util.log('*** sauceLabsReporter: result.fullName:', result.fullName);
Util.log('*** sauceLabsReporter: result.status:', result.status);
Util.log('*** sauceLabsReporter: result.testCaseId:', result.testCaseId);
if (result.testCaseId) {
result.fullName = `(Testcase ID: ${result.testCaseId}): ${result.fullName}`;
Util.log('*** sauceLabsReporter: UPDATED result.fullName:', result.fullName);
}
Util.updateSauceLabsJobTitle(result.fullName);
if (result.status) {
Util.updateSauceLabsTestState(result.status);
}
}
};
export function updateSauceLabsJobTitle(title: string): promise.Promise<void> {
let fullTitle: string = `${title} | (${getHostname()})`;
return browser.executeScript(`sauce:job-name=${fullTitle}`)
.then(() => browser.getSession())
.then((session: Session) => {
if (isThisVSTSBuildAgent()) {
//The VSTS Sauce Labs add-on gets information by parsing the console log.
//tslint:disable-next-line:no-console
console.log(`SauceOnDemandSessionID=${session.getId()} job-name=${fullTitle}`);
}
});
}
export function updateSauceLabsTestState(state: string): promise.Promise<{}> {
return browser.executeScript(`sauce:job-result=${state}`);
}
I work on the same project as Padma. It had to do with restartBrowserBetweenTests being set to false which conflates all tests into a single job. After setting it to true, each test became its own job.
When I try to run JSCover with PhantomJS, I see below ERROR:
Steps followed:
1) Run the JSCover Server:
java -jar ~/JSCover/target/dist/JSCover-all.jar -ws --report-dir=report
2) Run the PhantomJS runner with JSCover:
*phantomjs --debug=true ~/JSCover/src/test/javascript/lib/PhantomJS/run-jscover-jasmine.js
localhost8080/<app>/module/framework/test/SpecRunner.html
TypeError: 'null' is not an object(evaluating''document.body.querySelector('.description').innerText')`
phantomjs://webpage.evaluate():3
phantomjs://webpage.evaluate():22
phantomjs://webpage.evaluate():22
2013-09-19T16:36:07 [DEBUG] WebPage - evaluateJavaScript result QVariant(, )
2013-09-19T16:36:07 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function () {
jscoverage_report('phantom');
})(); })()"
2013-09-19T16:36:07 [DEBUG] WebPage - evaluateJavaScript result QVariant(, )
2013-09-19T16:36:07 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: localhost8080/<app_home>/lib/backbone/1.0.0/backbone.js?cb=0.5381254460662603
This was an issue that I ran into yesterday. It turns out that the example script does not work for newer versions, so I built a new Phantom Script that works for Jasmine 2.X which fixes it. You can locate the working script here in my repository:
https://github.com/tkaplan/PhantomJS-Jasmine
I faced with the same issue when I try running Jasmine with PhantomJS.
I realized that the latest version of Jasmine-html.js (jasmine-2.0.0-rc2)
does not go along with PhantomJS's run-jasmine.js (phantomjs-1.9.2-windows).
In the jasmine-2.0.0-rc2 version of Jasmine-html.js,
The '.description' class is not available if all tests passed.
This 'description' class is created only if any test failed.
Thus, when I run the phantomjs with all tests passed, I get the above error message.
I modified run-jasmine.js to adapt to Jasmine-html.js (jasmine-2.0.0-rc2) to
resolve this issue.
Are you loading your tests asynchronously? I use requirejs for modular javascript. It is also used to load the test specs:
<script data-main='SpecRunner' src='/test/scripts/libs/require.js'></script>
When using JSCover, the run-jscover-jasmine.js script does not account for this async behaviour, so the DOM nodes referenced in the query do not exist (yet). I modified the script to delay the waitFor call by 1 second:
page.open(system.args[1], function(status){
if (status !== "success") {
console.log("Unable to access network");
phantom.exit();
} else {
// Added 1s delay here
window.setTimeout(function() {
waitFor(function(){
return page.evaluate(function(){
return document.body.querySelector('.symbolSummary .pending') === null
});
}, function(){
var exitCode = page.evaluate(function(){
console.log('');
console.log(document.body.querySelector('.description').innerText);
var list = document.body.querySelectorAll('.results > #details > .specDetail.failed');
if (list && list.length > 0) {
console.log('');
console.log(list.length + ' test(s) FAILED:');
for (i = 0; i < list.length; ++i) {
var el = list[i],
desc = el.querySelector('.description'),
msg = el.querySelector('.resultMessage.fail');
console.log('');
console.log(desc.innerText);
console.log(msg.innerText);
console.log('');
}
return 1;
} else {
console.log(document.body.querySelector('.alert > .passingAlert.bar').innerText);
return 0;
}
});
page.evaluate(function(){
jscoverage_report('phantom');
});
phantom.exit(exitCode);
});
}, 1000);
}
});
Depending on the amount of code loaded, you may have to increase the delay.