RealmSwift (0.92.3) and provisioning profile error - ios

The following error-message occurs when I try to run my watchkit app with my iPhone device (i.e. simulator runs fine) :
dyld: Library not loaded: #rpath/RealmSwift.framework/Frameworks/Realm.framework/Realm
Referenced from: /private/var/mobile/Containers/Bundle/Application/9CCC-B93-89-4E6/MyApp.app/MyApp
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/9CC8D-43AE7-F8E/MyApp.app/Frameworks/RealmSwift.framework/Frameworks/Realm.framework/Realm:
code signature invalid for '/private/var/mobile/Containers/Bundle/Application/9C98D-435D-A8E6/MyApp.app/Frameworks/RealmSwift.framework/Frameworks/Realm.framework/Realm'
(lldb)
Any idea what there is to do ??? Any help appreciated !

The solution is to create a new "Run Script Phase" in the app's target as described in the realm.io page:
"If using Realm in an iOS project, create a new “Run Script Phase” in your
app’s target’s “Build Phases” and paste the following snippet in the script
text field:
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework/strip-frameworks.sh"
This step is required to work around an App Store submission bug when
archiving universal binaries."
Here is a screenshot on how to find in Xcode-menu and how it eventually looks like !

Kruherson recommends, that you use CocoaPods. Check this post...
Thanks to Kruherson - we know now, that there seems to be a problem later on during app-revision in the app-store with the current solution given from the official realm.io Swift-documentation page !
Here is instruction for CocoaPods installation
Install CocoaPods 0.37.1 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'RealmSwift' to your main and test targets.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!

Related

framework not found RealmSwift

I was installing Realm and imported to my project but when I run the app it shows me an error:
ld: framework not found RealmSwift
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There can be multiple reasons for this issue.
To get the exact issue you can follow the below step :
Right click on error and select 'Reveal in log'. This will give you more insight about the reason of error.
One of the solution is to setting the 'Enabled Bitcode' to No. For this go to Build settings in your target and search 'Bitcode' in the search field.
I have faced this issue multiple times and one of the below solution may work for you.
After installing the pods make sure that you're opening the workspace instead of Xcode project file.
Restart Xcode
Remove derive data for your application
Reintegrate pods using pod deintegrate and pod install for your project
Reset simulator(If you are viewing the output in simulator)
Ensure proper linking of Framework in your project
Restart simulator
Clean project etc.
Hope this may help you.
I was having the same issue.
Initially, I was trying to import the files (Realm.framework and RealmSwift.framework) from download folder but then i was getting the same error like yours.
What i did then, i copied the folder containing the (Realm.framework and RealmSwift.framework) into the project folder and then i imported the files from there. That resolves my issue.
In my case, I've updated the Cocopods to the latest version (1.1.0) via this command sudo gem install cocoapods
is it possible that you are still running the .xcodeproj file. You should run .workspace file in your xcdoe

React-Native: Build error GeneratedInfoPlistDotEnv.h file not found

I had a old React-Native project which I wanted to give it a try again and when trying to run the project on iOS (Android works perfect) I get the error that Debug-iphonesimulator/GeneratedInfoPlistDotEnv.h file not found.
If I run the project from the command react-native run-ios, than the build will succeed.
What can cause this issue and how can it be fixed?
I have tried to fix it with the comments from this issue but no success.
React-Native verision: 0.47
Full error:
<built-in>:1:10: fatal error:
'/Users/myUser/Library/Developer/Xcode/DerivedData/Project-gcaxrvbcwgkfhkadevoqxcprxszw/Build/Products/Debug-iphonesimulator/GeneratedInfoPlistDotEnv.h' file not found
I fixed by copying file GeneratedInfoPlistDotEnv.h (in /ios/build/Build/Products/) to the path mentioned in the error message.
The path mentioned in error message for simulator is not same as real phone, you need to copy for a second time.
The development for React Native just like droped in a deep black hole, what you need to do is just climb and climb and climb...
Changing the Info.plist preprocessor prefix file to works for me ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h
Image of code in Xcode 9
If you're coming from React version 0.60 and above, you should be referencing the package from GitHub instead of NPM. The author hasn't released auto-linking support on NPM yet, even though it's already merged!?
Try these steps after you unlink and uninstall the existing version of react-native-config. Remember to revert to default Info.plist preprocessor settings in XCode build settings.
yarn add https://github.com/luggit/react-native-config.git
cd ios && pod install
You don't have to add any other post-install scripts, just run the app like usual and it should work fine. Make sure you undo any other fixes before doing this.

Xcode Swift: Error using a framework that uses a pod (CocoaPods)

I have made a Swift framework that uses a pod (SCrypto). I could build the framework and the host project with no errors.
But when I run the iPhone simulator (from the project that uses the framework) I get the following error:
dyld: Library not loaded: #rpath/SCrypto.framework/SCrypto
Referenced from: ...
Reason: image not found
I'd be very thankful if someone helped me with this problem.
Details:
Have tried clean and build, didn't work.
Both the project and the framework are in Swift, meant for iOS. I'm using the latest versions of Swift and Xcode.
My pod file includes use_frameworks!. I have not run 'pot init' in the directory of my project - just in the directory of the framework.
In the build phases of the project, the framework is listed under Link Binary with Libraries.
There are some other pages on stack overflow about this error, but the solutions there are outdated or didn't work for me. It doesn't let me comment on those (to say that it didn't work for me). Some of the other ones seem to complicated for a simple thing (using a framework that uses a pod), which make me doubt if they would work. Again, I can't comment there and ask this. So I have to use this page instead.
You need to run pod init in the directory of your project so that when you run pod install it will install it to your project, then close everything after installation and open again your project , only this time use yourprojectname.xcsworkspace. be sure it's not yourprojectname.xcodeproject or it will give you No such module error

Xcode 7.3: error: could not read CFBundleIdentifier from Info.plist (null) after pods configuration

I've downloaded Telegram's code and I'm playing around trying to add Auth0 with it, so I tried to used pods, replicating the practice code.
After some pain regarding PODS_ROOT, I finally managed to get it going, only to encounter the above error.
And now I'm not sure what to do. This answer leads me to believe there's an issue with the info.plist file location, but there's too many:
UPDATE:
I saw that the Bundle Identifiers for the Targets were blank, in contrast to the 'base' Telegram app (perhaps something to do with switching from config configuration to Pods-Telegraph?), which had values in it. So I copied over the Bundle Identifiers from the 'base' app like so:
And promptly ended with this new issue:
ld: library not found for -lPods-watchkitapp Extension
clang: error: linker command failed with exit code 1 (use -v to see invocation)
EDIT:
For reference:
Telegram (iOS version is Objective-C)
Auth0
For replication, I:
Downloaded necessary files for each project. Telegram is missing some files scattered around the net, and Auth0 requires a (free) account for configuration.
Created a podfile for Telegram.
Modified it to resemble Auth0 podfile - Target main app only. If done right, this should replicate the error in question.
Filled in Bundle Filters (erased upon pod install), based off original values. If done right, this should replicate the UPDATE error in question.
Close your project . Open Again. Clean your project and try to run.
And if its not works then Search info.plist right click -> Remove reference . And add it again. and try to Build.
EDIT :- After installing pod You need open project from .xcworkspace in place of .xcodeproject .

How do I use SwiftyJSON in my iOS App?

I recently added SwiftyJSON into my xCode project using Carthage.
Cartfile
$ cat Cartfile
github "SwiftyJSON/SwiftyJSON" >= 2.1.2
I ran this command to install SwiftyJSON
$ carthage update
I added the built Framework to my xCode project
I imported the Framework at the top of my project
But I still get this error:
Use of unresolved identifier 'JSON'
Seriously, what am I doing wrong? I'm new to iOS development.
UPDATE: I tried removing the Frameworks and re-dragging the frameworks to the Linked Frameworks and Libraries and Adding the "Run Script" section to "Build Phases" as the instructions in Carthage asked.
I'm convinced that something went awry during the Carthage Update process because I received this error on my initial attempt:
$ carthage update
*** Fetching SwiftyJSON
*** Fetching Alamofire
*** Checking out SwiftyJSON at "2.1.3"
*** Checking out Alamofire at "1.1.4"
*** xcodebuild output can be found in /var/folders/0x/swzt630n3_575tglljpwhn4h0000gn/T/carthage-xcodebuild.Pc6rLg.log
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
After looking up the problem, I was told that you could run
carthage update --configuration Debug
Which installed it fine, but something is still amiss...
It seems like you missed a step during the addition of SwiftyJSON and Alamofire frameworks from Carthage. Check out these steps from the Carthage readme page :
Steps :
Create a Cartfile that lists the frameworks you’d like to use in your project.
Run carthage update. This will fetch dependencies into a Carthage/Checkouts folder, then build each one.
On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.
On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework
$(SRCROOT)/Carthage/Build/iOS/SwiftyJSON.framework
Looks like you missed step 4. I tried these steps myself in a demo Swift project and they are working great. Try these steps out, and if you still have problems, leave a comment. Thanks!
I switched over to Cocoapods and it just worked. Again, I'm a total noob when it comes to iOS development. When looking for a dependency manger I looked at Cocoapods and Carthage for what they had to offer. I was intrigued by Carthage's claim of keeping things simple:
"Carthage because we wanted the simplest tool possible—a dependency manager that gets the job done without taking over the responsibility of Xcode"
While I always will choose the simpler tool when given a choice, I think I don't know enough of the iOS ecosystem (read: Xcode) to use Carthage.
TL,DR: Can't use it inside of Emulator, Use iPhone.
I also followed your way, and I found out that --configuration debug will code-sign "iOS Developer" identity as SwiftyJSON's project property.
AFAIK, Code-signed "iOS Developer" identity wasn't run with Emulator.
My issue was resolved when I run it at my iPhone 6.
I do not know why you can not add this resource with help of Carthage but if you need use SwiftyJSON you only need:
Enter this URL: SwiftyJSON
Clic the button "Clone or download" and then in "Download ZIP" like the next image shows:
Clic the button "Clone or download" and then in "Download ZIP" IMG
You will get a ZIP file with name "SwiftyJSON-master"
Extract the files
Enter the path:
SwiftyJSON-master/Source/
You will see a file with name:
SwiftyJSON.swift
Copy that file into the files of your project.
Add that file into your project directory.
That file will be like other class into your project that you may use.

Resources