Regenerate XCFramework if there is a code change - xcode

I have a Demo project and Framework which can be integrated with multiple ways(Cocoapods, SPM - using generated XCFramework, directly integrate with XCFramework)
For distributing Demo app to external users we integrate the Framework with SPM.
Problem with this approch is during development its makes really hard to regenerate XCFramework after each change, so I have decided to drag and drop the Framework's project to Demo app, but cant understand how to recompile XCFramework if there is a change.
Could you please help me with understading how to handle this scenario.

Create an .xcworkspace that contains the framework project and the demo app project side by side, then inside the demo app target General settings (see screenshot), add the .framework file from the framework project within the workspace instead of depending on the .xcframework binary file directly.
After that, add a "Copy File" build phase that embeds the framework file.

Related

Xcode: how to work with library/framework conveniently while keeping code private towards others?

I have been following this tutorial: https://medium.com/better-programming/create-swift-5-static-library-f1c7a1be3e45
However, it is inconvenient to copy the new .a file every time I make a change to the library. What is the common setup during development of the static library? Do a "copy to iOS project folder" in the build script or linking the frameworks "Products" folder in the iOS project etc.?
During development, Subprojects seem to be a really useful way (https://www.raywenderlich.com/2658-creating-a-static-library-in-ios-tutorial). However, copying the project to another computer renders it useless as it seems to rely on the Subproject and not e.g. cache the data from the last build.
The background is that I want to work with a client that I don't want to give access to my private API.
I am looking for a solution that lets me
work on the project as well as the library conveniently (either by submodules or by having opened 2 Xcode windows at the time)
commit changes to the Git repo (via the Xcode Source Control) and automatically have the compiled framework being pushed, too
have my be able client to use my Project and work on the Project but only has access to the compiled library so he can't see what's inside it

How to use ServiceCore framework from salesforce in a Xamarin forms app?

I am getting a warning in my console when I try building the app in Release configuration. The warning reads The ServiceSDK frameworks have not been prepared for release.
Please ensure the "prepare-framework" script is run after the "Embed Frameworks" build phase.
From the documentations, I understand that a build phase script has to be run to fix the issue.
Here is how I use the framework in my solution:
I am creating a binding library which refers the framework through a Native Reference. Then I run the library project and build a .dll with I use in the iOS project within my Xamarin forms application. All this is working fine. I am able to use the intended features from the framework.
However, there is this warning which appears in the console when I run the App in Release configuration. Also, when I tried submitting the App to App Store, it throws error, which is apparently the same mentioned above.
I tried by adding Custom commands which I think is the equivalent of Xcode build phase scripts, but the warning doesn't simply go away.
Any help would be really appreciated.
Sample Repos - https://github.com/XamarinUniversity/ENT302
Youtube Video Link - https://www.youtube.com/watch?v=HEypPXVoYnY&feature=youtu.be
Gudie Here - https://xamarinuniversity.github.io/ENT302/

Can I link an XCUITest target to a different Project's app target OR use XCTest/XCUITest outside of a UI Test Bundle target?

I am currently building out a test suite in an Xcode workspace that contains 3 existing projects. 2 App projects and a common framework project. Both apps are very similar in regards to UI with some minor differences.
I am trying to find a way to share the XCUITest framework I made for App A with App B.
Currently, App A has a test target set inside of its AppA.xcodeproj. All of App A's tests are doing great and easy to maintain. I need to extend this to App B and refactor App A's framework to only the App A exclusive bits so App A and App B can share the common XCUITest framework code base from a central base.
I have tried to create a new project, move over the UI test code and point the new UI Test target at App A's executable, but I could not figure out how to get the option to show.
I set the App A app as a Target Dependency in the New Project's test target > Build Phases tab, but no luck. I was able to set App A's target in the new test target's scheme but still landed on an error.
Assertion Failure: CommonBasePage.swift:21: failed: caught "NSInternalInconsistencyException",
"No target application path specified via test configuration: <XCTestConfiguration: 0x60400014e910>
testBundleURL:file:///Users/user.name/Library/Developer/Xcode/DerivedData/.../Debug-iphonesimulator/NewTestTarget-Runner.app/PlugIns/NewTestTarget.xctest/
testBundleRelativePath:(null)
productModuleName:NewTestTarget
testsToSkip:(null)
testsToRun:NewBasePage/testExample
reportResultsToIDE:YES
sessionIdentifier:<>
pathToXcodeReportingSocket:(null)
disablePerformanceMetrics:no
treatMissingBaselinesAsFailures:no
baselineFileURL:(null)
baselineFileRelativePath:(null)
targetApplicationPath:(null)
targetApplicationBundleID:(null)
testApplicationDependencies:
{...
I'm assuming targetApplicationPath:(null), targetApplicationBundleID:(null) should have legit target values but I'm unsure where else to look in order to set them.
I gave up on that and tried to create a new project & target as a Cocoa Touch Framework to shift the common code to a central point but was not able to import XCTest, which my framework depends on for XCUIApplication and XCUIElement fields.
import XCTest //Causes "Cannot load underlying module for 'XCTest'"I tried adding XCTest.framework to the targets "Link Binary with Libraries" section under build phases but no luck.
Is there a way to work with the XCTest framework outside of a test target?
OR
Is there a way to point one project's test target at another project's app target?
You can link XCTest and any other framework to anything. Make sure you have $(PLATFORM_DIR)/Developer/Library/Frameworks in both LD_RUNPATH_SEARCH_PATHS and FRAMEWORK_SEARCH_PATHS.
Making framework for shared code is a good idea.

Build static library Target with main Target for proper architecture in XCode?

I am currently developing an iPhone app in XCode that requires a static library that is built from another XCode project I have made. I currently have both targets in the same project, and I need the static library project to build and run for the proper architecture when I build the project that uses it.
As of now I have to open the static library project on its own, build it from there, find where it was built, and then remove the old library and add the new one to my project that uses it.
How do I do this?
The solution lies within the idea of workspaces. This s.o. thread might also be helpful. I think the general layout youll want to create is a new workspace where you will add both projects, the client and the library, that way they are both within reach.
Best of luck!

Internal Linking of Cocoa Frameworks

In my open-source Cocoa project, I have two Xcode projects -- one framework and one application. I want to link the framework in the application, and whenever I build the framework, I want the linked framework in the application to be updated automatically as well.
What is the correct way to set this up, especially so that someone else who clones my project can easily build both the framework and the application?
Drag the Framework project into the App project's source list (on the left). I make a "Projects" folder in the source list for that exact purpose.
Then, you can simply select your App Target, Get Info, and add the Framework as a Direct Dependency.
Now, whenever you build your App, your Framework will be built as well.
It's recommended to use a common Build Folder as well (Xcode->Preferences->Building) to help with linking.

Resources