How to use Swift Pod in Unity exported iOS App - ios

I have reach experience in iOS native app development, My company have a unity app. Unity app developer exported the app for iOS and shared with me. I wanted to use my own created cocoa-pod library (which I have already using in my another iOS App) into Unity iOS project.
So Unity developer exported by File -> Build Settings, choose iOS and click Build, and now I am trying integrated pod (which is written in Swift 4.2) into Unity exported of iOS project.
I have taken medium post and many more reference, I have implemented the same as conclusive direction. Please look the attached screenshot below.
Reference - https://medium.com/ios-os-x-development/swift-and-objective-c-interoperability-2add8e6d6887
Please look the below screenshot for autogenerated file
Now when I am going to import this autogenerated header file to make connection between Objective C to Swift, then it is showing error as attached screenshot below
Please help me to resolve this issue. Thanks in advance.

One thing that has hung me up on this in the past is if you get an error during the initial build, then sometimes it doesn't create the -swift.h file and then subsequent builds also get an error that it's missing. Make sure you've deleted your derived data and cleaned the build folder to reset so everything gets built from the beginning.

Related

"Could not locate google-services.json or GoogleService-info.plist files" iOS Project, Unity, Mac Computer

I've been trying for the past two hours to figure this thing out! So I already created a project within my Firebase account; an iOS project. Downloaded the google-service-Info.plist files.
If I click Import New Asset and attempt to search for the file.. can't added it like that, I have to drag it into my folder.
I'm aware that the file must be put within the root folder (which I have done many times now), but I still encounter the same error message.
Could not locate google-services.json or GoogleService-info.plist files"
I removed all the Firebase files (SDK), re-installed them,.. same thing..
I also deleted the GoogleService-info.plist file and downloaded a brand new one, same thing!!! enter image description here
I'm currently using Unity 2018.2.1f1, My computer: macOS High Sierra, Version 10.13.6
I have same problem.
Add IOS and Android build component for Unity. Switch to the platform Android. It resolve you problem.
Check SDK status. See in screenshot below:
This happened to me right after adding a GoogleService-info.plist to a project that only had Android support before.
Doing Assets -> Reimport All also worked for me to get past this error.
In my case I missed the step where you generate those files on Firebase.
Generate them from your Firebase console by clicking the Unity icon in your project overview page. See more complete documentation here

XCode Project Invalid Bundle on App Store Upload

When submitting our app to the app store the validation process for the build keeps getting rejected with the following error.
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Has anyone else had issues with this error? I feel like I've tried just about everything. I'd done the suggested otool -L on the main app as well as the watch app. The only library that it shows linked for is the Mixpanel library. The only other two libraries we are using is Fabric and Crashlytics. From my understanding those are not actual real frameworks? I've also tried to set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES as many posts online suggest. The project builds and runs fine so I'm completely lost as to how to resolve this issue.
This is a React Native iOS app if that has anything to do with it. I'm not the most experience when it comes to iOS stuff but I can find my way around xcode. Anyone have any suggestions? Maybe the best solution is to just create a new xcode project and set everything up again and copy/paste in the code from the previous project?

Objective C generated interface header file Not found in WatchKit

I am currently working to add Apple Watch app in my current App. I added the required profiles and got it to working without any issues.
Now, I want to use some of the class files from iphone app in my apple watch app. I did add the .m file in the target membership to the watchkit extension target.
Since the file which I want to use is in Objective C class, I went ahead and created the bridging header file for apple watch extension target.
Each time when I run the application; I get $(SWIFT_MODULE_NAME)-Swift.h file not found. I did try to follow steps from this link but to no avail. I did clean build folder; removed the derived data but it still gives me the same error.
Am I missing anything in particular which others have tried and can share with me ?
I am using Xcode 8 and Swift 3.
So I figured out the answer and thought of posting it here.
There are couple of ways in which you can fix this but it depends on what you want to do.
1) Using #IF TARGET_OS_IOS will allow you to use the class from iphone to watch.
2) You can also use WatchConnectivity framework to send and/or receive messages, send data also. This is the new framework Apple has recommended to use for connectivity between the devices.
Hope this will help someone else trying to figure out this problem.

How to connect Realm with watchOS and iOS app at the same time?

So, there simple instructions on Realm website:
Installation (Swift 2.1.1):
...
2) Go to your Xcode project’s “General”
settings. Drag RealmSwift.framework and Realm.framework from the
ios/swift-2.1.1/, watchos/, tvos/ or osx/swift-2.1.1/ directory to the
“Embedded Binaries” section. Make sure Copy items if needed is
selected and click Finish.
Basically, stating that we need to use different Realm libraries for developing apps for Watch and for iPhone.
Problem here, is that if I want to create watchOS app I need to import library specific to it. When at the same time I'm trying to import library for iOS, I get error from xCode (version 7.2.1):
Multiple errors occurred while copying the files
Making it impossible to add both libraries at the same time.
My goal is to share data between Watch and iPhone like instructed in this article, but even there author is missing information on how to setup 2 different libraries.
Appreciate any help or advice. Thank you.
The problem you are having adding both the iOS Frameworks and the WatchKit's frameworks is the exact same one I had
I solved this by copying both folders [iOS] [watchkit] into my Xcode project's folder, then adding the respective libraries to their target's Embedded Binaries section.
In this way, you will not be literally copying the same-named items to the same location and it will not throw the error!

WatchOS 2 App fails to launch on device with dyld_fatal_error for my Framework Library not loaded: Image not found

I've just followed the apple transition guide to upgrade my ObjectiveC app to WatchOS 2
https://developer.apple.com/library/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/ConfiguretheXcodeProject.html
With the section "Sharing Code Between an iOS App and a watchOS App" describing how to duplicate an existing iOS framework into a WatchOS framework target for use by WatchOS as follows.
"If you already have a watchOS 1 app that shares a framework with your iOS app, duplicate your iOS framework target and modify it to support watchOS 2.
To duplicate and configure your framework target for watchOS 2
Open the project editor pane of Xcode. (The pane is normally closed.)
Control-click the target to display a context menu with a Duplicate command.
Change the name of the target so that you can identify it easily later.
In Build settings, change the following values:
Change the Supported Platforms setting to watchOS.
Change the Base SDK setting to the latest watchOS.
Change the Product Name setting so that it matches the name of your iOS framework. You want both frameworks to be built with the same name.
Add the framework to your WatchKit extension’s list of linked frameworks."
I've followed these steps to clone my framework which with the iOS framework was called MyFramework, and now the new WatchOS framework is called MyFrameworkWatch. But as described above the Product Name is set to MyFramework instead of MyFrameworkWatch. I presume this naming shift is so that I can include from my framework using
#import <MyFramework/SharedUtils.h>
instead of presumably having to change it to
#import <MyFrameworkWatch/SharedUtils.h>
I wouldn't mind the latter but I'll admit its nicer keeping the framework name the same.
After a bit more work beyond the initial automatic transition I managed to get my app working perfectly well on the simulator, but now switching to device i just can't get it to launch.
Launching my app on the device causes it to spin for a few seconds and then just crash. Launching the glance just causes it to spin indefinitely. Trying to run it from Xcode and running the app causes the app to eventually launch and spin, the spinning can last indefinitely sometimes, but eventually it gets through and i get the actual error reported as follows
dyld_fatal_error - dyld: Library not loaded: #rpath/MyFramework.framework/MyFramework referenced from WatchKit Extension Reason: image not found
So this is my Watch App Extension trying to link to the Watch framework, and doing so looking for the MyFramework name, not the MyFrameworkWatch name. I wonder if this name clashing has caused it to get confused?
When I try to find the frameworks referenced under the Products folder in Xcode I can see two frameworks
MyFramework
MyFramework
they're both reference the same path
/Users/jim/Library/Developer/Xcode/DerivedData/MyApp-byegspjumgwlfpahhwjgzpmfkcdx/Build/Products/Debug-iphoneos/MyFramework.framework
though you can see the target membership is separating the two frameworks, the top MyFramework is associated with the main app, today widget and framework tests project. The lower MyFramework is just associated with my Watch extension. It doesn't feel right that these are referencing the exact same path surely?
Finally when googling for this issue I've found reference of CocoaPods having similar problems though according to their site here
https://github.com/CocoaPods/CocoaPods/issues/4180
It's been fixed since September in version 0.39.0, which is the version that pod --version reports. So I presume I have their fix. I'm tempted to remove the cocoa pods from my framework to see if it helps.
Has anyone else followed the transition guide suggestions for creating a duplicate framework and then managed to get the app and framework actually installing on their watch ok?
Is there any way to analyse the build that is done to try and see if i can see problems with the built files so i don't have to wait for the watch to fail to launch the app to debug it.
Any help is really appreciated as always! Cheers!
Edit: I think I've managed to remove cocoa pods from the offending MyFrameworkWatch target by commenting out the target section in my pod file and running pod update/pod install... it didn't seem to clean up the target very well so i had to manually remove the cocoa pod steps in the post build step. Maybe i've not removed it properly, i find it a little confusing to know what is going on under the hood with cocoa pods. Regardless the same error occurred, so either i didn't remove it properly or it has no effect on this particular problem
Ok, this was caused by the apple documentation for transitioning being wrong, or me interpreting it wrong. It says
Add the framework to your WatchKit extension’s list of linked frameworks.
Where as actually the correct fix was to add the framework to the embedded binaries section (which automatically adds an entry to the linked frameworks anyways) and correctly places the framework within the watch extension under a Frameworks directory. Which the app then loads fine! So much frustration, I lost hours to this across a few days!!

Resources