Xcode install target library dependency on executable Run - ios

I have a target executable A.
A links against a target dynamic library B in the same project.
I would like that each time in Xcode, i run A (⌘R), i will get B installed into it's INSTALL_PATH on device/simulator.
I Tried to add to A post build events, a RunScript to copy B manually, and also tried to use "Copy Build Phase" on A target but it all failed. Nothing which i have tried seems to get B installed on it's target install directory.

Related

Getting error in Xcode no such file or directory found with libReactNativeLocalization.a during build and archive

I am having issue in Xcode while I try to build or archive my react-native project. Xcode throwing error like no such file or directory: '/Users/...../DerivedData/myproject/Build/Products/Debug-iphonesimulator/libReactNativeLocalization.a'.
when I run react-native run-ios or in release mode react-native run-ios --configuration Release then it is working perfectly fine but when I try to build or archive it from Xcode then it is throwing error.
I am using Xcode version 10
My react-native version is 0.57.4
iOS development target is 9.0
react-native-localization version is 2.0.3
Tried things which didn't worked for me
Removed node_modules and pods completely and run npm install and pod install didn't worked for me .
In menue File --> workspace setting changed build system from Use Shared System to Legacy build system. in this particular case app is build and archived successfully but when I lunch my app then it crashes after splash screen.
Removed Derived Data completely and rebuild again still getting this error.
If I remove react-native-localization completely from my project then all the things are working fine and I am able to build and archive the project.
When we run react-native link react-native-localization command then it also applies the changes on ios app too which creates an issue in our case. So due to this command, it creates an entry in project_name → ios → podfile (podfile)
Here ReactNativeLocalization is pointing to project_name/node_modules/react-native-localization directory due to this line when we run pod install command then there is one dependence React in this package is going to reinstall in your pods as you can see in this image.(as you can see here)
Follow the following steps to overcome form this issue
After react-native link react-native-localization command navigate to project_name → ios → podfile and remove or comment pod ‘ReactNativeLocalization’, :path => ‘../node_modules/react-native-localization’
Now its time to link react-native-localization library manually from Xcode. So to link this library manually open project_name → ios → project_name.xcworksace file in Xcode and select your target.
After that in project navigator right click on library and select Add Files to “...” and after that navigate to project_name → node_modules → react-native-localization and select ReactNativeLocalization.xcodeproj file.
Now navigate to project Target → Build Phase and expand Link Binary With Library after that click on plus icon and add libReactNativeLocalization.a library
I had been stuck on this issue since morning. A simple hack made my build.
I observed that in folder Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/ lib files were being generated in their folder. i.e libLinearGradient.a was in libLinearGradient.
One .a file which was being successfully lined was there without it's folder so I did the same for all .a files. ( Simply put them outside without their folder.)
So now path became Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/libLinearGradient.a instead of Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/libLinearGradient/libLinearGradient.a

Build error in Xcode by react-native code

This is my error:
Build system information
error: Multiple commands produce '/Users/tanhaeirad/Project/Rahanj/RezasPortal/portalapp/ios/build/Build/Products/Debug-iphonesimulator/portalapp.app/AntDesign.ttf':
1) Target 'portalapp' (project 'portalapp') has copy command from '/Users/tanhaeirad/Project/Rahanj/RezasPortal/portalapp/node_modules/native-base/Fonts/AntDesign.ttf' to '/Users/tanhaeirad/Project/Rahanj/RezasPortal/portalapp/ios/build/Build/Products/Debug-iphonesimulator/portalapp.app/AntDesign.ttf'
2) Target 'portalapp' (project 'portalapp') has copy command from '/Users/tanhaeirad/Project/Rahanj/RezasPortal/portalapp/node_modules/react-native-vector-icons/Fonts/AntDesign.ttf' to '/Users/tanhaeirad/Project/Rahanj/RezasPortal/portalapp/ios/build/Build/Products/Debug-iphonesimulator/portalapp.app/AntDesign.ttf'
but my code run in simulator
i code with react native and this error shown when i install react-native base
In Xcode, go to < one of the library target names > => Build Phases => Copy Bundle Resources and remove the font that's causing the issue. This should ensure that it only gets copied into the app package once. It probably doesn't matter which of those two libraries you remove it from.

Xcode Buildtime Error: 'Unable to load contents of file list: '.../Info.plist' (in target 'xxxx')

Xcode started throwing this error in a project today, and I'm having trouble figuring out what it means and how to troubleshoot it, and it's not coming up in any searches. It happens immediately after trying to build to a device (no scripts compile, etc):
error: Unable to load contents of file list: '/Users/.../Products/Debug-appletvos/myapp.app/Info.plist' (in target 'myapp')
Full log below, (note I've replaced build folder with ... for brevity)
Showing Recent Messages
Prepare build
note: Using new build systemnote: Planning buildnote: Constructing build description
Build system information
error: Unable to load contents of file list: '/Users/.../Products/Debug-appletvos/myapp.app/Info.plist' (in target 'myapp')
Build failed 3/5/19, 3:09 PM 0.2 seconds
Things I've tried so far:
Restarting Xcode
Restarting Computer
'Product' > 'Clean Build Folder'
Manually deleting everything in Build folder
Re-download repository on the same computer (same issue)
Re-download repository on a different computer (same issue)
reverting to a previous commit that was working (same issue)
plutil Info.plist responds with Info.plist: OK
Other items of note:
Project uses Cocoapods
Project utilizes custom C++ code
The only file list in the Info.plist file is a list of 2 custom fonts, but those are showing up ok in the Xcode project browser (not red).
If anyone has encountered this before and has a fix, or has any other suggestions for troubleshooting I would greatly appreciate it, thanks!
In my case, I just fixed below
Open terminal under project folder
pod deintegrate
sudo gem install cocoapods-clean
pod clean
Open the project and delete (if it's still there) the “Pods” folder that should be red
pod setup (This may take some time)
pod install
I fix this in this way:
1、Go to your project's target, -> Build Phases -> Embed Pods Frameworks
2、check the input files and input file lists, Output files, and output file lists.
3、move dir from input file lists to input files, and output file lists to output files
I realised after a while that my colleague has updated cocoapods to the latest version, so what I did was just
sudo gem install cocoapods
And that did the trick! :)
Finally figured this out, posting here so others googling can find it.
It was an issue with a build script that used the 'Input File Lists' option, removing and re-adding the script fixed the issue.
Nav to Target
'Build Phases' tab
'Run Script' phase
make notes of what's there, remove it
re-run to make sure things work
re-add the script (and content under 'Input File Lists')
The problem is that you have added path to Input File Lists instead of Input Files
In my case
pod deintegrate
pod install
was enough
In my case, I just fixed below
1- Go to your project's target, -> Build Phases -> Delete [CP] Copy Pods Resources.
2- pod deintegrate.
3- pod install.
First, you work:
Delete the .xcworkspace file
Delete the Podfile.lock file and Pods/ directory
Keep the Podfile
Rerun pod install
If the error still occurs, you need to add include .xcconfig path for CocoaPods in your .xcconfig files by prepending an #include statement like the following: #include “Pods/[path .xccofig file in Terminal”
Example:
I have two environments Stag and Production
After I run the pod file in Terminal. You’ll see in Terminal that CocoaPods did not set the configuration since we already set custom configurations. CocoaPods provides a link to be included in each
Open .xcworkspace file and select .xcconfig file
Finally, Cmd + Shift + K and run project
Good luck!!!
No need to deintegrate pods and install again. Just run
pod install
It will create necessary files for new configurations.
In my case, Xcode was using a Build Configuration that didn't exist anymore. Going to 'edit scheme...' and selecting a valid scheme fixed it for me.
In my case, the problem wasn't about cocoapods, it was about Fabric
I removed row $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH) from Build Phases > Fabric > Input File Lists and it fixed the error

What's the equivalent of "development pods" under Carthage?

The teams developing frameworks for our iOS app are migrating from Cocoapods to Carthage.
Under Cocoapods, I could set up dependencies as "development pods". For example, instead of having the main app download a specific version of an xyzzy dependency, I could set up xyzzy as a development pod and point it to my local directory where I had checked out xyzzy from its Git repo. While I was working in the main app's project, any edits I'd do to xyzzy's files would be made in that directory. This let me build and test changes immediately, and when I was ready to check them in, Git would find them in the xyzzy project's directory.
Under Carthage I haven't found a way to do this. I see http://allocinit.io/ios/debugging-carthage-dependencies/ which explains how to create symbolic links so that I can see the dependency source files to make debugging easier, but any edits I make to them are under the main application's Carthage/Builds directory.
How do I set up the equivalent of development pods under Carthage?
I believe Carthage doesn't have something similar to "development pods" yet.
But you could simulate "development pods" just following these steps:
Steps:
Add the .xcodeproj to your workspace
Remove all the dependencies you have in your project of the framework you added in step 1. (probably you may need to remove it from Build Phases -> Run Script -> Input Files too )
Go to General tab of the target you want to run, add the framework under Linked Frameworks and Libraries (it is going to take the one added from the .xcoproj)
(optional) you may need to run carthage bootstrap in the framework's repo you want to add locally.
That's it.
After that you will be able to run your project and update framework's code in the same workspace.
This works just as well as development pods for me, as of Xcode 8.3.3 and Carthage 0.24.0:
In app path, rm -rf Carthage
Point at the appropriate branch or tag in Cartfile
carthage update --use-submodules (generates .gitmodules and clones repo into Carthage/Checkouts)
In Xcode under project -> Build Phases -> Run Script, comment out the line that ends with carthage update --cache-builds if present.
Change to the General tab and remove the lib from Embedded Binaries
Right-click project, Add Files to app..., add lib from Carthage/Checkouts
Under project -> General, re-add the library, choosing the one you added in the previous step.
App should now build with the local lib. Make sure that your .gitignore has Carthage/{Build,Checkouts} and .gitmodules.
This answer is a summary of a successful implementation of the solution introduced here.
A cleaner solution is using local paths for dependencies in Cartfile.
Environment
Xcode 10.1
macOS 10.13.6
Step 1. Symbolic linking
1.1 Change $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) directory to a symbolic link pointing to source root directory of your developing framework $(SRCROOT_DEVELOPING_FRAMEWORK), where $(SRCROOT_MAIN) is source root directory of your main app. Backup existing directories before this change.
This linking enables version-controlled changes in your developing framework.
Syntax when using ln utility,
$ ln -s "$SRCROOT_DEVELOPING_FRAMEWORK" "$SRCROOT_MAIN/Carthage/Checkouts/$DEVELOPING_FRAMEWORK_NAME"
1.2 Change $(SRCROOT_DEVELOPING_FRAMEWORK)/Carthage/Build directory in your framework to a symbolic link pointing to $(SRCROOT_MAIN)/Carthage/Build directory. Backup existing directories before this change.
This linking enables access to all frameworks built by Carthage from both your developing framework and your main app.
Syntax when using ln utility,
$ ln -s "$SRCROOT_MAIN/Carthage/Build" "$SRCROOT_DEVELOPING_FRAMEWORK/Carthage/Build"
Step 2. Framework Replacement

2.1 Remove your developing framework in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries (that is, the one located in $(SRCROOT_MAIN)/Carthage/Build/iOS).
2.2 Add $(DEVELOPING_FRAMEWORK_NAME).xcodeproj (found in directory pointed by $(SRCROOT_MAIN)/Carthage/Checkouts/$(DEVELOPING_FRAMEWORK_NAME) symbolic link) into your main app
2.3 Build the developing framework product for device and simulator
2.4 Add the new developing framework auto-detected by Xcode in Xcode > YOUR_MAIN_APP > General > Linked Frameworks and Libraries.
2.5 Add $(DEVELOPING_FRAMEWORK_NAME).framework as a target dependency by adding $(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Target Dependencies.
2.6 Copy $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework to $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework by adding a new input file $(BUILT_PRODUCTS_DIR)/$(DEVELOPING_FRAMEWORK_NAME).framework and a new output file $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/$(DEVELOPING_FRAMEWORK_NAME).framework in Xcode > YOUR_MAIN_APP > Build Phases > Run Script of Carthage Embed Framework.
Reference
Debugging Carthage Dependencies
https://allocinit.io/ios/debugging-carthage-dependencies/
Build Setting Reference
https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

"No such module" error in Xcode 8

I get the "No such module" compilation error in Xcode 8.2.1 in my Swift project. I use Carthage with two modules: Alamofire and Fuzi. The Carthage/Build/iOS directory exists with the two framework files. The Build Settings/Framework Search Paths points to that directory. I have embedded the two framework files in General/Embedded Binaries. What am I missing?
You shouldn't need to embed the libraries; they should be added to Linked Frameworks and Libraries underneath the "General/Embedded Binaries" section. Make sure you have the Carthage copy-frameworks script added to your Build Phases.
From the Carthage documentation:
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 in which you
specify your shell (ex: bin/sh), add the following contents to the
script area below the shell:
/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/Box.framework
$(SRCROOT)/Carthage/Build/iOS/Result.framework
$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework
This script works around an App Store submission bug triggered by
universal binaries and ensures that necessary bitcode-related files
and dSYMs are copied when archiving.
Firstly you check Carthage installed or not in your machine like the following command in your terminal
carthage version
If carthage is not installed in your machine try the following.
Download the latest release of Carthage, and double-click Carthage.pkg to run the installer. Click Continue, select a location to install to, then click Continue again, and finally click Install.
Then you can check carthage version.
If you are using existing project then move to project folder like
cd ~/Path/To/Starter/Project
Try the following command for update cartfile
carthage update —platform iOS
After installation/updation completed then try the following command
open carthage
You should see a Finder window pop up that contains two directories: Build and Checkouts.
In the Carthage Finder window, navigate into Build\iOS. Now, drag Alamofire.framework(for example) into the Linked Frameworks and Libraries section in Xcode:
Next, switch over to Build Phases and add a new Run Script build phase. Add the following command:
/usr/local/bin/carthage copy-frameworks
Click the + under Input Files and add an entry for each framework:
$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework

Resources