App crash on iOS 11.0.2, no suitable image found - swift

dyld: Library not loaded: #rpath/AFNetworking.framework/AFNetworking
Referenced from: /var/containers/Bundle/Application/
Reason: No suitable image found.

Explanation of the error:
Your app could not able to find the AFNetworking Dynamic Framework in #rPath. This is the place (rPath), where we should need to place our third party or our custom Dynamic Frameworks for the system to search for Dynamic Frameworks. So that system will search the rPath folder and will load them lazily instead of statically.
Solution:
If you are using Cocoapods, then cocoapods will itself do this step for you. Let me know if you are not using Cocoapods. If you still face the problem, just run Pod install once again..
if you are building your own libraries then you should place them in embedded binaries.

It seems what you are using in AFNetworking is iOS11+, yet you've required it for your project, so when iOS10 searches its directories to find it, it finds nothing. The fact that the error says 'image' is just a fault on Apple's end.
Fix:
Under your project settings go to included frameworks, find AFNetworking and set the status flag from required to optional. Then, wherever you would use AFNetworking in your project, wrap it in the following:
if (#available(iOS 11.0, *)) {
//your AFNetworking code here (for iOS11+)
} else {
//comparable non-AFNetworking code here (for iOS10-)
}
Or just make your project require iOS11 under the deployment target flag.

I had the same issue, in my case the problem was that I had a certificate expired and marked as "always trust". I fixed it using the default setting for the certificates and deleting the expireds

Related

ITMS-90334: Invalid Code Signature Identifier when building via Xcode Cloud

I have started a small collection of helper code in a Swift Package for my own needs. If i include this package in my main project using Swift Package Manger and try to build it using Xcode Cloud, i get the following error:
ITMS-90334: Invalid Code Signature Identifier - The identifier
'AppulizeStandardTools-55554944b34e30d285943c0fa8b9aecb5744a53e'
in your code signature for 'AppulizeStandardTools_BFA0AAD86B154A1_PackageProduct'
must match its Bundle Identifier 'AppulizeStandardTools'
I haven't set any identifiers or code signing manually with regards to the package and the Package.swift is very simple.
What am i doing wrong here?
I lost half a day trying to figure this out, documentation is not plentiful on it atm.
It appears to be related to how XCode Cloud handles the signing for dynamically embedded frameworks... Not ideal if you are using a microcomponent architectural pattern.
Fix for this:
Go into your main target (executable) -> Frameworks, Libraries and Embedded Content section -> Change your frameworks to:
Embed & Sign => Do Not Embed
Go to Build Settings for each Framework and change the Mach-O Type from Dynamic to Static
There are some implications about how this would effect device memory, I found it to be pretty negligible in my case.

Create framework within framework

i got some problem when i trying to include framework within framework. i try to make subframework in swift language. when i run in simulator work perfectly but in device i have error “Reason: no suitable image found. Did find:”
the following is an error message:
dyld: Library not loaded: #rpath/xxx.framework/xxx Referenced from:
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/custom
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/Frameworks/xxx.framework/xxx:
mmap() error 1 at address=0x00169000, size=0x000E8000 segment=__TEXT
in Segment::map() mapping
/private/var/containers/Bundle/Application/81D1C716-915E-4DCA-893D-F934D56C8BAD/customDemo.app/Frameworks/custom.framework/Frameworks/xxx.framework/xxx
You are not allowed to submit an app to the App Store with a framework embedded inside another framework. All frameworks must be inside the main app bundle's Frameworks folder. This does not mean you cannot link one framework against another, though. Just specify framework B inside framework A's Link Binary With Libraries build phase, and don't embed it.

After implementing Google Analytics according to documentation, I am getting an Use Of Unresolved Identifier 'GGLContext' Error

I have implemented the Google Mobile Analytics according to steps outlined on the Google Documentation Page. I have added the pod, I have the bridging header in place, I have downloaded the configuration file and imported the plist file provided. However, when I insert the following code into my appDelegate file, I get the error Use of Unresolved Identifier 'GGLContext'.
// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
// Optional: configure GAI options.
var gai = GAI.sharedInstance()
gai.trackUncaughtExceptions = true // report uncaught exceptions
gai.logger.logLevel = GAILogLevel.Verbose // remove before app release
I have searched many forums and cannot find any solution. I have even run pod try Google and looked at their example project and cannot see a difference. Has any experienced this before (XCode 6.4, OSX 10.10.5, Swift 1)?
Don't use CGLContext try to implement it manually with your Google Analytic ID.
I find this more reliable, as I also try to do it the Google documented way that didn't work for me as well, I believe they have to update their context (I believe this is due to swift 2 - Update).
Example: enter this in your AppDelegate.swift within didFinishLaunchingWithOptions: method.
// Init GAI.
let Tracker = GAI.sharedInstance()
//Add Publisher Track ID
Tracker.trackerWithTrackingId("UA-XXXXXXXXX-X")
Please ask if you have any other question you would like to manually implement (trackUncaughtExceptions, logger etc)
UPDATE:
Your bridge header file should look something as following, you should add whichever feat you're using in Google Analytic Framework.
//Google Analytics
#import "GAI.h"
#import "GAITracker.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
Here is a screenshot of available classes.
just do this
pod 'Google/Analytics'
and
pod install
create -Bridging-Header.h in your project root.
and then copy that to .h file
#import <Google/Analytics.h>
and drag and drop GoogleService-Info.pist to root of project.
this is so important. go to build setting and find swift compiler-code Generation and then set $(SWIFT_MODULE_NAME)-Bridging-Header.h to Objective-C Bridging Header
clean project and build and then run.
At the point in time the 'Google/Analytics' pod doesn't support Bitcode, so when you go to do a production build, you will run into problems. Especially if you want to support WatchOS or tvOS.
At this point in time, using the "GoogleAnalytics" pod seems to be the best option, and setting up the tracker manually with
// Init GAI.
let Tracker = GAI.sharedInstance()
//Add Publisher Track ID
Tracker.trackerWithTrackingId("UA-XXXXXXXXX-X")
You can also go to https://code.google.com/p/analytics-issues/issues/detail?id=671 and scroll to the bottom to vote for Google to fix the recommended path to work with Bitcode.
To import 'Google/Analytics' framework to your swift code, simply import the module using . as package separator:
import Google.Analytics
It will import all required classes without having to modify the bridging header.
You can manually import the GGLCore.framework in ViewController.swift like
import GGLCore
Like this you can manually import the GGL file

Cannot access "Parse.setApplicationId()"

I'm trying to make an app with swift/Obj-c (Bridging Header) with parse.com
So here's my question:
I saw on many sites that you can use Parse.setApplicationId("appid","clientid")
When I try this code it says Use of unresolved Identifier 'Parse'
I imported the framework and set the bridging header in the properties.
I also imported the frameworks which are required like it's written on parse.com
All other Classes/Objects from parse can be used by swift in the code.
This problem was because of a bug in xcode... (I think the compiler failed)
After I restarted Xcode the error was gone.

NSConcreteData vs NSData

I have added an extension to NSData (base64 extension), which I kept over a separate infrastructure class lib project. But when i use this method from my main project i am getting an error like this: "-[NSConcreteData encodeBase64]: unrecognized selector sent to instance 0x121e60'".
But if i keep the same class in my main project itself, this will execute with out any issue.
I call this method in the following way:
[dev setToken:[token encodeBase64]];
Please suggest why this is not working if i put the extension in another project. (I am already using some other extensions, eg. for NSDate, like this with out any issue.)
Is this on iPhone OS 3.0? The 3.0 SDK broke the use of -ObjC, but you usually are able to link in categories for a static library by adding the -all_load option to Other Linker Flags within your target application.
The issue is that the metadata necessary to configure a category is usually stripped by the linker because it appears to be dead. If you add the "-ObjC" LDFLAG to your project it will tell the linker to link all the potential ObjC info even if it appears to be dead.