Post

Replies

Boosts

Views

Activity

Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
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)                 }             }     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’21
Reply to What language is the "unbrella" keyword from?
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
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to What language is the "unbrella" keyword from?
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,
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’21
Reply to Is there a way to pretend IP address in Xcode Device Simulator?
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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to Xcode: Why I need #available(iOS 14.0, *) even if the project iOS Deployment Target is 14.1?
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.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
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!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to get the UIViewController instance for displaying dialog when the app starts up?
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)                 }             }     } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to What language is the "unbrella" keyword from?
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
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to What language is the "unbrella" keyword from?
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,
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to What language is the "unbrella" keyword from?
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 * } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to SwiftUI: memory leaks if update environment object in a view
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
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21