I have a file hierarchy similar to this one:
File hierarchy image
And I need to capture in the visible area all the folders and files (swift and ObjC) that lie in the TestFramework. What podspec parameter to use for source file path? I try to use this:
s.source_files = "TestFramework/**/*"
Is the correct parameter I use?
Okey, s.source_files = "TestFramework/**/*" is correct parameter for my situation.
/** - matches directories recursively.
/* - matches any file.
Sometimes it is necessary to limit the type of files that should be visible. For such situations, the following parameters are used:
s.source_files = "TestFramework/**/*.{h,m,swift}"
Related
I have read the question, but unfortunately the proposed solutions are to change source code of header files location, which on this case it's not possible.
Let's imagine I have the following structure of system includes from an installed package:
/usr/local/bar/bar1.h
/usr/local/bar/bar2.h
And
/usr/include/foo.h
Important detail:
bar1.h includes foo.h
foo.h includes bar2.h
From Bazel, I would right away create a new_git_repository() from /usr/local/bar and then create a library containing the header files from this folder as:
cc_library(
name = "libBar",
hrds = ["bar1.h", "bar2.h"],
deps = ["#foo//:libFoo"],
)
I would do another new_git_repository() from /usr/include/ and create a library:
cc_library(
name = "libFoo",
hrds = ["foo.h"],
deps = ["#bar//:libBar"],
)
As seen, this will end up in a compilation error from Bazel regarding cyclic dependencies:
libBar is dependent of libFoo, and libFoo is dependend of libBar.
Or course a solution would be to separate the libBar into some libBar1 and libBar2. But I would want to avoid this solution as the folder /usr/local/bar contains too many header files and separating this will be a nightmare.
Is there a proper solution for this case?
I have an entry like this in my pbxproj file:
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
The part of it I'm interested is this line:
path = "../node_modules/react-native/React/React.xcodeproj";
Is there a way to modify this so I could get the path to the react-native folder programatically?
Like, if this were a bash script, I could use an expansion like so:
"$(run-some-script)/React/React.xcodeproj"
I could make a script that the user could run to automatically update the paths in the pbxproj whenever they change, but I am curious if I could have a way to have Xcode run a command to get the path to this React.xcodeproj file whenever it is opened.
Short answer is no, but you can place other source code or a library files inside the toplevel xcode project directory and then reference these files as relative paths. That way, you can link to the project relative files and then update them and the xcode build will just make use of them. For example, you can include source code that is under a completely different git repo in a subdirectory, then you can update that code differently that the toplevel source, and yet still build the whole combined project together.
I have a project with multiple targets, which represent the same app just with different styling and translations.
Since almost whole project looks the same for each target, I need to have just few strings in Localizable.strings file, that I need to be different. And I don't want to copy whole huge Localizable.strings file to each project just because of the fact it has few lines different.
It is required for me to have just 1 strings file because of third-party libraries/SDK that are included in project. So I cannot use tableName for localizedString.
The problem is - I need to have a flexible possibility to override just few lines from Localizable.strings for each target separately. And I don't like the idea just to copy whole file to each target, cause it will lead to annoying flow in the future, in case I will have 10 targets and I need to add 1 string to all of them.
The goal is to have 1 huge Localizable.strings file with all strings included, that would be common for all targets, and have small configuration for each target for the strings that should tell different. So target's file should kinda merge and override the one that is common.
AFAIK it is not natively supported by Xcode, so I'm probably looking for a script that would make it works.
So, script should look into common and target's Localizable files, merge them, and in case some keys are defined in both, then it should use the one from target's file.
Can anyone help me with such script?
P.S. Similar issue exists with .xcassets, and CocoaPods solves it by merging multiple assets into 1, and it works as expected - if some targets has an asset containing the image with the same name that is already included into a common asset, then the one from target will replace it.
P.S.2. Similar feature is natively supported for Android devs - each image, each translations can be overridden by "child" flawor, or whatever it is called :)
TL;DR:
Example project: https://github.com/JakubMazur/SO45279964
OK, the easier thing to do would be shell/python script, because it will work for every build server. I assume that you have a different scheme for each target (otherwise it will make no sense). So what you can do is:
Let's say your target is named:
target1
target2
target3
1) Create separate files contains all the strings that should be different (i will put it under Localizable directory.
Your Localizable.strings file may look like this:
"someGeneralString" = "General string 1";
"AppName" = "This is a string that you probably need to change";
"someOtherGeneralString" = "General string 2";
And any of your targetX.strings file may look like this:
"AppName" = "target[x]"
And here is how it should look like in your project:
Note that your target localizable files should has target membership set only to one target, but your Localizable.strings should be for all targets!
That's all for project configuration. Let's go to scripting (I will use python for that):
#!/usr/bin/python
import sys
supportedLanguages = ["en","pl"]
commonPath = ".lproj/Localizable.strings"
keys = ["AppName"]
class CopyLocalizable():
target = ""
def __init__(self,arg):
self.target = arg
self.perform()
def perform(self):
for lang in supportedLanguages:
pathToLocalizable = lang+commonPath
textToFile = ""
with open(pathToLocalizable,"r") as languageFile:
for line in languageFile.readlines():
for key in keys:
if key in line:
textToFile += self.foundAndReplace(key,lang)
else:
textToFile += line
self.saveInFile(pathToLocalizable,textToFile)
def foundAndReplace(self,key,lang):
pathToTargetFile = "Localizable/"+lang+".lproj/"+self.target+".strings"
with open(pathToTargetFile,"r") as targetFile:
for targetLine in targetFile.readlines():
if key in targetLine:
return targetLine
def saveInFile(self,file,stringToSave):
with open(file,"w+") as languageFile:
languageFile.write(stringToSave)
You can optimize it yourself. It's easier script i can think about to get a job done.
And in the end let's automate it a bit:
- Go to your target
- add a new build phase
- Add a new script:
export PATH="/usr/local/bin:$PATH"
cd SO45279964/
python localize.py target[x]
and watch a magic happen ;)
http://www.giphy.com/gifs/26n6NKgiwYvuQk7WU
Here you can find example project that I've created to run this example:
https://github.com/JakubMazur/SO45279964
To keep it simple, Have a Macro defined for each target in Build Settings & define target specific strings within macro section like
#ifdef __TARGET__
//key values in localizable file
#endif
Example taken from https://guides.cocoapods.org/syntax/podspec.html#requires_arc:
spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm']
What is the meaning of the following? Can you give an example that to use? Thanks!
Classes/*ARC.m
Classes/ARC.mm
According to the Cocoapods documentation (which you're presumably looking at right now), your choices are "true", "false" or the actual files that require ARC (automated-ref-counting).
So for the Podspec pattern spec.requires_arc = ['Classes/*ARC.m', 'Classes/ARC.mm'] you'd be saying that any files in the "Classes" directory that are either named ARC.mm or *ARC.m (i.e. * being a wildcard so "ChenFanFangARC.m would be a valid match while ARCMichael.m is not), these files are expected to work with Automated Reference Counting.
All other files compiled for this pod would have ARC turned off.
I want to use cocoapods to install ZXing, but some .hh file can not be downloaded, what I write is something like this:
s.source_files = 'cpp/core/src/zxing/**/*.hh', 'cpp/core/src/zxing/**/*.h', 'cpp/core/src/zxing/**/*.cpp', 'objc/src/ZXing/*.{m,mm}'
it turns out to be my networking problem that leads to some files haven't been downloaded, so the syntax of my sources_file pattern is right.