Post

Replies

Boosts

Views

Activity

Removing folder from .app
I am using "Excluded Source File Names" in Xcode build settings to remove a folder from IPA. The given relative path is correct but for some reason, the folder that needs to be excluded is still exists in the .app file. Any idea why Excluded Source File Names is not working. The folder that I am trying to remove is listed under "Copy Bundle Resources" Here is the path "$(SRCROOT)/../foldera/folderb/foldertoberemoved"
1
0
1.3k
Jul ’21
Excluding few frameworks while extracting IPA
Hi,I have an Xcode project with multiple targets. I added a few custom frameworks to all the targets which increase the IPA file size. Actually, a few targets don't need to have these custom framework.I know we can exclude these frameworks by removing them from "Build Phases->Link Binaries With Libraries" for the particular target, but I am exploring to see whether these can be achieved by having a script so that we don't have to remove/add them manually whenever required.I have a custom plist file for each target which tells whether these frameworks are needed. Is there any command available to remove/strip the framework from the target while building the app so that I can write a script by referring the plist value.
2
0
2.0k
Jun ’21
Present SwiftUI without tap
I wanted to present an View with modal animation full screen on top the the existing view/viewcontroller programmatically(without button tap or tap gesture). Is it possible to present a view without button tap/tap gesture?
2
0
1.1k
Jul ’21
Pass Data from Swift to SwifUI
I developed a framework in Swift and designed a screen/view via SwiftUI. SwiftUI view will be presented on top of the Window by the class written in Swift. Now I need to pass the data from the Swift class to SwiftUI. Could one any help to know the best practice to pass the data to show the progress from Swift class to Swift UI. func A () {} func B () { // score will get updated frequently score = .... ScorePresenter().presentScoreUI() } } import SwiftUI struct ScorePresenter: { func presentScoreUI() { let hostController = UIHostingController(rootView: ScoreUI()) hostController = .overCurrentContext topViewController()!.present(hostController, animated: true, completion: nil) } } struct ScoreUI: View { var score = 1 Text(score).foregroundColor(.green) } When ever score changes in Score class ScoreUI must be updated accordingly.
2
1
1.2k
Jul ’21
Concurrency
What is the best way to print in the order for the given implementation (void) print:(NSString*) str while(true) { NSLog(@“%@”, str); } } [self print:@“123”]; [self print:@“ABC”]; [self print:@“456”]; [self print:@“DEF”]; output should be printing in the order continuously 123 ABC 456 DEF 123 ABC 456 DEF … … …
2
0
748
Oct ’21
DataFlow from Swift to SwfitUI
I have the business logic in Swift class and built UI using SwiftUI. Below the high level code that shows how SwiftUI and its subview receives the data from Swift. Please let me know if its correct approach class SwiftClass{     var score = "1"     func A () {}          func B () {         // score will get updated frequently         let scoreModal =  ScoreUIViewModel()         let scoreUI: ScoreUI = ScoreUI(showModal: .constant(true), scoreUIViewModel: scoreModal)         DispatchQueue.main.async {             scoreUI.displayScoreUI()         }        // score getting updated from another class         scoreModal.score = score // score getting updated from another class         score  = "2"         scoreModal.score = "2" // score getting updated from another class         score  = "3"         scoreModal.score = "3" // score getting updated from another class        score  = "4"         scoreModal.score = "4"      .......              } } import SwiftUI class ScoreUIViewModel: Observable {     @Published score: String } struct ScoreUI: View {     @State var scoreUIViewModel: ScoreUIViewModel     func displayScoreUI() {         let hostController = UIHostingController(rootView: ScoreUI())         hostController = .overCurrentContext         topViewController()!.present(hostController, animated: true, completion: nil)     }.environmentObject(scoreUIViewModel)      } struct ScoreText: View {     @EnvironmentObject var scoreUIViewModel: ScoreUIViewModel     Text(score).foregroundColor(.green) }
3
0
773
Jul ’21
Swift framework localization
I am trying to localize Swift framework and added a file Localizable.Strings and that file is included in the target but the app that consumes this framework is showing the key not the actual string. NSLocalizedString("string_key", comment: "Actual String") I think issue is related to bundle. Do I need to add bundle parameter to NSLocalizedString? If so what is the bundle parameter value? If bundle is not required then what must be the issue
4
0
3.2k
Jul ’21
Swift files in Bundle
I wanted to move a few .swift files from the framework to different container. I tried creating framework/static-library/SPM to move a few files from the framework but getting compilation errors for the new framework and old framework due to dependancy. I don't want ondemand resource and wanted to keep it local. So I looking for some container to move a few files from framework and load/import them back. I tried moving those files to Settings.bundle but unable to load/import them in the framework? Is there any other way to achieve this?
4
0
1.5k
Sep ’22
Semaphore
class  a {     b().download ({ data in     }) } class  b{     func download (downloadedData: @escaping (_ data: Data? ) -> Void )  {         c().download()     } } class c {     func download () -> Data {         let semaphore = DispatchSemaphore(value: 0)           NetworkManager().downloadRequest: { (result: Result<Data, Error>) in                                             switch result {                                             case .success(let success)                                                 ......                                              case .failure(let error): .....                                             }                                             semaphore.signal()                                    }                         )         semaphore.wait()         return data     } } Class a initiates the download and class c interacts with network manager to download the data. Class c issues semaphore wait as soon as it sends request to download the data and issues signal when download completes. Is there a way to issue signal from class a when download is in progress. Basically class a should be able to skip wait by issuing signal command
6
0
1.9k
Jul ’21