Initialising Firebase Crashlytics in an iOS common project shared by other projects - ios

I have an iOS project with common functionality (including FB Crashlytics logging) included in several other iOS projects each with their own GoogleService-Info.plist file.
Everything seemed to work fine until it came to adding the "Firebase/FirebaseCrashlytics/run" Run Script phase to the common project at which point I find I need to pass in the correct GoogleService-Info.plist file (via /FirebaseCrashlytics/upload-symbols).
Is there a way to do this, perhaps some way to detect the project containing the common project and set the correct path to the appropriate GS-I.plist file, or will I have to move all FB functionality into the separate projects?

In the end, I put the Run Script into my separate projects but referenced the FB path in the common project, e.g.
"../CommonProject/Firebase/FirebaseCrashlytics/run"
I assume this will work (there's no errors on compilation, obviously) but have yet to confirm FB logging, etc... occurs.

Related

UnityFramework-Swift.h file not found

I have an error 'Lexical or Preprocessor Issue Group' with building xcode project after have built from Unity.
'UnityFramework/UnityFramework-Swift.h file not found'
I have Nice Vibration asset and FB SDK in my project. So I tried to follow this instructions in 'Building for iOS' section, but have no result https://nice-vibrations-docs.moremountains.com/platform-specifics.html#building-for-ios
I makes it with .xcworkspace, not .xcodeproj file. I have read it's right way because of FB SDK needs CocoaPods build pipeline and I should use .xcworkspace. And it's happens in XCode 12, if it matters.
What could be wrong? I spent a few hours and so still there, where I have been :(
I also ran into this issue today (although because of the Firebase SDK, not FB).
The problems seems to be with the post-build processor, which modifies the output XCode project. The NiceVibrations implementation currently only copies a single file (module.modulemap) to the build directory. Instead, we need the entire NiceVibrations/Common/Plugins/iOS/Swift directory to be copied over.
While I can't publish the entire file, I will share my modifications with you for automating this process.
Open the following file:
NiceVibrations/Common/Scripts/Editor/MMNVBuildPostProcessor.cs
Locate the WritePropertiesToFramework function and replace:
System.IO.File.Copy(privateModuleFilepath, destination);
With this:
DirectoryCopy(Path.GetDirectoryName(privateModuleFilepath), Path.GetDirectoryName(destination), true);
You can find the source code for the DirectoryCopy function from the Microsoft dotnet docs here
Edit: You will have to change the second argument of file.CopyTo to true to allow for subsequent rebuilding atop the same directory to avoid runtime errors
Additionally, I have increased the callbackOrder to 60 to ensure that this hook runs last.
I am personally using .xcodeproj instead of workspaces, but it should work fine with workspaces as well. (Firebase uses something called External dependency manager which allows you to configure your project generation preference)
After making these changes, trigger a build from unity and "replace" the target folder to update your XCode files!

Xcode build process for linking & embedding framework to app in workspace

I've separated some functionality in an app I'm working on into a self-contained framework. Both the framework and the app are included in a workspace. How do I include this framework in my build in a machine-agnostic manner?
What I've been doing is adding the framework to the embedded binaries of my client app, as suggested on a number of posts here on SO. This works nicely until you start work on another machine, at which point the randomly generated 'DerivedData' directory the framework resides in can't be found, and you have to re-create the link. This will become a really tiresome process.
I was considering using CocoaPods for this purpose, but unless I'm reading it wrong, you can't just reference local projects with a podspec; the project needs to reside on a known source / repo.
So basically I'd like to know how people here have forged a multi-project build process that isn't linked to the directory structure of a particular development machine.
So I've found a solution that works. The issue was that my client app project referred to the framework file relative to the project itself.
The minimal steps I took to refer to (and embed) my framework were significantly fewer than some of the solutions I've seen.
In my client app's target (on the General tab), add the framework to the 'Embedded Libraries' section. This will also add a reference to the framework to the Project navigator.
Select the reference added to the Project navigator in step 1, and change it's location to be 'Relative to Built Products'. Optionally move the framework to the 'Frameworks' folder of the client app's project, where the rest of the frameworks live.
This second step ensures the build looks for the framework relative to the build products, rather than relative to something else, whose location may vary between machines / copies of the source.
Actually, you can indeed have private Pods. Most tutorials on how to do this usually keep these private Pods within private repos on GitHub, but you can also host them on another Git (non-GitHub) server.
As for the DerivedData directory issue, it sounds like you are including the framework via a build setting (i.e. something like "-framework ~/Library/Developer/Xcode/DerivedData/MyFramework-$$##$###$#/MyFramework.framework").
You should be able to simply click on the "Build Phases" section of your app's target settings and then the "add" (or "+") button and you'll see your (built via the same workspace) framework or library in that list that you can add. More information can be seen in this Apple documentation.

Linking a framework for iOS

I'm creating my own iOS framework for use in one of my apps. Now I want to send the app to a friend so that he can run it. I want this to be as simple as possible for him, and I don't want him to have to change of the build settings or link the framework. Given that I don't know what directory he will place the framework in, I think I have 2 options:
1.
When I drag the framework into my app, I don't "copy" the framework, and instead just keep a reference to it. Furthermore, I place my framework in a directory called Project. Then the directory would look like this
/Project
App
Framework
This way, I can send the Project file, and when he runs the app the reference to the framework will be the same.
2. Copy the framework into the project, and just send the app.
Do both of these methods work the same?
Both methods should work. Reference to a file is kept in the project, and file is in the project directory. But, for example, if framework file was placed outside the project directory, it wouldn't work.

Trigger.io Custom Module & ForgeInspector

Our project has a requirement to use user tracking from SOMO (somoglobal.com), and given this module doesn't exist in Trigger, we're trying to build our own bespoke module so we can load the tracking API and send Events from the trigger app using a custom forge.somo object.
I've followed the documentation on creating custom modules, and so far it's fairly straightforward. However, the SOMO plugin requires a couple of files to be part of the module and this is where I'm stumbling, getting errors in the ForgeInspector app when testing.
In the below screenshot, I've highlighted the 3rd party files added to the ForgeModule project; a xcdatamodeld file to the Compile Sources, a .pem to ForgeModule's bundle resources., and the .a added to the libraries. However, when I run ForgeInspector to test my module is working, I get errors that I have pinpointed to the xcdatamodeld & .pem files (with the PEM, ForgeInspector complains that it cannot find the file) If I manually edit the ForgeInspector project, adding these files to that skeleton, everything seems to work fine.
My understanding is I cannot/shouldn't edit ForgeInspector, given it represents the untouchable main Trigger project - is there a way around this? Feels like a scoping issue, but I would have thought anything in the sub-project would be visible to the parent, so I'm hoping I'm just displaying my relative inexperience with iOS / xcode development :-)

Reference code in a separate project in XCode 4.2

I'm working on an iOS app where I use third party libraries. I want to migrate my project to use ARC, but the third party libraries are still using the old memory management. So I want to separate third party code and put it in a separate project without ARC, and then somehow link that project into my iOS-app project, so that they will be built together using the same configuration.
Is this possible to do in a very simple way, or am i better of just turning off ARC for the individual files? (seems very tedious..)
Can I use a workspace? Where one project is my iOS app and the other just contains third party code?
I've played around a bit and googled a lot, but there just doesn't seem to be any simple soultion, or am I wrong?
So I figured it out myself, with a lot of help from different blogs. Something this basic should be more trivial and well documented... But here we go, this is what I did to get a library for AsiHttpRequest:
Create a new iOS project. Select the 'Cocoa Touch Static Library' template. Call it whatever you like. You don't want to tick 'Use automatic reference counting', since AsiHttpRequest does not support it.
Select a location for your library project (will matter later on).
Delete the default .h- and .m-file created by Xcode.
Drag and drop the AsiHttpRequest files into the project
You can add the frameworks that AsiHttpRequest is dependent of, but you will have to add them to your main project anyway, so it is not necessary.
Try to build the project, it should do so without errors.
Open your main project
From finder, drag your library .proj-file into your main project (in Xcode, so that it 'lands' onto the main project file)
The library project should now appear under your main project (still in XCode). It should be expandable and you should be able to see the library project files as well. If it doesn't, try closing all open projects and reopen the main project.
Select the main project, and select target. Under Build Phases - Link Binary With Libraries, click the +-sign.
In the list of frameworks you should see your library project (called something like libname.a). Select that file
The newly added file might appear red in the list of frameworks, don't worry, it works anyway. Guess it's a bug.
Still under target, go to Build Settings
Under Header Search Paths add the relative search path to where the library .h-files are. This is relative to your main projects .proj-file. (For example ../some folder/libproject/)
Hopefully your main project will build without errors and the library project will be built at the same time, using the same configuration as the main project.
I have no idea if this is a good approach or if there is some easier way to do it. However, I like this, since I can use the library project in several projects. And if I want to update the library project, I only have to do it in one place, and the other projects will be updated as well, since they all reference the same project.
Edit1:
I had some problems with library projects using objective c categories. I received unrecognized selector sent to instance errors in runtime when trying to call those methods. This problem was solved by following the answer given here.
Go to build settings of the target in the main project and add -ObjC to the entry called Other Linker Flags
Edit2:
I found this template for creating Universal frameworks. I haven't tried it, but I guess something like this would work as well.

Resources