The Swift integration of a new Realm-DB (realm 0.92.3) under Xcode 6.3 and iOS10.10.3 basically works for the iPhone (not for the Apple-Watch yet). The integration of the same realm-framework under Watchkit (i.e. Apple-Watch) does not work yet.
The RealmSwift.framework is integrated (dragged into) the Embedded-Binaries as described here1 and here2.
See screenshot below :
When running the Watchkit-App with the simulator the following error occurs :
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /Users/XXX/Library/Developer/CoreSimulator/Devices/3FE99-9-4C4C2/data/Containers/Bundle/Application/8B4-DF19F34-222973/MyApp.app/PlugIns/MyApp WatchKit Extension.appex/MyApp WatchKit Extension
Reason: image not found
(lldb)
What is still wrong ???
The Framework-Search-Path of the main-app is set. The ones for MyApp Watchkit Extension and MyApp Watchkit App are not set. Setting them does not change the above error. What is still missing ???
I would recommend that you use CocoaPods.
I did it like you did, with dynamic frameworks, but when I try to submit my application to iTunes Connect using Xcode's Organizer, I could not because of the nested frameworks. Realm.framework is inside RealmSwift.framework, and that is not okay with Apple. So I try and try but nothing helped…
Then I used CocoaPods and everything worked as it should.
Here are instructions 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!
This Podfile finally did it for me (see below). Everything worked after that...
To install just open a terminal, go to your App's folder (where you place the Podfile) and type
pod install
After that make sure to open from now on the "MyApp.xcworkspace" (no longer "MyApp.xcodeproj") and you are all set !
Here is the podfile that worked :
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'MyApp', 'MyApp WatchKit Extension'
def shared_pods
pod 'RealmSwift', '>= 0.93.2'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
Related
I'm developing a cocoa touch framework and I'm importing "RealmSwift" using CocoaPods. The project builds successfully but the tests fails to load.
I'm getting the following error:
xctest (97035) encountered an error (Early unexpected exit, operation
never finished bootstrapping - no restart will be attempted.
(Underlying error: The test runner failed to load the test bundle.
Executable cannot be loaded for some other reason, such as a problem
with a library it depends on or a code signature/entitlements
mismatch.))
Crash log:
2019-02-27 17:35:44.197599+0400 xctest[12408:121075] The bundle “MyFrameworkTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-02-27 17:35:44.197835+0400 xctest[12408:121075] (dlopen_preflight(/Users/zakaria/Library/Developer/Xcode/DerivedData/MyFramework-cltpexonmtkefveximwygxbkkcrj/Build/Products/Debug-iphonesimulator/MyFrameworkTests.xctest/MyFrameworkTests): Library not loaded: #rpath/Realm.framework/Realm
Referenced from: /Users/zakaria/Library/Developer/Xcode/DerivedData/MyFramework-cltpexonmtkefveximwygxbkkcrj/Build/Products/Debug-iphonesimulator/MyFrameworkTests.xctest/MyFrameworkTests
Reason: image not found)
I tried every solution I could find online, but to no avail.
It's worth mentioning that this works successfully in a iOS project, the problem occurs only in a cocoa touch framework.
My podfile is as follow:
target 'Framework' do
use_frameworks!
pod 'RealmSwift', '~> 3.13.1'
target 'FrameworkTests' do
inherit! :search_paths
end
end
I'm using Xcode version: 10.1
and CocoaPods version: 1.6.0
Go to your test logs in Derived data folder:
~/Library/Developer/Xcode/DerivedData/APP_BUILD_FOLDER/Logs/Test
You will find a .xcresult test result bundle, right-click it and choose Show package contents and in 1_Test/Diagnostics folder, you should find run/crash log for your tests.
This log will give you an exact cause of your fail, you can post it here if you don't know what to do with it after you find it, we will help you :-)
Without this log, cause of your issue could be literally anything, since this is rather generic xcbuild fail message.
This is the podfile that worked for me:
platform :ios, '11.0'
def shared
use_frameworks!
pod 'RealmSwift', '~> 3.18.0'
end
target 'Framework' do
shared
end
target 'FrameworkTests' do
shared
end
Oky, thx for logs this should fix your issue:
target 'Framework' do
use_frameworks!
pod 'RealmSwift', '~> 3.13.1'
target 'FrameworkTests' do
inherit! :search_paths
pod 'RealmSwift', '~> 3.13.1'
end
end
You don't have the RealmSwift library installed for your test target in pods, only for your app, as you can tell from log:
...Library not loaded: #rpath/Realm.framework/Realm referenced from...MyFrameworkTests.xctest...
Add code above to your podfile and run pod update :-)
Similar modification helped me.
use_frameworks!
target 'Framework' do
pod 'RealmSwift', '~> 3.13.1'
end
target 'FrameworkTests' do
pod 'RealmSwift', '~> 3.13.1'
end
Feel free to use "def" link
I encountered this issue recently when attempting to run our UI Tests target after our min deployment target was updated from 11.0 to 13.2, which failed immediately on launch. Oddly enough, updating the target all the way up to 12.4 worked just fine, but anything >= 13.0 resulted in the error
The bundle "MyAppUITests" couldn't be loaded. Try reinstalling the bundle.
The single change that resolved it (beyond ensuring that deployment target was set consistently across all targets, and in the Podfile) was to clear out the value we had listed in the BUNDLE_LOADER Build Setting within our UI Test Target.
Before:
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp";
After:
BUNDLE_LOADER = "";
I have a ObjC app project with a UI Automation Swift target in it. By default the Run and Test build work successfully.
But I have to add a Cocoa Pod with a Swift framework for the UI Automation target... Podfile:
workspace 'BlahApp.xcworkspace'
platform :ios, '8.0'
project 'BlahApp/BlahApp.xcodeproj'
target 'BlahApp' do
pod 'Blahpod', '~> 2.1.6'
pod 'Mehpod', '~> 3.10.0'
end
target 'BlahAppUITests' do
use_frameworks!
platform :ios, '9.0'
pod 'autom', :git => 'https://blah.to.my.repo', :branch => 'master'
end
So I add this, do a pod install, Xcode clean, Xcode Run --> works, Xcode Test fails with:
ld: library not found for -lAFNetworking
AFNetworking is used in Blahpod.
Time wasted trying to get Xcode/Cocoapods to do what I want: 2 days
Somebody please help me here. tried other people's solution to the error message to no avail.
in build setting , search for Run Path
then add "#executable_path/Frameworks" and Remove All other Content Related to AFNetworking
Using Xcode-6.3.1, iOS-8.3 and MacOS-10.10.3, I am trying to use RealmSwift (0.92.3) and CocoaPods 0.37.1
I use the following procedure :
install cocoapods (in terminal):
$ sudo gem install cocoapods
Create new Xcode project (named MyApp)
Create Podfile
platform :ios, '8.3'
use_frameworks!
target 'MyApp' do
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyAppTests' do
pod 'RealmSwift', '>= 0.92.3'
end
Place the Podfile in the MyApp folder (next to MyApp.xcodeproj)
Download the newest Realm (0.92.3 from here) (i.e. Swift version)
unzip it
go to /ios folder
copy RealmSwift.framework also to your MyApp-project folder
(after Point 4 and 5 you end up like in the picture here)
Inside a terminal, go to your MyApp-folder and type
pod install
After pod-install, I end up with the following text inside the terminal:
After that, I simply open the new MyApp.xcworkspace
It basically looks ok - except: NO FRAMEWORK SEEMS TO BE FOUND !! (see screenshot below)...
What am I still missing ????
Any help greatly appreciated!
I finally found out that the "red" colored missing frameworks are no harm. Using CocoaPods these frameworks are not physically there - therefore Xcode cannot change the color. It, for sure, does not indicate a mistake here...
THREFORE THE ABOVE WORKFLOW (pt 1-8) IS CORRECT !
However, the Podfile above is not the right one if you want to use your "MyApp WatchKit Extension". The correct one is:
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'MyApp', 'MyApp WatchKit Extension'
def shared_pods
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
Also, it is important that you still "import RealmSwift" in your Realm-Object definition(s) as can be seen in an example below:
Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):
Using iOS-8.3, Xcode-6.3.1 and MacOS-10.10.3 - The CocoaPods (v0.37.1) installation of the RealmSwift (v0.92.3) described here and here basically works, except the WatchKit Extension does not find any Realm keywords.
My Podfile looks as follows:
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
def shared_pods
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
link_with 'MyApp', 'MyApp WatchKit Extension'
All my Realm-keywords in the WatchKit Extension do not work as can be seen in the following error messages (...having commented out any import RealmSwift statements) (see pictures below)
Any idea strongly appreciated of what could still be wrong ???
Any idea on how the target-settings must be. Hint: The NameEntry Realm-Object is used in both targets (i.e. MyApp and also MyApp WatchKit Extension). This seems to add complexity to the CocoaPods usage. Any idea if the double-usage (i.e. in both targets) need a special cocoapods setting ?? What about "import RealmSwift" - is this necessary or not ??
The Podfile above is actually the right one !!
However, it is important that you still "import RealmSwift" in your Realm-Object definition(s) using CocoaPods as can be seen in the corrected example below. This will make your error messages of the WatchKit Extension not recognizing any realm-object go away !
Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):
I try to build a WatchKit Extension for my app...
I Updated the pods file to look like this:
platform:ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'
link_with 'my-team-ios', 'My Team WatchKit Extension'
def shared_pods
pod 'DOSingleton'
pod 'JSONModel'
pod 'MagicalRecord'
end
target :'My App' do
shared_pods
pod 'Facebook-iOS-SDK', '~> 3.23.1'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
... some more pods here...
end
target :'My Team WatchKit Extension' do
shared_pods
end
How I install the pods and don't get an error...
But, when I build the App, I get this error:
ld: framework not found Pods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What is my problem here?
I'm using Pod 1.2.1 and facing the same problem i.e. No such module XYZ and for anyone who came across the same issue here what I did to overcome it:
use_frameworks!
def shared_pods
pod 'XYZ'
end
target 'MyApp' do
platform :ios, '8.0'
shared_pods
pod 'Blah'
pod 'blah'
end
target 'Watch Extension' do
platform :watchos, '3.2'
shared_pods
end
I just added platform under each target e.g platform :watchos, '3.2' which was missing before and it solved my problem.
You need to open the xcworkspace file instead of the project file when using CocoaPods.
The problem is when updating to cocoapods 0.36.x they are now creating Frameworks out of each pod library. See the blog post about it.
This causes issues with any pod library that is dependent on other pods and how its referencing them in their import statements, or how your code is importing them as well. The Pod process now turns them into frameworks and when they used to be imported as
#import "ThisOtherPodClass.h"
Now need to be imported as
#import <ThisPodsFrameworkName/ThisOtherPodClass.h>
There is a new version of cocoa pods .38, that is designed to support WatchKit. However, if you want to work with the current version, check o make sure that libPods.a is added to the Target, WatchKit Extension in Included Libraries and Frameworks. Second, make sure that Pods.debug and Pods.release are added to Watchkit Extension in the General tabl
https://github.com/CocoaPods/CocoaPods/issues/3382
neonichu commented on Apr 15, 2015
would start by making sure OTHER_LDFLAGS isn't overwritten with unnecessary things, both in the project and the targets.
That set OTHER_LDFLAGS in buids settings solved my issus.
Try to change this lines
target :'My App', target :'My Team WatchKit Extension'
and remove colons:
target 'My App', target 'My Team WatchKit Extension'
I found a "temporally solution" for me:
Switch back to CocoaPods 0.35
Now everything is working fine, with our any changes to my project / pod file (except removing the 'use_frameworks!')
I think, that should not be the final solution here...
A short test by upgrading again to 0.36 raises the same problem as before...
Here is a link to the GitHub Issue:
Rename the target so it doesnt include any spaces -> MyTeamWatchKitExtension both in podfile and also in General -> Targets. This solved my problem