Posts

Post marked as solved
3 Replies
Thank you Claude! I changed the IP address of my Mac manually for testing the app. Even though I didn't get the expected result (seeing the popup message), but I think your answer has got to the bottom of the specific question I asked.
Post marked as solved
2 Replies
Hi Claude31, OOPer, Thank you for pointing out what I missed. I check the individual targets and found the "iOS Deployment Target". After updating each of them to iOS 14.1, I can delete the unnecessary code now.
Post not yet marked as solved
3 Replies
Hi OOper, For the "UIKit App Delegate" option of Life Cycle, I found it is only available if I chose "iOS" App template for the new project. If I chose "Multiplatform" template, then there is no Life Cycle choices for me to select. Thank you!
Post not yet marked as solved
3 Replies
Hi OOper, Thank you for your suggestion about using Life Cycle as UIKit App Delegate. I will try it. On another hand, I found a way to get a UIViewController object from ContentView.swift file, like the code below. Is this solution Ok? or there will be issue? Thank you! import SwiftUI import MoPubSDK struct ContentView: View {     var body: some View {         return         Text("Hello, world!")             .padding()             .onAppear(){                 // for MoPub: Check whether you must show the consent dialog                 let shouldShow = MoPub.sharedInstance().shouldShowConsentDialog;                 // for MoPub: Start loading the consent dialog. This call fails if the user has opted out of ad personalization                 let myUIViewController : UIViewController = (UIApplication.shared.windows.first?.rootViewController)!                 MoPub.sharedInstance().loadConsentDialog(){ a in                     MoPub.sharedInstance().showConsentDialog(from: myUIViewController, completion: nil)                 }             }     } }
Post marked as solved
4 Replies
After some reading I think I understand what is the .modulemap file for: it is for the Clang complier to support the newly introduced "module" mechanism for C-like programming languages (C, C++, Objective-C, etc.). Even though I said "module" is new, I haven't actually check when it is introduced. What I am sure is it is newer than the basic #include mechanism. One of the difference it makes is to allow separate compilation of individual modules. While the "module" mechanism is being used, the original .h files (header files) of the C-like language library can still be used, and an additional file with .modulemap extension is added to specify which header file is mapped to which module name to be consumed. The syntax of this .mdulemap file is "Module Map Language". https://releases.llvm.org/3.3/tools/clang/docs/Modules.html#module-map-language
Post marked as solved
4 Replies
Hi Claude31, The 3rd link you provide have some examples using the "umbrella" keyword. I will try to start understand more from there. I checked the source code of the SwiftyJSON, surprisingly it is written in Swift, even though the CocoaPods adds C code to it. https://github.com/SwiftyJSON/SwiftyJSON Thank you,
Post marked as solved
4 Replies
Hi Claude31, Sorry, I missed the curly braces. Yes you are right. The code should be framework module SwiftyJSON { umbrella header "SwiftyJSON.h" export * module * { export * } }
Post not yet marked as solved
2 Replies
Hi wingover, That's because I have a lot of data want to share in the application across different pages. I just made a singleton class and put all the data inside. Does that cause issue? Thank you! Sui
Post not yet marked as solved
5 Replies
Hi Claude31, The expression "self.view.window.windowScene" is from the Google AdMob documentation. Since I am not allowed to post the link in the form, I copy-paste the code section below together with some description. The documentation doesn't tell what "self" is, but from there I assume the view should have a "window" property. However, I cannot get it when I try to use "self" in the "body" of a View definition. vvvvvvvvvvvvvvvvvvv from Google AdMob Doc vvvvvvvvvvvvvvvvvvvvvv Set the scene in an ad request In order to receive an ad that fits a specific window, you pass the view's windowScene to the ad request. The Google Mobile Ads SDK returns an ad with valid size for that scene. (void)loadInterstitial {   GADRequest *request = [GADRequest request];   request.scene = self.view.window.windowScene;   [self.interstitial loadRequest:request]; }
Post not yet marked as solved
5 Replies
Just an update of the status, for now I set the "Enable Multiple Windows" in info.plist to false, such that I don't need to get the scene for now. The original reason I want to get the scene object is because I am trying to use Google Admob in an iOS app for iPad. Since iPad by default supports multiple windows, Admob is asking me to input scene. After disabling multiple windows, AdMob is no longer asing for it. Google AdMob link is not allowed to be posted in the forum, so I cannot include it.
Post not yet marked as solved
5 Replies
Hi Claude31, The stackoverflow link shows a way that needs to inject hosting window in root ContentWindow from AppDelegate or SceneDelegate. However, in the new Multiplatform App template, there is no AppDelegate/SceneDelegate by default. Seems they are being deprecated. Is there a way to do it without AppDelegate/SceneDelegate? Thank you!
Post marked as solved
3 Replies
Thank you Claude31!
Post marked as solved
5 Replies
Thank you Claude31!The code I initially posted was modified from some complicated original code to present the issue in a simple way, and I didn't put it back to test before posting. Thank you for checking this and correcting it. For other reader's convenience, I pasted your code to a single view project and update it to make sure it works. I got:struct ContentView: View { @State var showDetail: Bool = false @State private var displayPopupMessage: Bool = false var body: some View { NavigationView { VStack { NavigationLink(destination: DetailView(), isActive: self.$showDetail) { EmptyView() } Button(action: { self.displayPopupMessage = true }) {Text("Alert and Navigate")} .alert(isPresented: $displayPopupMessage){ Alert(title: Text("Warning"), message: Text("This is a test"), dismissButton: .default(Text("OK"), action: {self.showDetail = true}) ) } } } } } struct DetailView :View { var body: some View {Text("details ...")} }Above code was tested in a project to be fully working. I added the NavigationView to make sure it works in a separate project.This solution confirms that each section of code should only make one popup message or navigation change.Thank you!
Post marked as solved
5 Replies
I found a work-around: use .sheet modifier instead of .alert modifier, such that I can use the onDismiss closure to toggle the state variable for navigation link after message is dismissed.Reference: htt ps:// swiftwithmajid.com/2019/07/24/alerts-actionsheets-modals-and-popovers-in-swiftui/However, I feel that this solution is pretty complicated, and wondering whether there is any better idea.